FreeCAD Scripts

FreeCAD Scripts

Makes the AI an expert at writing FreeCAD Python scripts and macros for parametric models, GUI tools and automation.

Skill files6 files

references/

SKILL.md690 lines
1
---
2
name: freecad-scripts
3
description: 'Expert skill for writing FreeCAD Python scripts, macros, and automation. Use when asked to create FreeCAD models, parametric objects, Part/Mesh/Sketcher scripts, workbench tools, GUI dialogs with PySide, Coin3D scenegraph manipulation, or any FreeCAD Python API task. Covers FreeCAD scripting basics, geometry creation, FeaturePython objects, interface tools, and macro development.'
4
---
5
6
# FreeCAD Scripts
7
8
Expert skill for generating production-quality Python scripts for the FreeCAD CAD application. Interprets shorthand, quasi-code, and natural language descriptions of 3D modeling tasks and translates them into correct FreeCAD Python API calls.
9
10
## When to Use This Skill
11
12
- Writing Python scripts for FreeCAD's built-in console or macro system
13
- Creating or manipulating 3D geometry (Part, Mesh, Sketcher, Path, FEM)
14
- Building parametric FeaturePython objects with custom properties
15
- Developing GUI tools using PySide/Qt within FreeCAD
16
- Manipulating the Coin3D scenegraph via Pivy
17
- Creating custom workbenches or Gui Commands
18
- Automating repetitive CAD operations with macros
19
- Converting between mesh and solid representations
20
- Scripting FEM analyses, raytracing, or drawing exports
21
22
## Prerequisites
23
24
- FreeCAD installed (0.19+ recommended; 0.21+/1.0+ for latest API)
25
- Python 3.x (bundled with FreeCAD)
26
- For GUI work: PySide2 (bundled with FreeCAD)
27
- For scenegraph: Pivy (bundled with FreeCAD)
28
29
## FreeCAD Python Environment
30
31
FreeCAD embeds a Python interpreter. Scripts run in an environment where these key modules are available:
32
33
```python
34
import FreeCAD # Core module (also aliased as 'App')
35
import FreeCADGui # GUI module (also aliased as 'Gui') — only in GUI mode
36
import Part # Part workbench — BRep/OpenCASCADE shapes
37
import Mesh # Mesh workbench — triangulated meshes
38
import Sketcher # Sketcher workbench — 2D constrained sketches
39
import Draft # Draft workbench — 2D drawing tools
40
import Arch # Arch/BIM workbench
41
import Path # Path/CAM workbench
42
import FEM # FEM workbench
43
import TechDraw # TechDraw workbench (replaces Drawing)
44
import BOPTools # Boolean operations
45
import CompoundTools # Compound shape utilities
46
```
47
48
### The FreeCAD Document Model
49
50
```python
51
# Create or access a document
52
doc = FreeCAD.newDocument("MyDoc")
53
doc = FreeCAD.ActiveDocument
54
55
# Add objects
56
box = doc.addObject("Part::Box", "MyBox")
57
box.Length = 10.0
58
box.Width = 10.0
59
box.Height = 10.0
60
61
# Recompute
62
doc.recompute()
63
64
# Access objects
65
obj = doc.getObject("MyBox")
66
obj = doc.MyBox # Attribute access also works
67
68
# Remove objects
69
doc.removeObject("MyBox")
70
```
71
72
## Core Concepts
73
74
### Vectors and Placements
75
76
```python
77
import FreeCAD
78
79
# Vectors
80
v1 = FreeCAD.Vector(1, 0, 0)
81
v2 = FreeCAD.Vector(0, 1, 0)
82
v3 = v1.cross(v2) # Cross product
83
d = v1.dot(v2) # Dot product
84
v4 = v1 + v2 # Addition
85
length = v1.Length # Magnitude
86
v_norm = FreeCAD.Vector(v1)
87
v_norm.normalize() # In-place normalize
88
89
# Rotations
90
rot = FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 45) # axis, angle(deg)
91
rot = FreeCAD.Rotation(0, 0, 45) # Euler angles (yaw, pitch, roll)
92
93
# Placements (position + orientation)
94
placement = FreeCAD.Placement(
95
FreeCAD.Vector(10, 20, 0), # translation
96
FreeCAD.Rotation(0, 0, 45), # rotation
97
FreeCAD.Vector(0, 0, 0) # center of rotation
98
)
99
obj.Placement = placement
100
101
# Matrix (4x4 transformation)
102
import math
103
mat = FreeCAD.Matrix()
104
mat.move(FreeCAD.Vector(10, 0, 0))
105
mat.rotateZ(math.radians(45))
106
```
107
108
### Creating and Manipulating Geometry (Part Module)
109
110
The Part module wraps OpenCASCADE and provides BRep solid modeling:
111
112
```python
113
import FreeCAD
114
import Part
115
116
# --- Primitive Shapes ---
117
box = Part.makeBox(10, 10, 10) # length, width, height
118
cyl = Part.makeCylinder(5, 20) # radius, height
119
sphere = Part.makeSphere(10) # radius
120
cone = Part.makeCone(5, 2, 10) # r1, r2, height
121
torus = Part.makeTorus(10, 2) # major_r, minor_r
122
123
# --- Wires and Edges ---
124
edge1 = Part.makeLine((0, 0, 0), (10, 0, 0))
125
edge2 = Part.makeLine((10, 0, 0), (10, 10, 0))
126
edge3 = Part.makeLine((10, 10, 0), (0, 0, 0))
127
wire = Part.Wire([edge1, edge2, edge3])
128
129
# Circles and arcs
130
circle = Part.makeCircle(5) # radius
131
arc = Part.makeCircle(5, FreeCAD.Vector(0, 0, 0),
132
FreeCAD.Vector(0, 0, 1), 0, 180) # start/end angle
133
134
# --- Faces ---
135
face = Part.Face(wire) # From a closed wire
136
137
# --- Solids from Faces/Wires ---
138
extrusion = face.extrude(FreeCAD.Vector(0, 0, 10)) # Extrude
139
revolved = face.revolve(FreeCAD.Vector(0, 0, 0),
140
FreeCAD.Vector(0, 0, 1), 360) # Revolve
141
142
# --- Boolean Operations ---
143
fused = box.fuse(cyl) # Union
144
cut = box.cut(cyl) # Subtraction
145
common = box.common(cyl) # Intersection
146
fused_clean = fused.removeSplitter() # Clean up seams
147
148
# --- Fillets and Chamfers ---
149
filleted = box.makeFillet(1.0, box.Edges) # radius, edges
150
chamfered = box.makeChamfer(1.0, box.Edges) # dist, edges
151
152
# --- Loft and Sweep ---
153
loft = Part.makeLoft([wire1, wire2], True) # wires, solid
154
swept = Part.Wire([path_edge]).makePipeShell([profile_wire],
155
True, False) # solid, frenet
156
157
# --- BSpline Curves ---
158
from FreeCAD import Vector
159
points = [Vector(0,0,0), Vector(1,2,0), Vector(3,1,0), Vector(4,3,0)]
160
bspline = Part.BSplineCurve()
161
bspline.interpolate(points)
162
edge = bspline.toShape()
163
164
# --- Show in document ---
165
Part.show(box, "MyBox") # Quick display (adds to active doc)
166
# Or explicitly:
167
doc = FreeCAD.ActiveDocument or FreeCAD.newDocument()
168
obj = doc.addObject("Part::Feature", "MyShape")
169
obj.Shape = box
170
doc.recompute()
171
```
172
173
### Topological Exploration
174
175
```python
176
shape = obj.Shape
177
178
# Access sub-elements
179
shape.Vertexes # List of Vertex objects
180
shape.Edges # List of Edge objects
181
shape.Wires # List of Wire objects
182
shape.Faces # List of Face objects
183
shape.Shells # List of Shell objects
184
shape.Solids # List of Solid objects
185
186
# Bounding box
187
bb = shape.BoundBox
188
print(bb.XMin, bb.XMax, bb.YMin, bb.YMax, bb.ZMin, bb.ZMax)
189
print(bb.Center)
190
191
# Properties
192
shape.Volume
193
shape.Area
194
shape.Length # For edges/wires
195
face.Surface # Underlying geometric surface
196
edge.Curve # Underlying geometric curve
197
198
# Shape type
199
shape.ShapeType # "Solid", "Shell", "Face", "Wire", "Edge", "Vertex", "Compound"
200
```
201
202
### Mesh Module
203
204
```python
205
import Mesh
206
207
# Create mesh from vertices and facets
208
mesh = Mesh.Mesh()
209
mesh.addFacet(
210
0.0, 0.0, 0.0, # vertex 1
211
1.0, 0.0, 0.0, # vertex 2
212
0.0, 1.0, 0.0 # vertex 3
213
)
214
215
# Import/Export
216
mesh = Mesh.Mesh("/path/to/file.stl")
217
mesh.write("/path/to/output.stl")
218
219
# Convert Part shape to Mesh
220
import Part
221
import MeshPart
222
shape = Part.makeBox(1, 1, 1)
223
mesh = MeshPart.meshFromShape(Shape=shape, LinearDeflection=0.1,
224
AngularDeflection=0.5)
225
226
# Convert Mesh to Part shape
227
shape = Part.Shape()
228
shape.makeShapeFromMesh(mesh.Topology, 0.05) # tolerance
229
solid = Part.makeSolid(shape)
230
```
231
232
### Sketcher Module
233
234
# Create a sketch on XY plane
235
sketch = doc.addObject("Sketcher::SketchObject", "MySketch")
236
sketch.Placement = FreeCAD.Placement(
237
FreeCAD.Vector(0, 0, 0),
238
FreeCAD.Rotation(0, 0, 0, 1)
239
)
240
241
# Add geometry (returns geometry index)
242
idx_line = sketch.addGeometry(Part.LineSegment(
243
FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(10, 0, 0)))
244
idx_circle = sketch.addGeometry(Part.Circle(
245
FreeCAD.Vector(5, 5, 0), FreeCAD.Vector(0, 0, 1), 3))
246
247
# Add constraints
248
sketch.addConstraint(Sketcher.Constraint("Coincident", 0, 2, 1, 1))
249
sketch.addConstraint(Sketcher.Constraint("Horizontal", 0))
250
sketch.addConstraint(Sketcher.Constraint("DistanceX", 0, 1, 0, 2, 10.0))
251
sketch.addConstraint(Sketcher.Constraint("Radius", 1, 3.0))
252
sketch.addConstraint(Sketcher.Constraint("Fixed", 0, 1))
253
# Constraint types: Coincident, Horizontal, Vertical, Parallel, Perpendicular,
254
# Tangent, Equal, Symmetric, Distance, DistanceX, DistanceY, Radius, Angle,
255
# Fixed (Block), InternalAlignment
256
257
doc.recompute()
258
```
259
260
### Draft Module
261
262
```python
263
import Draft
264
import FreeCAD
265
266
# 2D shapes
267
line = Draft.makeLine(FreeCAD.Vector(0,0,0), FreeCAD.Vector(10,0,0))
268
circle = Draft.makeCircle(5)
269
rect = Draft.makeRectangle(10, 5)
270
poly = Draft.makePolygon(6, radius=5) # hexagon
271
272
# Operations
273
moved = Draft.move(obj, FreeCAD.Vector(10, 0, 0), copy=True)
274
rotated = Draft.rotate(obj, 45, FreeCAD.Vector(0,0,0),
275
axis=FreeCAD.Vector(0,0,1), copy=True)
276
scaled = Draft.scale(obj, FreeCAD.Vector(2,2,2), center=FreeCAD.Vector(0,0,0),
277
copy=True)
278
offset = Draft.offset(obj, FreeCAD.Vector(1,0,0))
279
array = Draft.makeArray(obj, FreeCAD.Vector(15,0,0),
280
FreeCAD.Vector(0,15,0), 3, 3)
281
```
282
283
## Creating Parametric Objects (FeaturePython)
284
285
FeaturePython objects are custom parametric objects with properties that trigger recomputation:
286
287
```python
288
import FreeCAD
289
import Part
290
291
class MyBox:
292
"""A custom parametric box."""
293
294
def __init__(self, obj):
295
obj.Proxy = self
296
obj.addProperty("App::PropertyLength", "Length", "Dimensions",
297
"Box length").Length = 10.0
298
obj.addProperty("App::PropertyLength", "Width", "Dimensions",
299
"Box width").Width = 10.0
300
obj.addProperty("App::PropertyLength", "Height", "Dimensions",
301
"Box height").Height = 10.0
302
303
def execute(self, obj):
304
"""Called on document recompute."""
305
obj.Shape = Part.makeBox(obj.Length, obj.Width, obj.Height)
306
307
def onChanged(self, obj, prop):
308
"""Called when a property changes."""
309
pass
310
311
def __getstate__(self):
312
return None
313
314
def __setstate__(self, state):
315
return None
316
317
318
class ViewProviderMyBox:
319
"""View provider for custom icon and display settings."""
320
321
def __init__(self, vobj):
322
vobj.Proxy = self
323
324
def getIcon(self):
325
return ":/icons/Part_Box.svg"
326
327
def attach(self, vobj):
328
self.Object = vobj.Object
329
330
def updateData(self, obj, prop):
331
pass
332
333
def onChanged(self, vobj, prop):
334
pass
335
336
def __getstate__(self):
337
return None
338
339
def __setstate__(self, state):
340
return None
341
342
343
# --- Usage ---
344
doc = FreeCAD.ActiveDocument or FreeCAD.newDocument("Test")
345
obj = doc.addObject("Part::FeaturePython", "CustomBox")
346
MyBox(obj)
347
ViewProviderMyBox(obj.ViewObject)
348
doc.recompute()
349
```
350
351
### Common Property Types
352
353
| Property Type | Python Type | Description |
354
|---|---|---|
355
| `App::PropertyBool` | `bool` | Boolean |
356
| `App::PropertyInteger` | `int` | Integer |
357
| `App::PropertyFloat` | `float` | Float |
358
| `App::PropertyString` | `str` | String |
359
| `App::PropertyLength` | `float` (units) | Length with units |
360
| `App::PropertyAngle` | `float` (deg) | Angle in degrees |
361
| `App::PropertyVector` | `FreeCAD.Vector` | 3D vector |
362
| `App::PropertyPlacement` | `FreeCAD.Placement` | Position + rotation |
363
| `App::PropertyLink` | object ref | Link to another object |
364
| `App::PropertyLinkList` | list of refs | Links to multiple objects |
365
| `App::PropertyEnumeration` | `list`/`str` | Dropdown selection |
366
| `App::PropertyFile` | `str` | File path |
367
| `App::PropertyColor` | `tuple` | RGB color (0.0-1.0) |
368
| `App::PropertyPythonObject` | any | Serializable Python object |
369
370
## Creating GUI Tools
371
372
### Gui Commands
373
374
```python
375
import FreeCAD
376
import FreeCADGui
377
378
class MyCommand:
379
"""A custom toolbar/menu command."""
380
381
def GetResources(self):
382
return {
383
"Pixmap": ":/icons/Part_Box.svg",
384
"MenuText": "My Custom Command",
385
"ToolTip": "Creates a custom box",
386
"Accel": "Ctrl+Shift+B"
387
}
388
389
def IsActive(self):
390
return FreeCAD.ActiveDocument is not None
391
392
def Activated(self):
393
# Command logic here
394
FreeCAD.Console.PrintMessage("Command activated\n")
395
396
FreeCADGui.addCommand("My_CustomCommand", MyCommand())
397
```
398
399
### PySide Dialogs
400
401
```python
402
from PySide2 import QtWidgets, QtCore, QtGui
403
404
class MyDialog(QtWidgets.QDialog):
405
def __init__(self, parent=None):
406
super().__init__(parent or FreeCADGui.getMainWindow())
407
self.setWindowTitle("My Tool")
408
self.setMinimumWidth(300)
409
410
layout = QtWidgets.QVBoxLayout(self)
411
412
# Input fields
413
self.label = QtWidgets.QLabel("Length:")
414
self.spinbox = QtWidgets.QDoubleSpinBox()
415
self.spinbox.setRange(0.1, 1000.0)
416
self.spinbox.setValue(10.0)
417
self.spinbox.setSuffix(" mm")
418
419
form = QtWidgets.QFormLayout()
420
form.addRow(self.label, self.spinbox)
421
layout.addLayout(form)
422
423
# Buttons
424
btn_layout = QtWidgets.QHBoxLayout()
425
self.btn_ok = QtWidgets.QPushButton("OK")
426
self.btn_cancel = QtWidgets.QPushButton("Cancel")
427
btn_layout.addWidget(self.btn_ok)
428
btn_layout.addWidget(self.btn_cancel)
429
layout.addLayout(btn_layout)
430
431
self.btn_ok.clicked.connect(self.accept)
432
self.btn_cancel.clicked.connect(self.reject)
433
434
# Usage
435
dialog = MyDialog()
436
if dialog.exec_() == QtWidgets.QDialog.Accepted:
437
length = dialog.spinbox.value()
438
FreeCAD.Console.PrintMessage(f"Length: {length}\n")
439
```
440
441
### Task Panel (Recommended for FreeCAD integration)
442
443
```python
444
class MyTaskPanel:
445
"""Task panel shown in the left sidebar."""
446
447
def __init__(self):
448
self.form = QtWidgets.QWidget()
449
layout = QtWidgets.QVBoxLayout(self.form)
450
self.spinbox = QtWidgets.QDoubleSpinBox()
451
self.spinbox.setValue(10.0)
452
layout.addWidget(QtWidgets.QLabel("Length:"))
453
layout.addWidget(self.spinbox)
454
455
def accept(self):
456
# Called when user clicks OK
457
length = self.spinbox.value()
458
FreeCAD.Console.PrintMessage(f"Accepted: {length}\n")
459
FreeCADGui.Control.closeDialog()
460
return True
461
462
def reject(self):
463
FreeCADGui.Control.closeDialog()
464
return True
465
466
def getStandardButtons(self):
467
return int(QtWidgets.QDialogButtonBox.Ok |
468
QtWidgets.QDialogButtonBox.Cancel)
469
470
# Show the panel
471
panel = MyTaskPanel()
472
FreeCADGui.Control.showDialog(panel)
473
```
474
475
## Coin3D Scenegraph (Pivy)
476
477
```python
478
from pivy import coin
479
import FreeCADGui
480
481
# Access the scenegraph root
482
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
483
484
# Add a custom separator with a sphere
485
sep = coin.SoSeparator()
486
mat = coin.SoMaterial()
487
mat.diffuseColor.setValue(1.0, 0.0, 0.0) # Red
488
trans = coin.SoTranslation()
489
trans.translation.setValue(10, 10, 10)
490
sphere = coin.SoSphere()
491
sphere.radius.setValue(2.0)
492
sep.addChild(mat)
493
sep.addChild(trans)
494
sep.addChild(sphere)
495
sg.addChild(sep)
496
497
# Remove later
498
sg.removeChild(sep)
499
```
500
501
## Custom Workbench Creation
502
503
```python
504
import FreeCADGui
505
506
class MyWorkbench(FreeCADGui.Workbench):
507
MenuText = "My Workbench"
508
ToolTip = "A custom workbench"
509
Icon = ":/icons/freecad.svg"
510
511
def Initialize(self):
512
"""Called at workbench activation."""
513
import MyCommands # Import your command module
514
self.appendToolbar("My Tools", ["My_CustomCommand"])
515
self.appendMenu("My Menu", ["My_CustomCommand"])
516
517
def Activated(self):
518
pass
519
520
def Deactivated(self):
521
pass
522
523
def GetClassName(self):
524
return "Gui::PythonWorkbench"
525
526
FreeCADGui.addWorkbench(MyWorkbench)
527
```
528
529
## Macro Best Practices
530
531
```python
532
# Standard macro header
533
# -*- coding: utf-8 -*-
534
# FreeCAD Macro: MyMacro
535
# Description: Brief description of what the macro does
536
# Author: YourName
537
# Version: 1.0
538
# Date: 2026-04-07
539
540
import FreeCAD
541
import Part
542
from FreeCAD import Base
543
544
# Guard for GUI availability
545
if FreeCAD.GuiUp:
546
import FreeCADGui
547
from PySide2 import QtWidgets, QtCore
548
549
def main():
550
doc = FreeCAD.ActiveDocument
551
if doc is None:
552
FreeCAD.Console.PrintError("No active document\n")
553
return
554
555
if FreeCAD.GuiUp:
556
sel = FreeCADGui.Selection.getSelection()
557
if not sel:
558
FreeCAD.Console.PrintWarning("No objects selected\n")
559
560
# ... macro logic ...
561
562
doc.recompute()
563
FreeCAD.Console.PrintMessage("Macro completed\n")
564
565
if __name__ == "__main__":
566
main()
567
```
568
569
### Selection Handling
570
571
```python
572
# Get selected objects
573
sel = FreeCADGui.Selection.getSelection() # List of objects
574
sel_ex = FreeCADGui.Selection.getSelectionEx() # Extended (sub-elements)
575
576
for selobj in sel_ex:
577
obj = selobj.Object
578
for sub in selobj.SubElementNames:
579
print(f"{obj.Name}.{sub}")
580
shape = obj.getSubObject(sub) # Get sub-shape
581
582
# Select programmatically
583
FreeCADGui.Selection.addSelection(doc.MyBox)
584
FreeCADGui.Selection.addSelection(doc.MyBox, "Face1")
585
FreeCADGui.Selection.clearSelection()
586
```
587
588
### Console Output
589
590
```python
591
FreeCAD.Console.PrintMessage("Info message\n")
592
FreeCAD.Console.PrintWarning("Warning message\n")
593
FreeCAD.Console.PrintError("Error message\n")
594
FreeCAD.Console.PrintLog("Debug/log message\n")
595
```
596
597
## Common Patterns
598
599
### Parametric Pad from Sketch
600
601
```python
602
doc = FreeCAD.ActiveDocument
603
604
# Create sketch
605
sketch = doc.addObject("Sketcher::SketchObject", "Sketch")
606
sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(0,0,0), FreeCAD.Vector(10,0,0)))
607
sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(10,0,0), FreeCAD.Vector(10,10,0)))
608
sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(10,10,0), FreeCAD.Vector(0,10,0)))
609
sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(0,10,0), FreeCAD.Vector(0,0,0)))
610
# Close with coincident constraints
611
for i in range(3):
612
sketch.addConstraint(Sketcher.Constraint("Coincident", i, 2, i+1, 1))
613
sketch.addConstraint(Sketcher.Constraint("Coincident", 3, 2, 0, 1))
614
615
# Pad (PartDesign)
616
pad = doc.addObject("PartDesign::Pad", "Pad")
617
pad.Profile = sketch
618
pad.Length = 5.0
619
sketch.Visibility = False
620
doc.recompute()
621
```
622
623
### Export Shapes
624
625
```python
626
# STEP export
627
Part.export([doc.MyBox], "/path/to/output.step")
628
629
# STL export (mesh)
630
import Mesh
631
Mesh.export([doc.MyBox], "/path/to/output.stl")
632
633
# IGES export
634
Part.export([doc.MyBox], "/path/to/output.iges")
635
636
# Multiple formats via importlib
637
import importlib
638
importlib.import_module("importOBJ").export([doc.MyBox], "/path/to/output.obj")
639
```
640
641
### Units and Quantities
642
643
```python
644
# FreeCAD uses mm internally
645
q = FreeCAD.Units.Quantity("10 mm")
646
q_inch = FreeCAD.Units.Quantity("1 in")
647
print(q_inch.getValueAs("mm")) # 25.4
648
649
# Parse user input with units
650
q = FreeCAD.Units.parseQuantity("2.5 in")
651
value_mm = float(q) # Value in mm (internal unit)
652
```
653
654
## Compensation Rules (Quasi-Coder Integration)
655
656
When interpreting shorthand or quasi-code for FreeCAD scripts:
657
658
1. **Terminology mapping**: "box" → `Part.makeBox()`, "cylinder" → `Part.makeCylinder()`, "sphere" → `Part.makeSphere()`, "merge/combine/join" → `.fuse()`, "subtract/cut/remove" → `.cut()`, "intersect" → `.common()`, "round edges/fillet" → `.makeFillet()`, "bevel/chamfer" → `.makeChamfer()`
659
2. **Implicit document**: If no document handling is mentioned, wrap in standard `doc = FreeCAD.ActiveDocument or FreeCAD.newDocument()`
660
3. **Units assumption**: Default to millimeters unless stated otherwise
661
4. **Recompute**: Always call `doc.recompute()` after modifications
662
5. **GUI guard**: Wrap GUI-dependent code in `if FreeCAD.GuiUp:` when the script may run headless
663
6. **Part.show()**: Use `Part.show(shape, "Name")` for quick display, or `doc.addObject("Part::Feature", "Name")` for named persistent objects
664
665
## References
666
667
### Primary Links
668
669
- [Writing Python code](https://wiki.freecad.org/Manual:A_gentle_introduction#Writing_Python_code)
670
- [Manipulating FreeCAD objects](https://wiki.freecad.org/Manual:A_gentle_introduction#Manipulating_FreeCAD_objects)
671
- [Vectors and Placements](https://wiki.freecad.org/Manual:A_gentle_introduction#Vectors_and_Placements)
672
- [Creating and manipulating geometry](https://wiki.freecad.org/Manual:Creating_and_manipulating_geometry)
673
- [Creating parametric objects](https://wiki.freecad.org/Manual:Creating_parametric_objects)
674
- [Creating interface tools](https://wiki.freecad.org/Manual:Creating_interface_tools)
675
- [Python](https://en.wikipedia.org/wiki/Python_%28programming_language%29)
676
- [Introduction to Python](https://wiki.freecad.org/Introduction_to_Python)
677
- [Python scripting tutorial](https://wiki.freecad.org/Python_scripting_tutorial)
678
- [FreeCAD scripting basics](https://wiki.freecad.org/FreeCAD_Scripting_Basics)
679
- [Gui Command](https://wiki.freecad.org/Gui_Command)
680
681
### Bundled Reference Documents
682
683
See the [references/](references/) directory for topic-organized guides:
684
685
1. [scripting-fundamentals.md](references/scripting-fundamentals.md) — Core scripting, document model, console
686
2. [geometry-and-shapes.md](references/geometry-and-shapes.md) — Part, Mesh, Sketcher, topology
687
3. [parametric-objects.md](references/parametric-objects.md) — FeaturePython, properties, scripted objects
688
4. [gui-and-interface.md](references/gui-and-interface.md) — PySide, dialogs, task panels, Coin3D
689
5. [workbenches-and-advanced.md](references/workbenches-and-advanced.md) — Workbenches, macros, FEM, Path, recipes
690

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…