Skip to content

Commit

Permalink
Draft: Added a Fuse property to Array objects - fixes #1768
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jan 3, 2015
1 parent d8e0df9 commit 3db987d
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/Mod/Draft/Draft.py
Expand Up @@ -4639,6 +4639,7 @@ def __init__(self,obj):
obj.addProperty("App::PropertyVector","IntervalAxis","Draft","Distance and orientation of intervals in Axis direction")
obj.addProperty("App::PropertyVector","Center","Draft","Center point")
obj.addProperty("App::PropertyAngle","Angle","Draft","Angle to cover with copies")
obj.addProperty("App::PropertyBool","Fuse","Draft","Specifies if copies must be fused (slower)")
obj.ArrayType = ['ortho','polar']
obj.NumberX = 1
obj.NumberY = 1
Expand All @@ -4650,22 +4651,27 @@ def __init__(self,obj):
obj.IntervalZ = Vector(0,0,0)
obj.Angle = 360
obj.Axis = Vector(0,0,1)
obj.Fuse = False

def execute(self,obj):
import DraftGeomUtils
if hasattr(obj,"Fuse"):
fuse = obj.Fuse
else:
fuse = False
if obj.Base:
pl = obj.Placement
if obj.ArrayType == "ortho":
sh = self.rectArray(obj.Base.Shape,obj.IntervalX,obj.IntervalY,
obj.IntervalZ,obj.NumberX,obj.NumberY,obj.NumberZ)
obj.IntervalZ,obj.NumberX,obj.NumberY,obj.NumberZ,fuse)
else:
av = obj.IntervalAxis if hasattr(obj,"IntervalAxis") else None
sh = self.polarArray(obj.Base.Shape,obj.Center,obj.Angle.Value,obj.NumberPolar,obj.Axis,av)
sh = self.polarArray(obj.Base.Shape,obj.Center,obj.Angle.Value,obj.NumberPolar,obj.Axis,av,fuse)
obj.Shape = sh
if not DraftGeomUtils.isNull(pl):
obj.Placement = pl

def rectArray(self,shape,xvector,yvector,zvector,xnum,ynum,znum):
def rectArray(self,shape,xvector,yvector,zvector,xnum,ynum,znum,fuse=False):
import Part
base = [shape.copy()]
for xcount in range(xnum):
Expand All @@ -4688,9 +4694,15 @@ def rectArray(self,shape,xvector,yvector,zvector,xnum,ynum,znum):
nshape = shape.copy()
nshape.translate(currentzvector)
base.append(nshape)
return Part.makeCompound(base)
if fuse:
fshape = base.pop()
for s in base:
fshape = fshape.fuse(s)
return fshape.removeSplitter()
else:
return Part.makeCompound(base)

def polarArray(self,shape,center,angle,num,axis,axisvector):
def polarArray(self,shape,center,angle,num,axis,axisvector,fuse=False):
#print("angle ",angle," num ",num)
import Part
if angle == 360:
Expand All @@ -4708,7 +4720,14 @@ def polarArray(self,shape,center,angle,num,axis,axisvector):
if not DraftVecUtils.isNull(axisvector):
nshape.translate(FreeCAD.Vector(axisvector).multiply(i+1))
base.append(nshape)
return Part.makeCompound(base)
if fuse:
fshape = base.pop()
for s in base:
fshape = fshape.fuse(s)
return fshape.removeSplitter()
else:
return Part.makeCompound(base)


class _PathArray(_DraftObject):
"The Draft Path Array object"
Expand Down

0 comments on commit 3db987d

Please sign in to comment.