Use Autosize in single placement, attachable placement, linear and polar arrays, shapestring

This commit is contained in:
DeepSOIC 2018-12-02 01:29:25 +03:00
parent ef613b8af7
commit 3e60aa867d
5 changed files with 28 additions and 2 deletions

View File

@ -168,8 +168,11 @@ def CreateAttachablePlacement(name):
FreeCAD.ActiveDocument.openTransaction("Create Attachable Placement")
FreeCADGui.addModule("lattice2AttachablePlacement")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.addModule("PartGui")
FreeCADGui.doCommand("f = lattice2AttachablePlacement.makeAttachablePlacement(name='"+name+"')")
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.MarkerSize = lattice2Base.Autosize.convenientMarkerSize()")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCADGui.doCommand("lattice2AttachablePlacement.editNewAttachment(f)")
#FreeCAD.ActiveDocument.commitTransaction()

View File

@ -196,12 +196,16 @@ def CreateLinearArray(name, mode):
FreeCAD.ActiveDocument.openTransaction("Create LinearArray")
FreeCADGui.addModule("lattice2LinearArray")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.doCommand("f = lattice2LinearArray.makeLinearArray(name='"+name+"')")
if len(sel) == 1:
FreeCADGui.doCommand("f.Link = App.ActiveDocument."+sel[0].ObjectName)
if sel[0].HasSubObjects:
FreeCADGui.doCommand("f.LinkSubelement = '"+sel[0].SubElementNames[0]+"'")
FreeCADGui.doCommand("f.GeneratorMode = {mode}".format(mode= repr(mode)))
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.SpanEnd = lattice2Base.Autosize.convenientModelSize()")
FreeCADGui.doCommand("f.Step = lattice2Base.Autosize.convenientMarkerSize()")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCAD.ActiveDocument.commitTransaction()

View File

@ -179,9 +179,12 @@ def CreateLatticePlacement(name,mode = 'Custom'):
FreeCAD.ActiveDocument.openTransaction("Create Lattice Placement")
FreeCADGui.addModule("lattice2Placement")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.doCommand("f = lattice2Placement.makeLatticePlacement(name='"+name+"')")
FreeCADGui.doCommand("f.PlacementChoice = '"+mode+"'")
FreeCADGui.doCommand("f.Label = '"+mode+"'")
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.MarkerSize = lattice2Base.Autosize.convenientMarkerSize()")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
FreeCADGui.doCommand("f = None")
@ -192,6 +195,7 @@ def CreateLatticePlacementAx(label, priority, XDir, YDir, ZDir):
FreeCAD.ActiveDocument.openTransaction("Create Lattice Placement")
FreeCADGui.addModule("lattice2Placement")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
name = "PlacementAx"
FreeCADGui.doCommand("f = lattice2Placement.makeLatticePlacementAx(name='"+name+"')")
FreeCADGui.doCommand("f.Priority = "+repr(priority))
@ -202,6 +206,8 @@ def CreateLatticePlacementAx(label, priority, XDir, YDir, ZDir):
if ZDir is not None and ZDir.Length > DistConfusion:
FreeCADGui.doCommand("f.ZDir_wanted = App.Vector"+repr(tuple(ZDir)))
FreeCADGui.doCommand("f.Label = "+repr(label))
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.MarkerSize = lattice2Base.Autosize.convenientMarkerSize()")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
FreeCADGui.doCommand("f = None")
@ -212,7 +218,10 @@ def CreateLatticePlacementEuler(name):
FreeCAD.ActiveDocument.openTransaction("Create Lattice Placement")
FreeCADGui.addModule("lattice2Placement")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.doCommand("f = lattice2Placement.makeLatticePlacementEuler(name='"+name+"')")
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.MarkerSize = lattice2Base.Autosize.convenientMarkerSize()")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
FreeCADGui.doCommand("f = None")

View File

@ -230,6 +230,7 @@ def CreatePolarArray(genmode = 'SpanN'):
FreeCAD.ActiveDocument.openTransaction("Create PolarArray")
FreeCADGui.addModule('lattice2PolarArray2')
FreeCADGui.addModule('lattice2Executer')
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.doCommand('f = lattice2PolarArray2.make()')
FreeCADGui.doCommand("f.GeneratorMode = {mode}".format(mode= repr(genmode)))
attached = False
@ -250,6 +251,9 @@ def CreatePolarArray(genmode = 'SpanN'):
.format(lnk= lnk.Name, sub= repr(sub), usearcrange= repr(usearcrange), endinclusive= repr(endinclusive))
)
attached = True
if not attached:
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.Radius = lattice2Base.Autosize.convenientModelSize()/2")
FreeCADGui.doCommand('lattice2Executer.executeFeature(f)')
if len(sublinks) > 0 and not attached:
FreeCADGui.addModule('lattice2AttachablePlacement')

View File

@ -219,8 +219,10 @@ class LatticeShapeString:
scale = 1.0
obj.Shape = markers.getNullShapeShape(scale)
raise ValueError('No strings were converted into shapes') #Feeding empty compounds to FreeCAD seems to cause rendering issues, otherwise it would have been a good idea to output nothing.
obj.Shape = Part.makeCompound(shapes)
result = Part.makeCompound(shapes)
result.Placement = obj.Placement
obj.Shape = result
def __getstate__(self):
return None
@ -254,9 +256,13 @@ def CreateLatticeShapeString(name):
FreeCAD.ActiveDocument.openTransaction("Create LatticeShapeString")
FreeCADGui.addModule("lattice2ShapeString")
FreeCADGui.addModule("lattice2Executer")
FreeCADGui.addModule("lattice2Base.Autosize")
FreeCADGui.doCommand("f = lattice2ShapeString.makeLatticeShapeString(name='"+name+"')")
if len(sel) == 1:
FreeCADGui.doCommand("f.ArrayLink = FreeCADGui.Selection.getSelection()[0]")
else:
FreeCADGui.doCommand("f.Placement.Base = lattice2Base.Autosize.convenientPosition()")
FreeCADGui.doCommand("f.Size = lattice2Base.Autosize.convenientModelSize()/10")
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
FreeCADGui.doCommand("f = None")
FreeCAD.ActiveDocument.commitTransaction()