+ Draft DXF import now produces Draft Blocks if Parametric Objects import style is selected
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5246 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
a7753882d7
commit
b75385abd8
|
@ -282,7 +282,7 @@ def drawLine(line,shapemode=False):
|
||||||
v2=vec(line.points[1])
|
v2=vec(line.points[1])
|
||||||
if not fcvec.equals(v1,v2):
|
if not fcvec.equals(v1,v2):
|
||||||
try:
|
try:
|
||||||
if (fmt.paramstyle >= 4) and (not fmt.makeBlocks) and (not shapemode):
|
if (fmt.paramstyle >= 4) and (not shapemode):
|
||||||
return Draft.makeWire([v1,v2])
|
return Draft.makeWire([v1,v2])
|
||||||
else:
|
else:
|
||||||
return Part.Line(v1,v2).toShape()
|
return Part.Line(v1,v2).toShape()
|
||||||
|
@ -331,7 +331,7 @@ def drawPolyline(polyline,shapemode=False):
|
||||||
except: warn(polyline)
|
except: warn(polyline)
|
||||||
if edges:
|
if edges:
|
||||||
try:
|
try:
|
||||||
if (fmt.paramstyle >= 4) and (not curves) and (not fmt.makeBlocks) and (not shapemode):
|
if (fmt.paramstyle >= 4) and (not curves) and (not shapemode):
|
||||||
ob = Draft.makeWire(verts)
|
ob = Draft.makeWire(verts)
|
||||||
ob.Closed = polyline.closed
|
ob.Closed = polyline.closed
|
||||||
return ob
|
return ob
|
||||||
|
@ -354,7 +354,7 @@ def drawArc(arc,shapemode=False):
|
||||||
circle.Center=v
|
circle.Center=v
|
||||||
circle.Radius=round(arc.radius,prec())
|
circle.Radius=round(arc.radius,prec())
|
||||||
try:
|
try:
|
||||||
if (fmt.paramstyle >= 4) and (not fmt.makeBlocks) and (not shapemode):
|
if (fmt.paramstyle >= 4) and (not shapemode):
|
||||||
pl = FreeCAD.Placement()
|
pl = FreeCAD.Placement()
|
||||||
pl.move(v)
|
pl.move(v)
|
||||||
return Draft.makeCircle(arc.radius,pl,False,firstangle,lastangle)
|
return Draft.makeCircle(arc.radius,pl,False,firstangle,lastangle)
|
||||||
|
@ -371,7 +371,7 @@ def drawCircle(circle,shapemode=False):
|
||||||
curve.Radius = round(circle.radius,prec())
|
curve.Radius = round(circle.radius,prec())
|
||||||
curve.Center = v
|
curve.Center = v
|
||||||
try:
|
try:
|
||||||
if (fmt.paramstyle >= 4) and (not fmt.makeBlocks) and (not shapemode):
|
if (fmt.paramstyle >= 4) and (not shapemode):
|
||||||
pl = FreeCAD.Placement()
|
pl = FreeCAD.Placement()
|
||||||
pl.move(v)
|
pl.move(v)
|
||||||
return Draft.makeCircle(circle.radius,pl)
|
return Draft.makeCircle(circle.radius,pl)
|
||||||
|
@ -489,7 +489,7 @@ def drawSpline(spline,shapemode=False):
|
||||||
elif dline[0] == 40:
|
elif dline[0] == 40:
|
||||||
knots.append(dline[1])
|
knots.append(dline[1])
|
||||||
try:
|
try:
|
||||||
if (fmt.paramstyle == 4) and (not fmt.makeBlocks) and (not shapemode):
|
if (fmt.paramstyle == 4) and (not shapemode):
|
||||||
ob = Draft.makeSpline(verts)
|
ob = Draft.makeSpline(verts)
|
||||||
ob.Closed = closed
|
ob.Closed = closed
|
||||||
return ob
|
return ob
|
||||||
|
@ -570,14 +570,20 @@ def drawInsert(insert):
|
||||||
return shape
|
return shape
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def drawLayerBlock(shapeslist):
|
def drawLayerBlock(objlist):
|
||||||
"draws a compound with the given shapes"
|
"draws a Draft block with the given shapes or objects"
|
||||||
shape = None
|
obj = None
|
||||||
try:
|
if fmt.paramstyle >= 4:
|
||||||
shape = Part.makeCompound(shapeslist)
|
try:
|
||||||
except:
|
obj = Draft.makeBlock(objlist)
|
||||||
pass
|
except:
|
||||||
return shape
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
obj = Part.makeCompound(objlist)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return obj
|
||||||
|
|
||||||
def attribs(insert):
|
def attribs(insert):
|
||||||
"checks if an insert has attributes, and returns the values if yes"
|
"checks if an insert has attributes, and returns the values if yes"
|
||||||
|
@ -637,12 +643,12 @@ def addText(text,attrib=False):
|
||||||
newob.ViewObject.DisplayMode = "World"
|
newob.ViewObject.DisplayMode = "World"
|
||||||
fmt.formatObject(newob,text,textmode=True)
|
fmt.formatObject(newob,text,textmode=True)
|
||||||
|
|
||||||
def addToBlock(shape,layer):
|
def addToBlock(obj,layer):
|
||||||
"adds given shape to the layer dict"
|
"adds given shape to the layer dict"
|
||||||
if layer in layerBlocks:
|
if layer in layerBlocks:
|
||||||
layerBlocks[layer].append(shape)
|
layerBlocks[layer].append(obj)
|
||||||
else:
|
else:
|
||||||
layerBlocks[layer] = [shape]
|
layerBlocks[layer] = [obj]
|
||||||
|
|
||||||
def processdxf(document,filename):
|
def processdxf(document,filename):
|
||||||
"this does the translation of the dxf contents into FreeCAD Part objects"
|
"this does the translation of the dxf contents into FreeCAD Part objects"
|
||||||
|
@ -690,10 +696,7 @@ def processdxf(document,filename):
|
||||||
else:
|
else:
|
||||||
shapes.append(shape.Shape)
|
shapes.append(shape.Shape)
|
||||||
elif fmt.makeBlocks:
|
elif fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,line.layer)
|
||||||
addToBlock(shape,line.layer)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,line.layer)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Line",line.layer)
|
newob = addObject(shape,"Line",line.layer)
|
||||||
if gui: fmt.formatObject(newob,line)
|
if gui: fmt.formatObject(newob,line)
|
||||||
|
@ -736,10 +739,7 @@ def processdxf(document,filename):
|
||||||
else:
|
else:
|
||||||
shapes.append(shape.Shape)
|
shapes.append(shape.Shape)
|
||||||
elif fmt.makeBlocks:
|
elif fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,polyline.layer)
|
||||||
addToBlock(shape,polyline.layer)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,polyline.layer)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Polyline",polyline.layer)
|
newob = addObject(shape,"Polyline",polyline.layer)
|
||||||
if gui: fmt.formatObject(newob,polyline)
|
if gui: fmt.formatObject(newob,polyline)
|
||||||
|
@ -767,10 +767,7 @@ def processdxf(document,filename):
|
||||||
else:
|
else:
|
||||||
shapes.append(shape.Shape)
|
shapes.append(shape.Shape)
|
||||||
elif fmt.makeBlocks:
|
elif fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,arc.layer)
|
||||||
addToBlock(shape,arc.layer)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,arc.layer)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Arc",arc.layer)
|
newob = addObject(shape,"Arc",arc.layer)
|
||||||
if gui: fmt.formatObject(newob,arc)
|
if gui: fmt.formatObject(newob,arc)
|
||||||
|
@ -804,10 +801,7 @@ def processdxf(document,filename):
|
||||||
else:
|
else:
|
||||||
shape = Draft.makeSketch(shape,autoconstraints=True)
|
shape = Draft.makeSketch(shape,autoconstraints=True)
|
||||||
elif fmt.makeBlocks:
|
elif fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,circle.layer)
|
||||||
addToBlock(shape,circle.layer)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,circle.layer)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Circle",circle.layer)
|
newob = addObject(shape,"Circle",circle.layer)
|
||||||
if gui: fmt.formatObject(newob,circle)
|
if gui: fmt.formatObject(newob,circle)
|
||||||
|
@ -822,10 +816,7 @@ def processdxf(document,filename):
|
||||||
shape = drawSolid(solid)
|
shape = drawSolid(solid)
|
||||||
if shape:
|
if shape:
|
||||||
if fmt.makeBlocks:
|
if fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,lay)
|
||||||
addToBlock(shape,lay)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,lay)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Solid",lay)
|
newob = addObject(shape,"Solid",lay)
|
||||||
if gui: fmt.formatObject(newob,solid)
|
if gui: fmt.formatObject(newob,solid)
|
||||||
|
@ -840,10 +831,7 @@ def processdxf(document,filename):
|
||||||
shape = drawSpline(spline)
|
shape = drawSpline(spline)
|
||||||
if shape:
|
if shape:
|
||||||
if fmt.makeBlocks:
|
if fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,lay)
|
||||||
addToBlock(shape,lay)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,lay)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Spline",lay)
|
newob = addObject(shape,"Spline",lay)
|
||||||
if gui: fmt.formatObject(newob,spline)
|
if gui: fmt.formatObject(newob,spline)
|
||||||
|
@ -949,10 +937,7 @@ def processdxf(document,filename):
|
||||||
shape = drawInsert(insert)
|
shape = drawInsert(insert)
|
||||||
if shape:
|
if shape:
|
||||||
if fmt.makeBlocks:
|
if fmt.makeBlocks:
|
||||||
if isinstance(shape,Part.Shape):
|
addToBlock(shape,block.layer)
|
||||||
addToBlock(shape,block.layer)
|
|
||||||
else:
|
|
||||||
addToBlock(shape.Shape,block.layer)
|
|
||||||
else:
|
else:
|
||||||
newob = addObject(shape,"Block."+insert.block,insert.layer)
|
newob = addObject(shape,"Block."+insert.block,insert.layer)
|
||||||
if gui: fmt.formatObject(newob,insert)
|
if gui: fmt.formatObject(newob,insert)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user