Browse Source

fixed bugs with variant links

master
Youen 2 years ago
parent
commit
9cf0944570
  1. 42
      ahb_techdraw_extensions.py

42
ahb_techdraw_extensions.py

@ -110,12 +110,12 @@ 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:
parts_to_paint.append(part)
for part in view.XSource:
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
if len(parts_to_paint) == 0:
@ -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,12 +133,9 @@ 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:
line_thickness = 0.2
color = (0, 0, 0)
if self.isNewPartInView(view, part):
line_thickness = 0.2
color = (0, 0, 0)
if self.enable_selected_part_highlight:
for balloon in selected_balloons:
@ -344,9 +341,16 @@ class TechDrawExtensions:
balloon.ViewObject.Fontsize = 4
balloon.BubbleShape = 'Inspection'
balloon.EndTypeScale = 4
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 obj.TypeId == 'App::Link':
if self.isPartLink(obj):
linked_obj = obj.LinkedObject
if 'Assembly_handbook_PartDisplayName' in linked_obj.PropertiesList:
return linked_obj.Assembly_handbook_PartDisplayName
@ -356,12 +360,16 @@ 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 not obj in prev_view.XSource:
return True
return False
if prev_view is None:
return True
else:
if not obj in prev_view.XSource:
return True
return False
def getActivePage(self):
activeView = Gui.activeView()
@ -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