Browse Source

fixed bugs with variant links

pull/1/head
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) parts_to_paint.append(part)
# repaint parts that are new in this step (thick line) # repaint parts that are new in this step (thick line)
prev_view = None
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList: if 'Assembly_handbook_PreviousStepView' in view.PropertiesList:
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView) prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView)
if prev_view is not None: for part in view.XSource:
for part in view.XSource: if (prev_view is None or part not in prev_view.XSource) and part not in parts_to_paint:
if part not in prev_view.XSource and part not in parts_to_paint: parts_to_paint.append(part)
parts_to_paint.append(part)
# make sure the list is not empty, so that we reset all lines # make sure the list is not empty, so that we reset all lines
if len(parts_to_paint) == 0: if len(parts_to_paint) == 0:
@ -125,7 +125,7 @@ class TechDrawExtensions:
default_line_thickness = 0.05 default_line_thickness = 0.05
line_thickness = default_line_thickness line_thickness = default_line_thickness
default_color = (0.65, 0.65, 0.65) default_color = (0.5, 0.5, 0.5)
color = default_color color = default_color
if part is not None: if part is not None:
@ -133,12 +133,9 @@ class TechDrawExtensions:
center = self.computePartCenter(view, part) center = self.computePartCenter(view, part)
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList: if self.isNewPartInView(view, part):
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView) line_thickness = 0.2
if prev_view is not None: color = (0, 0, 0)
if not part in prev_view.XSource:
line_thickness = 0.2
color = (0, 0, 0)
if self.enable_selected_part_highlight: if self.enable_selected_part_highlight:
for balloon in selected_balloons: for balloon in selected_balloons:
@ -344,9 +341,16 @@ class TechDrawExtensions:
balloon.ViewObject.Fontsize = 4 balloon.ViewObject.Fontsize = 4
balloon.BubbleShape = 'Inspection' balloon.BubbleShape = 'Inspection'
balloon.EndTypeScale = 4 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): def getPartDisplayName(self, obj):
if obj.TypeId == 'App::Link': if self.isPartLink(obj):
linked_obj = obj.LinkedObject linked_obj = obj.LinkedObject
if 'Assembly_handbook_PartDisplayName' in linked_obj.PropertiesList: if 'Assembly_handbook_PartDisplayName' in linked_obj.PropertiesList:
return linked_obj.Assembly_handbook_PartDisplayName return linked_obj.Assembly_handbook_PartDisplayName
@ -356,12 +360,16 @@ class TechDrawExtensions:
def isNewPartInView(self, view, obj): def isNewPartInView(self, view, obj):
doc = view.Document doc = view.Document
prev_view = None
if 'Assembly_handbook_PreviousStepView' in view.PropertiesList: if 'Assembly_handbook_PreviousStepView' in view.PropertiesList:
prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView) prev_view = doc.getObject(view.Assembly_handbook_PreviousStepView)
if prev_view is not None:
if not obj in prev_view.XSource: if prev_view is None:
return True return True
return False else:
if not obj in prev_view.XSource:
return True
return False
def getActivePage(self): def getActivePage(self):
activeView = Gui.activeView() activeView = Gui.activeView()
@ -421,7 +429,7 @@ class TechDrawExtensions:
objectCenterWorld = partLink.LinkPlacement.Matrix.multiply(partLink.LinkedObject.Shape.CenterOfGravity) objectCenterWorld = partLink.LinkPlacement.Matrix.multiply(partLink.LinkedObject.Shape.CenterOfGravity)
elif obj.TypeId == 'Part::FeaturePython' and hasattr(obj, 'LinkedObject'): # variant link elif obj.TypeId == 'Part::FeaturePython' and hasattr(obj, 'LinkedObject'): # variant link
partLink = obj partLink = obj
objectCenterWorld = partLink.LinkedObject.Shape.CenterOfGravity objectCenterWorld = partLink.Placement.Matrix.multiply(partLink.LinkedObject.Shape.CenterOfGravity)
else: else:
objectCenterWorld = obj.Shape.CenterOfGravity objectCenterWorld = obj.Shape.CenterOfGravity

Loading…
Cancel
Save