importCSG: add empty compounds for elemets with size 0

This commit is contained in:
Sebastian Hoogen 2014-01-16 13:38:19 +01:00 committed by Yorik van Havre
parent 21d736d21f
commit e99216189c

View File

@ -793,7 +793,7 @@ def p_cylinder_action(p):
r2 = float(p[3]['r2'])
n = int(p[3]['$fn'])
if printverbose: print p[3]
if ( r1 == r2 ):
if ( r1 == r2 and r1 > 0):
if printverbose: print "Make Cylinder"
fnmax = FreeCAD.ParamGet(\
"User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
@ -828,12 +828,16 @@ def p_cylinder_action(p):
mycyl.Circumradius = r1
mycyl.Height = h
else:
elif (r1 != r2):
if printverbose: print "Make Cone"
mycyl=doc.addObject("Part::Cone",p[1])
mycyl.Height = h
mycyl.Radius1 = r1
mycyl.Radius2 = r2
else: # r1 == r2 == 0
FreeCAD.Console.PrintWarning('cylinder with radius zero\n')
mycyl=doc.addObject("Part::Feature","emptycyl")
mycyl.Shape = Part.Compound([])
if printverbose: print "Center = ",tocenter
if tocenter=='true' :
center(mycyl,0,0,h)
@ -858,11 +862,16 @@ def p_cube_action(p):
'cube_action : cube LPAREN keywordargument_list RPAREN SEMICOL'
global doc
l,w,h = [float(str1) for str1 in p[3]['size']]
if printverbose: print "cube : ",p[3]
mycube=doc.addObject('Part::Box',p[1])
mycube.Length=l
mycube.Width=w
mycube.Height=h
if (l > 0 and w > 0 and h >0):
if printverbose: print "cube : ",p[3]
mycube=doc.addObject('Part::Box',p[1])
mycube.Length=l
mycube.Width=w
mycube.Height=h
else:
FreeCAD.Console.PrintWarning('cube with radius zero\n')
mycube=doc.addObject("Part::Feature","emptycube")
mycube.Shape = Part.Compound([])
if p[3]['center']=='true' :
center(mycube,l,w,h);
p[0] = [mycube]