Assembly: Create SoSwitchMarker.py to externalize the coin stuff that draw the joint's markers(JCS)

This commit is contained in:
PaddleStroke
2024-09-10 16:54:40 +02:00
parent fe5c883e4c
commit 62575f2d63
4 changed files with 238 additions and 153 deletions

View File

@@ -356,7 +356,7 @@ def extract_type_and_number(element_name):
return None, None
def findElementClosestVertex(assembly, ref, mousePos):
def findElementClosestVertex(ref, mousePos):
element_name = getElementName(ref[1][0])
if element_name == "":
return ""
@@ -767,6 +767,21 @@ def openEditingPlacementDialog(obj, propName):
dialog.exec_()
def setPickableState(obj, state: bool):
vobj = obj.ViewObject
if hasattr(vobj, "Proxy"):
proxy = vobj.Proxy
if hasattr(proxy, "setPickableState"):
proxy.setPickableState(state)
def setJointsPickableState(doc, state: bool):
"""Make all joints in document selectable (True) or unselectable (False) in 3D view"""
for obj in doc.Objects:
if obj.TypeId == "App::FeaturePython" and hasattr(obj, "JointType"):
setPickableState(obj, state)
def applyOffsetToPlacement(plc, offset):
plc.Base = plc.Base + plc.Rotation.multVec(offset)
return plc
@@ -799,6 +814,23 @@ def arePlacementZParallel(plc1, plc2):
return zAxis1.cross(zAxis2).Length < 1e-06
def removeTNPFromSubname(doc_name, obj_name, sub_name):
rootObj = App.getDocument(doc_name).getObject(obj_name)
resolved = rootObj.resolveSubElement(sub_name)
element_name_TNP = resolved[1]
element_name = resolved[2]
# Preprocess the sub_name to remove the TNP string
# We do this because after we need to add the vertex_name as well.
# And the names will be resolved anyway after.
if len(element_name_TNP.split(".")) == 2:
names = sub_name.split(".")
names.pop(-2) # remove the TNP string
sub_name = ".".join(names)
return sub_name
"""
So here we want to find a placement that corresponds to a local coordinate system that would be placed at the selected vertex.
- obj is usually a App::Link to a PartDesign::Body, or primitive, fasteners. But can also be directly the object.1