Skip to content

Commit

Permalink
to squash
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddleStroke authored Mar 7, 2025
1 parent 773fd1d commit 784d660
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Mod/Assembly/UtilsAssembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def getObject(ref):
return obj

elif obj.TypeId == "PartDesign::Body":
return process_body(obj, names, i)
return process_body(obj, obj, names, i)

elif obj.isDerivedFrom("Part::Feature"):
# primitive, fastener, gear ...
Expand All @@ -186,7 +186,7 @@ def getObject(ref):
elif isLink(obj):
linked_obj = obj.getLinkedObject()
if linked_obj.TypeId == "PartDesign::Body":
return process_body(linked_obj, names, i)
return process_body(linked_obj, obj, names, i)
elif linked_obj.isDerivedFrom("Part::Feature"):
return obj
else:
Expand All @@ -196,29 +196,27 @@ def getObject(ref):
return None


def process_body(body, names, i):
def process_body(body, returnObj, names, i):
# If there's a next name, it could either be elementName, in which case we can return the Body.
# But it could be a subobject like Sketch or datums.
if i + 1 < len(names):
name = names[i + 1]
obj2 = None
for obji in body.OutList:
if obji.Name == name:
if obji.Name == names[i + 1]:
obj2 = obji
break
if obj2 and isBodySubObject(obj2):
# obj2 can be a LCS or a Sketch. But it can also be a LCS's Axis or plane.
if i + 2 < len(names):
name = names[i + 2]
obj3 = None
for obji in obj2.OutList:
if obji.Name == name:
if obji.Name == names[i + 2]:
obj3 = obji
break
if obj3 and isBodySubObject(obj3):
return obj3
return obj2
return body
return returnObj


def isBodySubObject(obj):
Expand Down

0 comments on commit 784d660

Please sign in to comment.