Draft: Added raulshc's patch to importDWG + minor fix
This commit is contained in:
parent
eab159b6ee
commit
d5ed1b1b65
|
@ -68,7 +68,7 @@ def getTeighaConverter():
|
|||
if platform.system() == "Linux":
|
||||
teigha = "/usr/bin/TeighaFileConverter"
|
||||
elif platform.system() == "Windows":
|
||||
odadir = "C:\Program Files\ODA"
|
||||
odadir = os.path.expandvars("%ProgramFiles%\ODA")
|
||||
if os.path.exists(odadir):
|
||||
subdirs = os.walk(odadir).next()[1]
|
||||
for sub in subdirs:
|
||||
|
@ -90,7 +90,7 @@ def convertToDxf(dwgfilename):
|
|||
indir = os.path.dirname(dwgfilename)
|
||||
outdir = tempfile.mkdtemp()
|
||||
basename = os.path.basename(dwgfilename)
|
||||
cmdline = teigha + ' "' + indir + '" "' + outdir + '" "ACAD2010" "DXF" "0" "1" "' + basename + '"'
|
||||
cmdline = '"%s" "%s" "%s" "ACAD2000" "DXF" "0" "1" "%s"' % (teigha, indir, outdir, basename)
|
||||
print "Converting: " + cmdline
|
||||
os.system(cmdline)
|
||||
result = outdir + os.sep + os.path.splitext(basename)[0] + ".dxf"
|
||||
|
@ -110,7 +110,7 @@ def convertToDwg(dxffilename,dwgfilename):
|
|||
indir = os.path.dirname(dxffilename)
|
||||
outdir = os.path.dirname(dwgfilename)
|
||||
basename = os.path.basename(dxffilename)
|
||||
cmdline = teigha + ' "' + indir + '" "' + outdir + '" "ACAD2010" "DWG" "0" "1" "' + basename + '"'
|
||||
cmdline = '"%s" "%s" "%s" "ACAD2000" "DWG" "0" "1" "%s"' % (teigha, indir, outdir, basename)
|
||||
print "converting " + cmdline
|
||||
os.system(cmdline)
|
||||
return dwgfilename
|
||||
|
|
|
@ -106,24 +106,30 @@ def deformat(text):
|
|||
"removes weird formats in texts and wipes UTF characters"
|
||||
# remove ACAD string formatation
|
||||
#t = re.sub('{([^!}]([^}]|\n)*)}', '', text)
|
||||
print "input text: ",text
|
||||
#print "input text: ",text
|
||||
t = text.strip("{}")
|
||||
t = re.sub("\\\.*?;","",t)
|
||||
# replace UTF codes by utf chars
|
||||
sts = re.split("\\\\(U\+....)",t)
|
||||
ns = u""
|
||||
for ss in sts:
|
||||
print ss, type(ss)
|
||||
#print ss, type(ss)
|
||||
if ss.startswith("U+"):
|
||||
ucode = "0x"+ss[2:]
|
||||
ns += unichr(eval(ucode))
|
||||
else:
|
||||
ns += ss.decode("utf8")
|
||||
try:
|
||||
ns += ss.decode("utf8")
|
||||
except:
|
||||
try:
|
||||
ns += ss.decode("latin1")
|
||||
except:
|
||||
print "unable to decode text: ",text
|
||||
t = ns
|
||||
# replace degrees, diameters chars
|
||||
t = re.sub('%%d','°',t)
|
||||
t = re.sub('%%c','Ø',t)
|
||||
print "output text: ",t
|
||||
#print "output text: ",t
|
||||
return t
|
||||
|
||||
def locateLayer(wantedLayer):
|
||||
|
@ -655,7 +661,10 @@ def drawBlock(blockref,num=None,createObject=False):
|
|||
if not fmt.paramstarblocks:
|
||||
if blockref.name[0] == '*':
|
||||
return None
|
||||
print "creating block ", blockref.name, " containing ", len(blockref.entities.data), " entities"
|
||||
if len(blockref.entities.data) == 0:
|
||||
print "skipping empty block ",blockref.name
|
||||
return None
|
||||
#print "creating block ", blockref.name, " containing ", len(blockref.entities.data), " entities"
|
||||
shapes = []
|
||||
for line in blockref.entities.get_type('line'):
|
||||
s = drawLine(line,shapemode=True)
|
||||
|
@ -673,7 +682,7 @@ def drawBlock(blockref,num=None,createObject=False):
|
|||
s = drawCircle(circle,shapemode=True)
|
||||
if s: shapes.append(s)
|
||||
for insert in blockref.entities.get_type('insert'):
|
||||
print "insert ",insert," in block ",insert.block[0]
|
||||
#print "insert ",insert," in block ",insert.block[0]
|
||||
if fmt.paramstarblocks or insert.block[0] != '*':
|
||||
s = drawInsert(insert)
|
||||
if s: shapes.append(s)
|
||||
|
|
Loading…
Reference in New Issue
Block a user