Assembly: Insert new part (#17922)

* Assembly: Joint Object : encapsulate the joint creation widget such that the task can be subclassed and ui customized by other commands.

* Assembly: Insert New Part

* Update src/Mod/Assembly/CommandInsertNewPart.py

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
This commit is contained in:
PaddleStroke
2024-12-02 18:34:02 +01:00
committed by GitHub
parent 17b53ce42e
commit 5d937a4f84
6 changed files with 400 additions and 150 deletions

View File

@@ -1223,6 +1223,24 @@ def addVertexToReference(ref, vertex_name):
return ref
def createPart(partName, doc):
if not doc:
raise ValueError("No active document to add a part to.")
part = doc.addObject("App::Part", partName)
body = part.newObject("PartDesign::Body", "Body")
# Gui.ActiveDocument.ActiveView.setActiveObject('pdbody', body)
sketch = body.newObject("Sketcher::SketchObject", "Sketch")
sketch.MapMode = "FlatFace"
sketch.AttachmentSupport = [(body.Origin.OriginFeatures[3], "")] # XY_Plane
# add a circle as a base shape for visualisation
sketch.addGeometry(Part.Circle(App.Vector(0, 0), App.Vector(0, 0, 1), 5), False)
doc.recompute()
return part, body
def getLinkGroup(linkElement):
if linkElement.TypeId == "App::LinkElement":
for obj in linkElement.InList: