Workaround for FreeCAD bugs 2296, 2902

https://www.freecadweb.org/tracker/view.php?id=2996
https://www.freecadweb.org/tracker/view.php?id=2902

This change is to be removed in far future.
Note: mostly untested. Something might have been broken.
This commit is contained in:
DeepSOIC 2017-04-02 23:08:08 +03:00
parent a4c39da369
commit 05641559f9
22 changed files with 132 additions and 114 deletions

View File

@ -81,12 +81,12 @@ class _CompoundFilter:
def execute(self,obj):
#validity check
if isObjectLattice(obj.Base):
if isObjectLattice(screen(obj.Base)):
import lattice2Executer
lattice2Executer.warning(obj,"A generic shape is expected, but an array of placements was supplied. It will be treated as a generic shape.")
rst = [] #variable to receive the final list of shapes
shps = obj.Base.Shape.childShapes()
shps = screen(obj.Base).Shape.childShapes()
if obj.FilterType == 'bypass':
rst = shps
elif obj.FilterType == 'specific items':
@ -116,7 +116,7 @@ class _CompoundFilter:
if not flags[i]:
rst.append(shps[i])
elif obj.FilterType == 'collision-pass':
stencil = obj.Stencil.Shape
stencil = screen(obj.Stencil).Shape
for s in shps:
d = s.distToShape(stencil)
if bool(d[0] < DistConfusion) ^ bool(obj.Invert):
@ -155,8 +155,8 @@ class _CompoundFilter:
if len(rst) == 0:
scale = 1.0
if not obj.Base.Shape.isNull():
scale = obj.Base.Shape.BoundBox.DiagonalLength/math.sqrt(3)/math.sqrt(len(shps))
if not screen(obj.Base).Shape.isNull():
scale = screen(obj.Base).Shape.BoundBox.DiagonalLength/math.sqrt(3)/math.sqrt(len(shps))
if scale < DistConfusion * 100:
scale = 1.0
obj.Shape = markers.getNullShapeShape(scale)
@ -202,7 +202,7 @@ class _ViewProviderCompoundFilter:
return None
def claimChildren(self):
children = [self.Object.Base]
children = [screen(self.Object.Base)]
if self.Object.Stencil:
children.append(self.Object.Stencil)
return children
@ -210,7 +210,7 @@ class _ViewProviderCompoundFilter:
def onDelete(self, feature, subelements): # subelements is a tuple of strings
if not self.ViewObject.DontUnhideOnDelete:
try:
self.Object.Base.ViewObject.show()
screen(self.Object.Base).ViewObject.show()
if self.Object.Stencil:
self.Object.Stencil.ViewObject.show()
except Exception as err:

View File

@ -51,7 +51,7 @@ class _FuseCompound:
def execute(self,obj):
rst = None
shps = obj.Base.Shape.childShapes()
shps = screen(obj.Base).Shape.childShapes()
if len(shps) > 1:
rst = shps[0].multiFuse(shps[1:])
if obj.Refine:
@ -89,11 +89,11 @@ class _ViewProviderFuseCompound:
return None
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
def onDelete(self, feature, subelements): # subelements is a tuple of strings
try:
self.Object.Base.ViewObject.show()
screen(self.Object.Base).ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True

View File

@ -73,11 +73,11 @@ class LatticeArrayFilter(lattice2BaseFeature.LatticeFeature):
def derivedExecute(self,obj):
#validity check
if not lattice2BaseFeature.isObjectLattice(obj.Base):
if not lattice2BaseFeature.isObjectLattice(screen(obj.Base)):
lattice2Executer.warning(obj,"A lattice object is expected as Base, but a generic shape was provided. It will be treated as a lattice object; results may be unexpected.")
output = [] #variable to receive the final list of placements
leaves = LCE.AllLeaves(obj.Base.Shape)
leaves = LCE.AllLeaves(screen(obj.Base).Shape)
input = [leaf.Placement for leaf in leaves]
if obj.FilterType == 'bypass':
output = input
@ -107,7 +107,7 @@ class LatticeArrayFilter(lattice2BaseFeature.LatticeFeature):
if not flags[i]:
output.append(input[i])
elif obj.FilterType == 'collision-pass':
stencil = obj.Stencil.Shape
stencil = screen(obj.Stencil).Shape
for plm in input:
pnt = Part.Vertex(plm.Base)
d = pnt.distToShape(stencil)
@ -118,7 +118,7 @@ class LatticeArrayFilter(lattice2BaseFeature.LatticeFeature):
for i in xrange(0,len(input)):
if obj.FilterType == 'window-distance':
pnt = Part.Vertex(input[i].Base)
vals[i] = pnt.distToShape(obj.Stencil.Shape)[0]
vals[i] = pnt.distToShape(screen(obj.Stencil).Shape)[0]
valFrom = obj.WindowFrom
valTo = obj.WindowTo
@ -139,9 +139,9 @@ class ViewProviderArrayFilter(lattice2BaseFeature.ViewProviderLatticeFeature):
return getIconPath("Lattice2_ArrayFilter.svg")
def claimChildren(self):
children = [self.Object.Base]
if self.Object.Stencil:
children.append(self.Object.Stencil)
children = [screen(self.Object.Base)]
if screen(self.Object.Stencil):
children.append(screen(self.Object.Stencil))
return children
def makeItemListFromSelection(sel, bMakeString = True):

View File

@ -68,10 +68,10 @@ class LatticeArrayFromShape(lattice2BaseFeature.LatticeFeature):
def derivedExecute(self,obj):
# cache stuff
if lattice2BaseFeature.isObjectLattice(obj.ShapeLink):
if lattice2BaseFeature.isObjectLattice(screen(obj.ShapeLink)):
lattice2Executer.warning(obj,"ShapeLink points to a placement/array of placements. The placement/array will be reinterpreted as a generic shape; the results may be unexpected.")
base = obj.ShapeLink.Shape
base = screen(obj.ShapeLink).Shape
if obj.CompoundTraversal == "Use as a whole":
baseChildren = [base]
else:

View File

@ -100,8 +100,8 @@ class AttachedPlacementSubsequence(lattice2BaseFeature.LatticeFeature):
obj.CycleMode = ['Open','Periodic']
def derivedExecute(self,obj):
attacher = Part.AttachEngine(obj.Base.AttacherType)
attacher.readParametersFromFeature(obj.Base)
attacher = Part.AttachEngine(screen(obj.Base).AttacherType)
attacher.readParametersFromFeature(screen(obj.Base))
i_filt_str = obj.RefIndexFilter
ifilt = None if i_filt_str == "" else [i for i in range(len(i_filt_str)) if int(i_filt_str[i]) != 0]
sublinks = Subsequencer.Subsequence_auto(attacher.References,
@ -110,7 +110,7 @@ class AttachedPlacementSubsequence(lattice2BaseFeature.LatticeFeature):
plms = []
for lnkval in sublinks:
attacher.References = lnkval
plms.append(attacher.calculateAttachedPlacement(obj.Base.Placement))
plms.append(attacher.calculateAttachedPlacement(screen(obj.Base).Placement))
return plms
class ViewProviderAttachedPlacementSubsequence(lattice2BaseFeature.ViewProviderLatticeFeature):
@ -118,7 +118,7 @@ class ViewProviderAttachedPlacementSubsequence(lattice2BaseFeature.ViewProviderL
return getIconPath('Lattice2_AttachedPlacementSubsequence.svg')
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
# -------------------------- /document object --------------------------------------------------

View File

@ -138,7 +138,7 @@ class _BoundBox:
def execute(self,obj):
base = obj.ShapeLink.Shape
base = screen(obj.ShapeLink).Shape
if obj.CompoundTraversal == "Use as a whole":
baseChildren = [base]
else:
@ -155,11 +155,11 @@ class _BoundBox:
if obj.OrientMode == "global":
orients = [App.Placement()]*N
elif obj.OrientMode == "local of compound":
orients = [obj.ShapeLink.Placement]*N
orients = [screen(obj.ShapeLink).Placement]*N
elif obj.OrientMode == "local of child":
orients = [child.Placement for child in baseChildren]
elif obj.OrientMode == "use OrientLink":
orients = LBF.getPlacementsList(obj.OrientLink, context= obj)
orients = LBF.getPlacementsList(screen(obj.OrientLink), context= obj)
if len(orients) == N:
pass
elif len(orients)>N:

View File

@ -85,4 +85,19 @@ def deselect(sel):
DistConfusion = 1e-7
ParaConfusion = 1e-8
import lattice2_rc
import lattice2_rc
def screen(feature):
"""screen(feature): protects link properties from being overwritten.
This is to be used as workaround for a bug where modifying an object accessed through
a link property of another object results in the latter being touched.
returns: feature"""
if not hasattr(feature,"isDerivedFrom"):
return feature
if not feature.isDerivedFrom("App::DocumentObject"):
return feature
if feature.Document is None:
return feature
feature = getattr(feature.Document, feature.Name)
return feature

View File

@ -74,7 +74,7 @@ class _latticeDowngrade:
def execute(self,obj):
rst = [] #variable to receive the final list of shapes
shp = obj.Base.Shape
shp = screen(obj.Base).Shape
if obj.Mode == 'bypass':
rst = [shp]
elif obj.Mode == 'Leaves':
@ -124,8 +124,8 @@ class _latticeDowngrade:
if len(rst) == 0:
scale = 1.0
if not obj.Base.Shape.isNull():
scale = obj.Base.Shape.BoundBox.DiagonalLength/math.sqrt(3)
if not screen(obj.Base).Shape.isNull():
scale = screen(obj.Base).Shape.BoundBox.DiagonalLength/math.sqrt(3)
if scale < DistConfusion * 100:
scale = 1.0
obj.Shape = markers.getNullShapeShape(scale)
@ -162,11 +162,11 @@ class _ViewProviderLatticeDowngrade:
return None
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
def onDelete(self, feature, subelements): # subelements is a tuple of strings
try:
self.Object.Base.ViewObject.show()
screen(self.Object.Base).ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True

View File

@ -60,8 +60,8 @@ class LatticeInvert(lattice2BaseFeature.LatticeFeature):
def derivedExecute(self,obj):
# cache stuff
base = obj.Base.Shape
if not lattice2BaseFeature.isObjectLattice(obj.Base):
base = screen(obj.Base).Shape
if not lattice2BaseFeature.isObjectLattice(screen(obj.Base)):
lattice2Executer.warning(obj, "Base is not a lattice, but lattice is expected. Results may be unexpected.\n")
baseChildren = LCE.AllLeaves(base)
@ -107,7 +107,7 @@ class ViewProviderInvert(lattice2BaseFeature.ViewProviderLatticeFeature):
return getIconPath('Lattice2_Invert.svg')
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
# -------------------------- /document object --------------------------------------------------

View File

@ -83,11 +83,12 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
self.assureProperties(obj)
def updateReadonlyness(self, obj):
obj.setEditorMode("Dir", 1 if (obj.Link and obj.DirIsDriven) else 0)
obj.setEditorMode("Point", 1 if (obj.Link and obj.PointIsDriven) else 0)
obj.setEditorMode("DirIsDriven", 0 if obj.Link else 1)
obj.setEditorMode("PointIsDriven", 0 if obj.Link else 1)
obj.setEditorMode("DrivenProperty", 0 if obj.Link else 1)
link = screen(obj.Link)
obj.setEditorMode("Dir", 1 if (link and obj.DirIsDriven) else 0)
obj.setEditorMode("Point", 1 if (link and obj.PointIsDriven) else 0)
obj.setEditorMode("DirIsDriven", 0 if link else 1)
obj.setEditorMode("PointIsDriven", 0 if link else 1)
obj.setEditorMode("DrivenProperty", 0 if link else 1)
self.generator.updateReadonlyness()
@ -103,7 +104,7 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
self.updateReadonlyness(obj)
def assureProperties(self, selfobj):
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(selfobj.Link, selfobj.LinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(screen(selfobj.Link), selfobj.LinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
def derivedExecute(self,obj):
self.assureGenerator(obj)
@ -111,15 +112,15 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
self.updateReadonlyness(obj)
# Apply links
if obj.Link:
if lattice2BaseFeature.isObjectLattice(obj.Link):
if screen(obj.Link):
if lattice2BaseFeature.isObjectLattice(screen(obj.Link)):
lattice2Executer.warning(obj,"For polar array, axis link is expected to be a regular shape. Lattice objct was supplied instead, it's going to be treated as a generic shape.")
#resolve the link
if len(obj.LinkSubelement) > 0:
linkedShape = obj.Link.Shape.getElement(obj.LinkSubelement)
linkedShape = screen(obj.Link).Shape.getElement(obj.LinkSubelement)
else:
linkedShape = obj.Link.Shape
linkedShape = screen(obj.Link).Shape
#Type check
if linkedShape.ShapeType != 'Edge':
@ -155,7 +156,7 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
#Apply reversal
if obj.Reverse:
obj.Dir = obj.Dir*(-1.0)
if not(obj.DirIsDriven and obj.Link):
if not(obj.DirIsDriven and screen(obj.Link)):
obj.Reverse = False
# precompute orientation

View File

@ -184,8 +184,8 @@ class LatticeParaSeries(lattice2BaseFeature.LatticeFeature):
if len(values) == 0:
scale = 1.0
try:
if not selfobj.Object.Shape.isNull():
scale = selfobj.Object.Shape.BoundBox.DiagonalLength/math.sqrt(3)
if not screen(selfobj.Object).Shape.isNull():
scale = screen(selfobj.Object).Shape.BoundBox.DiagonalLength/math.sqrt(3)
except Exception:
pass
if scale < DistConfusion * 100:
@ -204,7 +204,7 @@ class LatticeParaSeries(lattice2BaseFeature.LatticeFeature):
doc2 = App.newDocument()
object_in_doc2 = None # define the variable, to prevent del() in finally block from raising another error
try:
doc2.copyObject(selfobj.Object, True)
doc2.copyObject(screen(selfobj.Object), True)
#if there are nested paraseries in the dependencies, make sure to enable them
for objd2 in doc2.Objects:
@ -215,7 +215,7 @@ class LatticeParaSeries(lattice2BaseFeature.LatticeFeature):
except exception:
lattice2Executer.warning(selfobj,"Failed to enable recomputing of "+objd2.Name)
object_in_doc2 = doc2.getObject(selfobj.Object.Name)
object_in_doc2 = doc2.getObject(screen(selfobj.Object).Name)
if bGui:
progress.setValue(1)
output_shapes = []
@ -234,8 +234,8 @@ class LatticeParaSeries(lattice2BaseFeature.LatticeFeature):
scale = 1.0
try:
if not selfobj.Object.Shape.isNull():
scale = selfobj.Object.Shape.BoundBox.DiagonalLength/math.sqrt(3)
if not screen(selfobj.Object).Shape.isNull():
scale = screen(selfobj.Object).Shape.BoundBox.DiagonalLength/math.sqrt(3)
except Exception:
pass
if scale < DistConfusion * 100:
@ -263,7 +263,7 @@ class LatticeParaSeries(lattice2BaseFeature.LatticeFeature):
selfobj.Shape = Part.makeCompound(output_shapes)
output_is_lattice = lattice2BaseFeature.isObjectLattice(selfobj.Object)
output_is_lattice = lattice2BaseFeature.isObjectLattice(screen(selfobj.Object))
if 'Auto' in selfobj.isLattice:
new_isLattice = 'Auto-On' if output_is_lattice else 'Auto-Off'
if selfobj.isLattice != new_isLattice:#check, to not cause onChanged without necessity (onChange messes with colors, it's better to keep user color)
@ -279,7 +279,7 @@ class ViewProviderLatticeParaSeries(lattice2BaseFeature.ViewProviderLatticeFeatu
return getIconPath("Lattice2_ParaSeries.svg")
def claimChildren(self):
return [self.Object.Object]
return [screen(self.Object.Object)]
# -------------------------- /document object --------------------------------------------------

View File

@ -89,14 +89,15 @@ class PolarArray(lattice2BaseFeature.LatticeFeature):
self.updateReadonlyness(obj)
def updateReadonlyness(self, obj):
obj.setEditorMode("AxisDir", 1 if (obj.AxisLink and obj.AxisDirIsDriven) else 0)
obj.setEditorMode("AxisPoint", 1 if (obj.AxisLink and obj.AxisPointIsDriven) else 0)
obj.setEditorMode("AxisDirIsDriven", 0 if obj.AxisLink else 1)
obj.setEditorMode("AxisPointIsDriven", 0 if obj.AxisLink else 1)
axislink = screen(obj.AxisLink)
obj.setEditorMode("AxisDir", 1 if (axislink and obj.AxisDirIsDriven) else 0)
obj.setEditorMode("AxisPoint", 1 if (axislink and obj.AxisPointIsDriven) else 0)
obj.setEditorMode("AxisDirIsDriven", 0 if axislink else 1)
obj.setEditorMode("AxisPointIsDriven", 0 if axislink else 1)
self.generator.updateReadonlyness()
def assureProperties(self, selfobj):
assureProperty(selfobj, "App::PropertyLinkSub", "AxisSubLink", sublinkFromApart(selfobj.AxisLink, selfobj.AxisLinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
assureProperty(selfobj, "App::PropertyLinkSub", "AxisSubLink", sublinkFromApart(screen(selfobj.AxisLink), selfobj.AxisLinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
def derivedExecute(self,obj):
@ -105,15 +106,15 @@ class PolarArray(lattice2BaseFeature.LatticeFeature):
self.updateReadonlyness(obj)
# Apply links
if obj.AxisLink:
if lattice2BaseFeature.isObjectLattice(obj.AxisLink):
if screen(obj.AxisLink):
if lattice2BaseFeature.isObjectLattice(screen(obj.AxisLink)):
lattice2Executer.warning(obj,"For polar array, axis link is expected to be a regular shape. Lattice objct was supplied instead, it's going to be treated as a generic shape.")
#resolve the link
if len(obj.AxisLinkSubelement) > 0:
linkedShape = obj.AxisLink.Shape.getElement(obj.AxisLinkSubelement)
linkedShape = screen(obj.AxisLink).Shape.getElement(obj.AxisLinkSubelement)
else:
linkedShape = obj.AxisLink.Shape
linkedShape = screen(obj.AxisLink).Shape
#Type check
if linkedShape.ShapeType != 'Edge':

View File

@ -75,24 +75,24 @@ class LatticePopulateChildren(lattice2BaseFeature.LatticeFeature):
self.initNewProperties(obj)
outputIsLattice = lattice2BaseFeature.isObjectLattice(obj.Object)
outputIsLattice = lattice2BaseFeature.isObjectLattice(screen(obj.Object))
if not lattice2BaseFeature.isObjectLattice(obj.Object):
if not lattice2BaseFeature.isObjectLattice(screen(obj.Object)):
if obj.ObjectTraversal == "Direct children only":
objectShapes = obj.Object.Shape.childShapes()
if obj.Object.Shape.ShapeType != "Compound":
objectShapes = screen(obj.Object).Shape.childShapes()
if screen(obj.Object).Shape.ShapeType != "Compound":
lattice2Executer.warning(obj,"shape supplied as object is not a compound. It is going to be downgraded one level down (e.g, if it is a wire, the edges are going to be enumerated as children).")
elif obj.ObjectTraversal == "Recursive":
objectShapes = LCE.AllLeaves(obj.Object.Shape)
objectShapes = LCE.AllLeaves(screen(obj.Object).Shape)
else:
raise ValueError("Traversal mode not implemented: "+obj.ObjectTraversal)
else:
objectPlms = lattice2BaseFeature.getPlacementsList(obj.Object, obj)
placements = lattice2BaseFeature.getPlacementsList(obj.PlacementsTo, obj)
objectPlms = lattice2BaseFeature.getPlacementsList(screen(obj.Object), obj)
placements = lattice2BaseFeature.getPlacementsList(screen(obj.PlacementsTo), obj)
# Precompute referencing
placements = DereferenceArray(obj, placements, obj.PlacementsFrom, obj.Referencing)
placements = DereferenceArray(obj, placements, screen(obj.PlacementsFrom), obj.Referencing)
# initialize output containers and loop variables
outputShapes = [] #output list of shapes
@ -136,7 +136,7 @@ class LatticePopulateChildren(lattice2BaseFeature.LatticeFeature):
class ViewProviderLatticePopulateChildren(lattice2BaseFeature.ViewProviderLatticeFeature):
def getIcon(self):
if lattice2BaseFeature.isObjectLattice(self.Object):
if lattice2BaseFeature.isObjectLattice(screen(self.Object)):
return getIconPath(
{"Origin":"Lattice2_PopulateChildren_Plms_Normal.svg",
"First item":"Lattice2_PopulateChildren_Plms_Array.svg",
@ -154,9 +154,9 @@ class ViewProviderLatticePopulateChildren(lattice2BaseFeature.ViewProviderLattic
)
def claimChildren(self):
children = [self.Object.Object, self.Object.PlacementsTo]
children = [screen(self.Object.Object), screen(self.Object.PlacementsTo)]
if self.Object.Referencing == "Use PlacementsFrom":
children.append(self.Object.PlacementsFrom)
children.append(screen(self.Object.PlacementsFrom))
return children
# -------------------------- /document object --------------------------------------------------

View File

@ -109,16 +109,16 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
self.assureProperties(obj)
# cache stuff
objectShape = obj.Object.Shape
placements = lattice2BaseFeature.getPlacementsList(obj.PlacementsTo, obj)
objectShape = screen(obj.Object).Shape
placements = lattice2BaseFeature.getPlacementsList(screen(obj.PlacementsTo), obj)
outputIsLattice = lattice2BaseFeature.isObjectLattice(obj.Object)
outputIsLattice = lattice2BaseFeature.isObjectLattice(screen(obj.Object))
# Pre-collect base placement list, if base is a lattice. For speed.
if outputIsLattice:
objectPlms = lattice2BaseFeature.getPlacementsList(obj.Object,obj)
objectPlms = lattice2BaseFeature.getPlacementsList(screen(obj.Object),obj)
placements = DereferenceArray(obj, placements, obj.PlacementsFrom, obj.Referencing)
placements = DereferenceArray(obj, placements, screen(obj.PlacementsFrom), obj.Referencing)
# initialize output containers and loop variables
outputShapes = [] #output list of shapes
@ -143,7 +143,7 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
# Output shape or compound (complex logic involving OutputCompounding property)
#first, autosettle the OutputCompounding.
if obj.OutputCompounding == "(autosettle)":
if hasattr(obj.PlacementsTo,"ExposePlacement") and obj.PlacementsTo.ExposePlacement == False:
if hasattr(screen(obj.PlacementsTo),"ExposePlacement") and screen(obj.PlacementsTo).ExposePlacement == False:
obj.OutputCompounding = "always"
else:
obj.OutputCompounding = "only if many"
@ -177,9 +177,9 @@ class ViewProviderLatticePopulateCopies(lattice2BaseFeature.ViewProviderLatticeF
)
def claimChildren(self):
children = [self.Object.Object, self.Object.PlacementsTo]
children = [screen(self.Object.Object), screen(self.Object.PlacementsTo)]
if self.Object.Referencing == "Use PlacementsFrom":
children.append(self.Object.PlacementsFrom)
children.append(screen(self.Object.PlacementsFrom))
return children
# -------------------------- /document object --------------------------------------------------

View File

@ -68,17 +68,17 @@ class LatticeProjectArray(lattice2BaseFeature.LatticeFeature):
def derivedExecute(self,obj):
#validity check
if not lattice2BaseFeature.isObjectLattice(obj.Base):
if not lattice2BaseFeature.isObjectLattice(screen(obj.Base)):
lattice2Executer.warning(obj,"A lattice object is expected as Base, but a generic shape was provided. It will be treated as a lattice object; results may be unexpected.")
toolShape = obj.Tool.Shape
if lattice2BaseFeature.isObjectLattice(obj.Tool):
toolShape = screen(obj.Tool).Shape
if lattice2BaseFeature.isObjectLattice(screen(obj.Tool)):
lattice2Executer.warning(obj,"A lattice object was provided as Tool. It will be converted into points; orientations will be ignored.")
leaves = LCE.AllLeaves(toolShape)
points = [Part.Vertex(leaf.Placement.Base) for leaf in leaves]
toolShape = Part.makeCompound(points)
leaves = LCE.AllLeaves(obj.Base.Shape)
leaves = LCE.AllLeaves(screen(obj.Base).Shape)
input = [leaf.Placement for leaf in leaves]
output = [] #variable to receive the final list of placements
@ -180,7 +180,7 @@ class ViewProviderProjectArray(lattice2BaseFeature.ViewProviderLatticeFeature):
return getIconPath("Lattice2_ProjectArray.svg")
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
def CreateLatticeProjectArray(name):
sel = FreeCADGui.Selection.getSelectionEx()

View File

@ -69,8 +69,8 @@ class LatticeResample(lattice2BaseFeature.LatticeFeature):
def derivedExecute(self,obj):
# cache stuff
base = obj.Base.Shape
if not lattice2BaseFeature.isObjectLattice(obj.Base):
base = screen(obj.Base).Shape
if not lattice2BaseFeature.isObjectLattice(screen(obj.Base)):
lattice2Executer.warning(obj, "Base is not a lattice, but lattice is expected. Results may be unexpected.\n")
input = [leaf.Placement for leaf in LCE.AllLeaves(base)]
@ -142,7 +142,7 @@ class ViewProviderLatticeResample(lattice2BaseFeature.ViewProviderLatticeFeature
return getIconPath('Lattice2_Resample.svg')
def claimChildren(self):
return [self.Object.Base]
return [screen(self.Object.Base)]
# -------------------------- /document object --------------------------------------------------

View File

@ -53,13 +53,13 @@ class ShapeInfoFeature:
self.updatedProperties = set()
try:
if LBF.isObjectLattice(selfobj.Object):
plms = LBF.getPlacementsList(selfobj.Object)
if LBF.isObjectLattice(screen(selfobj.Object)):
plms = LBF.getPlacementsList(screen(selfobj.Object))
self.assignProp(selfobj,"App::PropertyInteger","NumberOfPlacements",len(plms))
for i in range( min( len(plms), 10 ) ):
self.assignProp(selfobj,"App::PropertyPlacement","Placement"+str(i),plms[i])
else:
sh = selfobj.Object.Shape
sh = screen(selfobj.Object).Shape
self.assignProp(selfobj,"App::PropertyString","ShapeType", sh.ShapeType)

View File

@ -150,7 +150,7 @@ class LatticeShapeString:
def execute(self,obj):
nOfStrings = len(obj.Strings)
lattice = obj.ArrayLink
lattice = screen(obj.ArrayLink)
if lattice is None:
plms = [App.Placement() for i in range(0,nOfStrings)]
else:

View File

@ -53,8 +53,8 @@ class LatticeSlice:
def execute(self,obj):
rst = []
pieces = LCE.AllLeaves(obj.Base.Shape)
cutters = LCE.AllLeaves(obj.Tool.Shape)
pieces = LCE.AllLeaves(screen(obj.Base).Shape)
cutters = LCE.AllLeaves(screen(obj.Tool).Shape)
# prepare cutter shapes by converting them to solids
cutters_solids = []
for cutter in cutters:
@ -125,12 +125,12 @@ class ViewProviderLatticeSlice:
return None
def claimChildren(self):
return [self.Object.Base, self.Object.Tool]
return [screen(self.Object.Base), screen(self.Object.Tool)]
def onDelete(self, feature, subelements): # subelements is a tuple of strings
try:
self.Object.Base.ViewObject.show()
self.Object.Tool.ViewObject.show()
screen(self.Object.Base).ViewObject.show()
screen(self.Object.Tool).ViewObject.show()
except Exception as err:
FreeCAD.Console.PrintError("Error in onDelete: " + err.message)
return True

View File

@ -59,17 +59,17 @@ class LatticeSubLink:
def assureProperties(self, selfobj):
assureProperty(selfobj, "App::PropertyEnumeration","Looping", ["Single"] + LSS.LOOP_MODES, "Lattice SubLink", "Sets wether to collect just the element, or all similar from array.")
assureProperty(selfobj, "App::PropertyEnumeration","CompoundTraversal", LSS.TRAVERSAL_MODES, "Lattice SubLink", "Sets how to unpack compounds if Looping is not 'Single'.")
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(selfobj.Object, selfobj.SubNames), "Lattice SubLink", "Mirror of Object+SubNames properties")
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(screen(selfobj.Object), selfobj.SubNames), "Lattice SubLink", "Mirror of Object+SubNames properties")
def execute(self,selfobj):
self.assureProperties(selfobj)
#validity check
if isObjectLattice(selfobj.Object):
if isObjectLattice(screen(selfobj.Object)):
import lattice2Executer
lattice2Executer.warning(selfobj,"A generic shape is expected, but a placement/array was supplied. It will be treated as a generic shape.")
lnkobj = selfobj.Object
lnkobj = screen(selfobj.Object)
sh = lnkobj.Shape
# subsequencing
@ -125,8 +125,8 @@ class LatticeSubLink:
# no shapes collected, FAIL!
scale = 1.0
try:
if selfobj.Object:
scale = selfobj.Object[0].Shape.BoundBox.DiagonalLength/math.sqrt(3)
if screen(selfobj.Object):
scale = screen(selfobj.Object).Shape.BoundBox.DiagonalLength/math.sqrt(3)
except Exception as err:
App.Console.PrintError(selfobj.Name+": Failed to estimate size of marker shape")
if scale < DistConfusion * 100:

View File

@ -132,7 +132,7 @@ class LatticeTopoSeries(lattice2BaseFeature.LatticeFeature):
# do the subsequencing in this document first, to verify stuff is set up correctly, and to obtain sequence length
if self.isVerbose():
print ("In-place pre-subsequencing, for early check")
n_seq, subs_linkdict = self.makeSubsequence(selfobj, selfobj.ObjectToLoopOver)
n_seq, subs_linkdict = self.makeSubsequence(selfobj, screen(selfobj.ObjectToLoopOver))
bGui = bool(App.GuiUp) and Executer.globalIsCreatingLatticeFeature #disabled for most recomputes, because it causes a crash if property edits are approved by hitting Enter
@ -150,7 +150,7 @@ class LatticeTopoSeries(lattice2BaseFeature.LatticeFeature):
if self.isVerbose():
print ("Copying object with dependencies to a temporary document...")
doc2.copyObject(selfobj.ObjectToTake, True)
doc2.copyObject(screen(selfobj.ObjectToTake), True)
if self.isVerbose():
print ("Enabling nested para/toposeries, if any...")
@ -163,8 +163,8 @@ class LatticeTopoSeries(lattice2BaseFeature.LatticeFeature):
except exception:
Executer.warning(selfobj,"Failed to enable recomputing of "+objd2.Name)
object_to_take_in_doc2 = doc2.getObject(selfobj.ObjectToTake.Name)
object_to_loop_in_doc2 = doc2.getObject(selfobj.ObjectToLoopOver.Name)
object_to_take_in_doc2 = doc2.getObject(screen(selfobj.ObjectToTake).Name)
object_to_loop_in_doc2 = doc2.getObject(screen(selfobj.ObjectToLoopOver).Name)
if bGui:
progress.setValue(1)
@ -191,8 +191,8 @@ class LatticeTopoSeries(lattice2BaseFeature.LatticeFeature):
scale = 1.0
try:
if not selfobj.ObjectToTake.Shape.isNull():
scale = selfobj.ObjectToTake.Shape.BoundBox.DiagonalLength/math.sqrt(3)
if not screen(selfobj.ObjectToTake).Shape.isNull():
scale = screen(selfobj.ObjectToTake).Shape.BoundBox.DiagonalLength/math.sqrt(3)
except Exception:
pass
if scale < DistConfusion * 100:
@ -224,7 +224,7 @@ class LatticeTopoSeries(lattice2BaseFeature.LatticeFeature):
selfobj.Shape = Part.makeCompound(output_shapes)
output_is_lattice = lattice2BaseFeature.isObjectLattice(selfobj.ObjectToTake)
output_is_lattice = lattice2BaseFeature.isObjectLattice(screen(selfobj.ObjectToTake))
if 'Auto' in selfobj.isLattice:
new_isLattice = 'Auto-On' if output_is_lattice else 'Auto-Off'
if selfobj.isLattice != new_isLattice:#check, to not cause onChanged without necessity (onChange messes with colors, it's better to keep user color)
@ -240,7 +240,7 @@ class ViewProviderLatticeTopoSeries(lattice2BaseFeature.ViewProviderLatticeFeatu
return getIconPath("Lattice2_TopoSeries.svg")
def claimChildren(self):
return [self.Object.ObjectToTake]
return [screen(self.Object.ObjectToTake)]
# -------------------------- /document object --------------------------------------------------

View File

@ -28,7 +28,7 @@ __doc__ = "Value Series generator module: utility module to attach value generat
import math
import lattice2Executer
from lattice2Common import ParaConfusion
from lattice2Common import ParaConfusion, screen
class ValueSeriesGenerator:
mode_userfriendly_names = {
@ -253,9 +253,10 @@ class ValueSeriesGenerator:
#loop until the value can't be read out
values = []
spsh = screen(obj.SpreadsheetLink)
while True:
try:
values.append( obj.SpreadsheetLink.get(col+str(row)) )
values.append( spsh.get(col+str(row)) )
except ValueError:
break
row += 1