Tidy up of text command support

This commit is contained in:
Keith Sloan 2016-10-08 20:56:00 +01:00 committed by wmayer
parent b4020f2cc8
commit e0b9e29db9

View File

@ -603,7 +603,8 @@ def process_linear_extrude(obj,h) :
mylinear.Base = newobj #obj mylinear.Base = newobj #obj
mylinear.Dir = (0,0,h) mylinear.Dir = (0,0,h)
mylinear.Placement=FreeCAD.Placement() mylinear.Placement=FreeCAD.Placement()
mylinear.Solid = True # V17 change to False mylinear.Solid = True
mylinear.Solid = False
if gui: if gui:
newobj.ViewObject.hide() newobj.ViewObject.hide()
return(mylinear) return(mylinear)
@ -703,18 +704,21 @@ def process_mesh_file(fname,ext):
obj.Shape=Part.Compound([]) obj.Shape=Part.Compound([])
return(obj) return(obj)
def processTextCmd(t): def processTextCmd(t):
import os import os
from OpenSCADUtils import callopenscadstring from OpenSCADUtils import callopenscadstring
tmpfilename = callopenscadstring(t,'dxf') tmpfilename = callopenscadstring(t,'dxf')
obj=processDXF(os.path.splitext(tmpfilename)[0],"") from OpenSCAD2Dgeom import importDXFface
try: face = importDXFface(tmpfilename,None,None)
os.unlink(tmpfilename) obj=doc.addObject('Part::Feature','text')
except OSError: obj.Shape=face
pass try:
return(obj) os.unlink(tmpfilename)
except OSError:
pass
return(obj)
def processDXF(fname,layer): def processDXF(fname,layer):
global doc global doc
global pathName global pathName
@ -1022,32 +1026,32 @@ def p_square_action(p) :
if p[3]['center']=='true' : if p[3]['center']=='true' :
center(mysquare,x,y,0) center(mysquare,x,y,0)
p[0] = [mysquare] p[0] = [mysquare]
def addString(t,s,p): def addString(t,s,p):
return(t + ', ' +s+' = "'+p[3][s]+'"') return(t + ', ' +s+' = "'+p[3][s]+'"')
def addValue(t,v,p): def addValue(t,v,p):
return(t + ', ' +v+' = '+p[3][v]) return(t + ', ' +v+' = '+p[3][v])
def p_text_action(p) : def p_text_action(p) :
'text_action : text LPAREN keywordargument_list RPAREN SEMICOL' 'text_action : text LPAREN keywordargument_list RPAREN SEMICOL'
t = 'text ( text="'+p[3]['text']+'"' t = 'text ( text="'+p[3]['text']+'"'
t = addValue(t,'size',p) t = addValue(t,'size',p)
t = addString(t,'spacing',p) t = addString(t,'spacing',p)
t = addString(t,'font',p) t = addString(t,'font',p)
t = addString(t,'direction',p) t = addString(t,'direction',p)
t = addString(t,'language',p) t = addString(t,'language',p)
t = addString(t,'script',p) t = addString(t,'script',p)
t = addString(t,'halign',p) t = addString(t,'halign',p)
t = addString(t,'valign',p) t = addString(t,'valign',p)
t = addValue(t,'$fn',p) t = addValue(t,'$fn',p)
t = addValue(t,'$fa',p) t = addValue(t,'$fa',p)
t = addValue(t,'$fs',p) t = addValue(t,'$fs',p)
t = t+');' t = t+');'
FreeCAD.Console.PrintMessage("textmsg : "+t+"\n") FreeCAD.Console.PrintMessage("textmsg : "+t+"\n")
p[0] = [processTextCmd(t)] p[0] = [processTextCmd(t)]
def convert_points_list_to_vector(l): def convert_points_list_to_vector(l):
v = [] v = []
for i in l : for i in l :