Assembly: Fix selection during joint edition (#25687)
This commit is contained in:
@@ -1839,8 +1839,11 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
self.refs.append(ref1)
|
||||
self.refs.append(ref2)
|
||||
|
||||
Gui.Selection.addSelection(ref1[0].Document.Name, ref1[0].Name, ref1[1][0])
|
||||
Gui.Selection.addSelection(ref2[0].Document.Name, ref2[0].Name, ref2[1][0])
|
||||
sub1 = UtilsAssembly.addTipNameToSub(ref1)
|
||||
sub2 = UtilsAssembly.addTipNameToSub(ref2)
|
||||
|
||||
Gui.Selection.addSelection(ref1[0].Document.Name, ref1[0].Name, sub1)
|
||||
Gui.Selection.addSelection(ref2[0].Document.Name, ref2[0].Name, sub2)
|
||||
|
||||
self.jForm.angleSpinbox.setProperty("rawValue", self.joint.Angle.Value)
|
||||
self.jForm.distanceSpinbox.setProperty("rawValue", self.joint.Distance.Value)
|
||||
|
||||
@@ -259,6 +259,46 @@ def fixBodyExtraFeatureInSub(doc_name, sub_name):
|
||||
return new_sub_name
|
||||
|
||||
|
||||
def addTipNameToSub(ref):
|
||||
"""
|
||||
Checks if the object referenced is a PartDesign::Body (or a Link to one).
|
||||
If so, it injects the Tip Name before the element name in the sub string.
|
||||
This is required for Gui.Selection to correctly highlight the geometry in the 3D View.
|
||||
Example: 'Body.Face1' -> 'Body.Pad.Face1'
|
||||
Example: 'Link.Face1' -> 'Link.Pad.Face1'
|
||||
"""
|
||||
if not isRefValid(ref, 1):
|
||||
return ""
|
||||
|
||||
sub = ref[1][0]
|
||||
|
||||
# Resolve the actual object being pointed to
|
||||
obj = getObject(ref)
|
||||
|
||||
target_body = None
|
||||
|
||||
if obj:
|
||||
if obj.TypeId == "PartDesign::Body":
|
||||
target_body = obj
|
||||
elif isLink(obj):
|
||||
linked = obj.getLinkedObject()
|
||||
if linked and linked.TypeId == "PartDesign::Body":
|
||||
target_body = linked
|
||||
|
||||
if target_body and target_body.Tip:
|
||||
split_sub = sub.split(".")
|
||||
if len(split_sub) > 0:
|
||||
element = split_sub.pop()
|
||||
if not element: # Empty element name means the whole body is selected
|
||||
return sub
|
||||
|
||||
split_sub.append(target_body.Tip.Name)
|
||||
split_sub.append(element)
|
||||
return ".".join(split_sub)
|
||||
|
||||
return sub
|
||||
|
||||
|
||||
# Deprecated. Kept for migrationScript.
|
||||
def getObjectInPart(objName, part):
|
||||
if part is None:
|
||||
|
||||
Reference in New Issue
Block a user