YSMlearnsCode
commited on
Commit
·
3f5e6fe
1
Parent(s):
1afe6d7
optimized prompt for teapot
Browse files- prompts/example_code.txt +146 -1
prompts/example_code.txt
CHANGED
|
@@ -225,4 +225,149 @@ use this template whenever asked to make a flange
|
|
| 225 |
'YoungsModulus': '200000 MPa',
|
| 226 |
'PoissonRatio': '0.3'
|
| 227 |
}
|
| 228 |
-
material_obj.Label = "StainlessSteelMaterial"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
'YoungsModulus': '200000 MPa',
|
| 226 |
'PoissonRatio': '0.3'
|
| 227 |
}
|
| 228 |
+
material_obj.Label = "StainlessSteelMaterial"
|
| 229 |
+
|
| 230 |
+
- This is a good example for a teapot. Whenever asked to generate a teapot, make something similar:
|
| 231 |
+
import FreeCAD as App
|
| 232 |
+
import FreeCADGui as Gui
|
| 233 |
+
from FreeCAD import Vector, Placement, Rotation
|
| 234 |
+
import Part
|
| 235 |
+
|
| 236 |
+
# Teapot dimensions
|
| 237 |
+
BODY_BOTTOM_RADIUS = 50.0
|
| 238 |
+
BODY_MAX_RADIUS = 80.0
|
| 239 |
+
BODY_HEIGHT = 100.0
|
| 240 |
+
LID_OPENING_RADIUS = 35.0
|
| 241 |
+
|
| 242 |
+
# Spout parameters
|
| 243 |
+
SPOUT_ATTACH_HEIGHT = BODY_HEIGHT * 0.5 # 50.0
|
| 244 |
+
SPOUT_OFFSET_Y = BODY_MAX_RADIUS * 0.7 # 56.0
|
| 245 |
+
SPOUT_LENGTH_HORIZONTAL = 60.0
|
| 246 |
+
SPOUT_LENGTH_VERTICAL = 30.0
|
| 247 |
+
SPOUT_RADIUS = 7.0
|
| 248 |
+
|
| 249 |
+
# Handle parameters
|
| 250 |
+
HANDLE_ATTACH_TOP_HEIGHT = BODY_HEIGHT * 0.7 # 70.0
|
| 251 |
+
HANDLE_ATTACH_BOTTOM_HEIGHT = BODY_HEIGHT * 0.3 # 30.0
|
| 252 |
+
HANDLE_OFFSET_Y = -BODY_MAX_RADIUS * 0.7 # -56.0
|
| 253 |
+
HANDLE_RADIUS = 6.0
|
| 254 |
+
|
| 255 |
+
def createTeapot():
|
| 256 |
+
doc = App.newDocument("Teapot")
|
| 257 |
+
|
| 258 |
+
# --- 1. Body ---
|
| 259 |
+
body_profile_pts = [
|
| 260 |
+
Vector(BODY_BOTTOM_RADIUS, 0, 0),
|
| 261 |
+
Vector(BODY_MAX_RADIUS, 0, BODY_HEIGHT * 0.4),
|
| 262 |
+
Vector(BODY_MAX_RADIUS * 0.8, 0, BODY_HEIGHT * 0.7),
|
| 263 |
+
Vector(LID_OPENING_RADIUS, 0, BODY_HEIGHT)
|
| 264 |
+
]
|
| 265 |
+
body_spline = Part.BSplineCurve(body_profile_pts)
|
| 266 |
+
body_edge = body_spline.toShape()
|
| 267 |
+
line1 = Part.LineSegment(Vector(LID_OPENING_RADIUS, 0, BODY_HEIGHT), Vector(0, 0, BODY_HEIGHT)).toShape()
|
| 268 |
+
line2 = Part.LineSegment(Vector(0, 0, BODY_HEIGHT), Vector(0, 0, 0)).toShape()
|
| 269 |
+
line3 = Part.LineSegment(Vector(0, 0, 0), Vector(BODY_BOTTOM_RADIUS, 0, 0)).toShape()
|
| 270 |
+
wire = Part.Wire([body_edge, line1, line2, line3])
|
| 271 |
+
face = Part.Face(wire)
|
| 272 |
+
body_solid = face.revolve(Vector(0, 0, 0), Vector(0, 0, 1), 360)
|
| 273 |
+
|
| 274 |
+
obj_body = doc.addObject("Part::Feature", "Body")
|
| 275 |
+
obj_body.Shape = body_solid
|
| 276 |
+
obj_body.ViewObject.ShapeColor = (0.9, 0.7, 0.7)
|
| 277 |
+
|
| 278 |
+
# --- 2. Lid ---
|
| 279 |
+
lid_profile_pts = [
|
| 280 |
+
Vector(36.0, 0, 0),
|
| 281 |
+
Vector(36.0, 0, 3.0),
|
| 282 |
+
Vector(35.0, 0, 3.0 + 20.0 * 0.2),
|
| 283 |
+
Vector(17.5, 0, 3.0 + 20.0 * 0.7),
|
| 284 |
+
Vector(10.0, 0, 3.0 + 20.0),
|
| 285 |
+
Vector(5.0, 0, 3.0 + 20.0 + 15.0 * 0.8),
|
| 286 |
+
Vector(0, 0, 3.0 + 20.0 + 15.0)
|
| 287 |
+
]
|
| 288 |
+
lid_spline = Part.BSplineCurve(lid_profile_pts)
|
| 289 |
+
lid_edge = lid_spline.toShape()
|
| 290 |
+
line1 = Part.LineSegment(Vector(0, 0, 3.0 + 20.0 + 15.0), Vector(0, 0, 0)).toShape()
|
| 291 |
+
line2 = Part.LineSegment(Vector(0, 0, 0), Vector(36.0, 0, 0)).toShape()
|
| 292 |
+
wire_lid = Part.Wire([lid_edge, line1, line2])
|
| 293 |
+
face_lid = Part.Face(wire_lid)
|
| 294 |
+
lid_solid = face_lid.revolve(Vector(0, 0, 0), Vector(0, 0, 1), 360)
|
| 295 |
+
|
| 296 |
+
obj_lid = doc.addObject("Part::Feature", "Lid")
|
| 297 |
+
obj_lid.Shape = lid_solid
|
| 298 |
+
obj_lid.Placement = Placement(Vector(0, 0, BODY_HEIGHT), Rotation())
|
| 299 |
+
obj_lid.ViewObject.ShapeColor = (0.9, 0.7, 0.7)
|
| 300 |
+
|
| 301 |
+
# --- 3. Spout (Precomputed final positions) ---
|
| 302 |
+
spout_path_pts = [
|
| 303 |
+
Vector(0, -121, 66), # Original: (0, -56, 50) -> transformed
|
| 304 |
+
Vector(0, -91, 51), # Original: (0, -26, 65) -> transformed
|
| 305 |
+
Vector(0, -61, 36) # Original: (0, 4, 80) -> transformed
|
| 306 |
+
]
|
| 307 |
+
|
| 308 |
+
spout_curve = Part.BSplineCurve(spout_path_pts)
|
| 309 |
+
spout_wire = Part.Wire(spout_curve.toShape())
|
| 310 |
+
|
| 311 |
+
tangent_spout = spout_curve.tangent(spout_curve.FirstParameter)[0]
|
| 312 |
+
tangent_spout.normalize()
|
| 313 |
+
|
| 314 |
+
spout_circle = Part.Circle()
|
| 315 |
+
spout_circle.Center = spout_path_pts[0]
|
| 316 |
+
spout_circle.Axis = tangent_spout
|
| 317 |
+
spout_circle.Radius = SPOUT_RADIUS
|
| 318 |
+
spout_profile = Part.Wire(spout_circle.toShape())
|
| 319 |
+
|
| 320 |
+
spout_solid = spout_wire.makePipe(spout_profile)
|
| 321 |
+
obj_spout = doc.addObject("Part::Feature", "Spout")
|
| 322 |
+
obj_spout.Shape = spout_solid
|
| 323 |
+
obj_spout.ViewObject.ShapeColor = (0.9, 0.7, 0.7)
|
| 324 |
+
|
| 325 |
+
# --- 4. Handle (Precomputed final positions) ---
|
| 326 |
+
handle_path_pts = [
|
| 327 |
+
Vector(0, 56, 31), # Original: (0, 56, 70) -> transformed
|
| 328 |
+
Vector(0, 78, 43), # Original: (0, 78, 58) -> transformed
|
| 329 |
+
Vector(0, 78, 79), # Original: (0, 78, 22) -> transformed
|
| 330 |
+
Vector(0, 56, 71) # Original: (0, 56, 30) -> transformed
|
| 331 |
+
]
|
| 332 |
+
|
| 333 |
+
handle_curve = Part.BSplineCurve(handle_path_pts)
|
| 334 |
+
handle_wire = Part.Wire(handle_curve.toShape())
|
| 335 |
+
|
| 336 |
+
tangent_handle = handle_curve.tangent(handle_curve.FirstParameter)[0]
|
| 337 |
+
tangent_handle.normalize()
|
| 338 |
+
|
| 339 |
+
handle_circle = Part.Circle()
|
| 340 |
+
handle_circle.Center = handle_path_pts[0]
|
| 341 |
+
handle_circle.Axis = tangent_handle
|
| 342 |
+
handle_circle.Radius = HANDLE_RADIUS
|
| 343 |
+
handle_profile = Part.Wire(handle_circle.toShape())
|
| 344 |
+
|
| 345 |
+
handle_solid = handle_wire.makePipe(handle_profile)
|
| 346 |
+
obj_handle = doc.addObject("Part::Feature", "Handle")
|
| 347 |
+
obj_handle.Shape = handle_solid
|
| 348 |
+
obj_handle.ViewObject.ShapeColor = (0.9, 0.7, 0.7)
|
| 349 |
+
|
| 350 |
+
# --- 5. Fuse all parts ---
|
| 351 |
+
fused = obj_body.Shape.fuse(obj_lid.Shape)
|
| 352 |
+
fused = fused.fuse(obj_spout.Shape)
|
| 353 |
+
fused = fused.fuse(obj_handle.Shape)
|
| 354 |
+
|
| 355 |
+
obj_final = doc.addObject("Part::Feature", "Teapot_Complete")
|
| 356 |
+
obj_final.Shape = fused
|
| 357 |
+
obj_final.ViewObject.ShapeColor = (0.9, 0.6, 0.6)
|
| 358 |
+
|
| 359 |
+
# Hide individual parts for clarity
|
| 360 |
+
obj_body.ViewObject.Visibility = False
|
| 361 |
+
obj_lid.ViewObject.Visibility = False
|
| 362 |
+
obj_spout.ViewObject.Visibility = False
|
| 363 |
+
obj_handle.ViewObject.Visibility = False
|
| 364 |
+
|
| 365 |
+
doc.recompute()
|
| 366 |
+
|
| 367 |
+
Gui.activeDocument().activeView().viewAxometric()
|
| 368 |
+
Gui.SendMsgToActiveView("ViewFit")
|
| 369 |
+
|
| 370 |
+
return doc
|
| 371 |
+
|
| 372 |
+
if __name__ == "__main__":
|
| 373 |
+
createTeapot()
|