Browse Source

fixed bugs with variant links

pull/1/head
Youen 2 years ago
parent
commit
9cf0944570
  1. 28
      ahb_techdraw_extensions.py

28
ahb_techdraw_extensions.py

@ -110,11 +110,11 @@ class TechDrawExtensions:
parts_to_paint.append(part)
# repaint parts that are new in this step (thick line)
prev_view = None
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList:
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView)
if prev_view is not None:
for part in view.XSource:
if part not in prev_view.XSource and part not in parts_to_paint:
if (prev_view is None or part not in prev_view.XSource) and part not in parts_to_paint:
parts_to_paint.append(part)
# make sure the list is not empty, so that we reset all lines
@ -125,7 +125,7 @@ class TechDrawExtensions:
default_line_thickness = 0.05
line_thickness = default_line_thickness
default_color = (0.65, 0.65, 0.65)
default_color = (0.5, 0.5, 0.5)
color = default_color
if part is not None:
@ -133,10 +133,7 @@ class TechDrawExtensions:
center = self.computePartCenter(view, part)
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList:
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView)
if prev_view is not None:
if not part in prev_view.XSource:
if self.isNewPartInView(view, part):
line_thickness = 0.2
color = (0, 0, 0)
@ -345,8 +342,15 @@ class TechDrawExtensions:
balloon.BubbleShape = 'Inspection'
balloon.EndTypeScale = 4
def getPartDisplayName(self, obj):
def isPartLink(self, obj):
if obj.TypeId == 'App::Link':
return True
if obj.TypeId == 'Part::FeaturePython' and hasattr(obj, 'LinkedObject'): # variant link
return True
return False
def getPartDisplayName(self, obj):
if self.isPartLink(obj):
linked_obj = obj.LinkedObject
if 'Assembly_handbook_PartDisplayName' in linked_obj.PropertiesList:
return linked_obj.Assembly_handbook_PartDisplayName
@ -356,9 +360,13 @@ class TechDrawExtensions:
def isNewPartInView(self, view, obj):
doc = view.Document
prev_view = None
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList:
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView)
if prev_view is not None:
if prev_view is None:
return True
else:
if not obj in prev_view.XSource:
return True
return False
@ -421,7 +429,7 @@ class TechDrawExtensions:
objectCenterWorld = partLink.LinkPlacement.Matrix.multiply(partLink.LinkedObject.Shape.CenterOfGravity)
elif obj.TypeId == 'Part::FeaturePython' and hasattr(obj, 'LinkedObject'): # variant link
partLink = obj
objectCenterWorld = partLink.LinkedObject.Shape.CenterOfGravity
objectCenterWorld = partLink.Placement.Matrix.multiply(partLink.LinkedObject.Shape.CenterOfGravity)
else:
objectCenterWorld = obj.Shape.CenterOfGravity

Loading…
Cancel
Save