Fixed merge issues
This commit is contained in:
@@ -112,7 +112,7 @@ class StockFromBase(Stock):
|
||||
obj.ExtZpos= 1.0
|
||||
|
||||
# placement is only tracked on creation
|
||||
bb = shapeBoundBox(base.Group)
|
||||
bb = shapeBoundBox(base.Group) if base else None
|
||||
if bb:
|
||||
obj.Placement = FreeCAD.Placement(FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin), FreeCAD.Rotation())
|
||||
else:
|
||||
@@ -225,9 +225,7 @@ def SetupStockObject(obj, stockType):
|
||||
|
||||
def CreateFromBase(job, neg=None, pos=None, placement=None):
|
||||
PathLog.track(job.Label, neg, pos, placement)
|
||||
base = job.Model if job and hasattr(job, 'Model') else None
|
||||
if base:
|
||||
base.Shape.tessellate(0.1)
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockFromBase(obj, base)
|
||||
|
||||
@@ -250,9 +248,7 @@ def CreateFromBase(job, neg=None, pos=None, placement=None):
|
||||
return obj
|
||||
|
||||
def CreateBox(job, extent=None, placement=None):
|
||||
base = job.Model.Group if job else None
|
||||
if base:
|
||||
base.Shape.tessellate(0.1)
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockCreateBox(obj)
|
||||
|
||||
@@ -261,24 +257,24 @@ def CreateBox(job, extent=None, placement=None):
|
||||
obj.Width = extent.y
|
||||
obj.Height = extent.z
|
||||
elif base:
|
||||
bb = shapeBoundBox(base)
|
||||
bb = shapeBoundBox(base.Group)
|
||||
obj.Length = max(bb.XLength, 1)
|
||||
obj.Width = max(bb.YLength, 1)
|
||||
obj.Height = max(bb.ZLength, 1)
|
||||
|
||||
if placement:
|
||||
obj.Placement = placement
|
||||
elif base:
|
||||
bb = shapeBoundBox(base)
|
||||
bb = shapeBoundBox(base.Group)
|
||||
origin = FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin)
|
||||
obj.Placement = FreeCAD.Placement(origin, FreeCAD.Vector(), 0)
|
||||
|
||||
SetupStockObject(obj, StockType.CreateBox)
|
||||
return obj
|
||||
|
||||
def CreateCylinder(job, radius=None, height=None, placement=None):
|
||||
base = job.Model.Group if job else None
|
||||
base = job.Model if job else None
|
||||
obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
if base:
|
||||
base.Shape.tessellate(0.1) obj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'Stock')
|
||||
proxy = StockCreateCylinder(obj)
|
||||
|
||||
if radius:
|
||||
@@ -287,14 +283,14 @@ def CreateCylinder(job, radius=None, height=None, placement=None):
|
||||
if height:
|
||||
obj.Height = height
|
||||
elif base:
|
||||
bb = shapeBoundBox(base)
|
||||
bb = shapeBoundBox(base.Group)
|
||||
obj.Radius = math.sqrt(bb.XLength ** 2 + bb.YLength ** 2) / 2.0
|
||||
obj.Height = max(bb.ZLength, 1)
|
||||
|
||||
if placement:
|
||||
obj.Placement = placement
|
||||
elif base:
|
||||
bb = shapeBoundBox(base)
|
||||
bb = shapeBoundBox(base.Group)
|
||||
origin = FreeCAD.Vector((bb.XMin + bb.XMax)/2, (bb.YMin + bb.YMax)/2, bb.ZMin)
|
||||
obj.Placement = FreeCAD.Placement(origin, FreeCAD.Vector(), 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user