Macro generating AdditiveLoft

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
edi
Posts: 482
Joined: Fri Jan 17, 2020 1:32 pm

Macro generating AdditiveLoft

Post by edi »

I will present a short macro generating an AdditiveLoft.

Code: Select all

import FreeCAD as App
def name(Sketch):
	return Sketch.Name
Sketches = Gui.Selection.getCompleteSelection()
Sketches.sort(key=name)
App.activeDocument().Body.newObject("PartDesign::AdditiveLoft","AdditiveLoft")
Loft = App.ActiveDocument.Objects[-1]
Loft.Profile = [Sketches.pop(0),[]]
Loft.Sections = Sketches
App.ActiveDocument.recompute()
Usage:
1. Create some sketches, containing regular sections for an AdditiveLoft.
2. Select all these sketches in the model tree.
3. Start the macro.
An AdditiveLoft using the sketches will be generated.
The order of the sketches is the same as in the model tree.
The macro will save much time if you have many (automatic generated) sketches.
Attention: The macro does not check anything. Please select only sketches (no other elements) containing regalar sections.
Post Reply