Importer function issue with a loop #846
-
Good morning, However, when I try to create that function or even make a loop with
or
What to do ? def porte(largeur):
if largeur > 58 & largeur <= 68 :
largeur = 63
elif largeur > 68 & largeur <= 78 :
largeur = 73
elif largeur > 78 & largeur <= 88 :
largeur = 83
elif largeur > 88 & largeur <= 98 :
largeur = 93
#sdoc = ezdxf.readfile('P_' + largeur+'.dxf')
sdoc = ezdxf.readfile(f'P{largeur}_droite.dxf')
tdoc = ezdxf.new()
Importer = Importer(sdoc, tdoc)
# import all entities from source modelspace into modelspace of the target drawing
Importer.import_modelspace()
# import all paperspace layouts from source drawing
Importer.import_paperspace_layouts()
# import all CIRCLE and LINE entities from source modelspace into an arbitrary target layout.
# create target layout
tblock = tdoc.blocks.new('SOURCE_ENTS')
# query source entities
ents = sdoc.modelspace().query('CIRCLE LINE')
# import source entities into target block
Importer.import_entities(ents, tblock)
PORTE = tdoc.blocks.new(name='PORTE')
# ajouter des lignes
#line = P_83.add_line((0.83, 0), (24.31, 58.69))
# This is ALWAYS the last & required step, without finalizing the target drawing is maybe invalid!
# This step imports all additional required table entries and block definitions.
Importer.finalize()
tdoc.saveas(f'PORTE_{largeur}.dxf') |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Just don't redefine the def porte(largeur):
if largeur > 58 & largeur <= 68 :
largeur = 63
elif largeur > 68 & largeur <= 78 :
largeur = 73
elif largeur > 78 & largeur <= 88 :
largeur = 83
elif largeur > 88 & largeur <= 98 :
largeur = 93
sdoc = ezdxf.readfile(f'P{largeur}_droite.dxf')
tdoc = ezdxf.new()
### Don't redefine the Importer class!
importer = Importer(sdoc, tdoc)
importer.import_modelspace()
importer.import_paperspace_layouts()
tblock = tdoc.blocks.new('SOURCE_ENTS')
ents = sdoc.modelspace().query('CIRCLE LINE')
importer.import_entities(ents, tblock)
PORTE = tdoc.blocks.new(name='PORTE')
importer.finalize()
tdoc.saveas(f'PORTE_{largeur}.dxf') |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your early and efficient answer! It's gonna help me a lot :) |
Beta Was this translation helpful? Give feedback.
Just don't redefine the
Importer
class 😄: