fixes in dxf2papercraft
This commit is contained in:
parent
88eb5d0a89
commit
e6db17cdd3
0
extensions/fablabchemnitz/dxf2papercraft/debug.dat
Normal file
0
extensions/fablabchemnitz/dxf2papercraft/debug.dat
Normal file
4
extensions/fablabchemnitz/dxf2papercraft/delete_me_later
Normal file
4
extensions/fablabchemnitz/dxf2papercraft/delete_me_later
Normal file
@ -0,0 +1,4 @@
|
||||
#VRML V1.0 ascii
|
||||
|
||||
Separator {
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
<param name="number" type="bool" gui-text="Print face numbers (labels)" gui-description="Disable this if you want to split custom faces">false</param>
|
||||
<param name="divide" type="bool" gui-text="Draw each face separate">false</param>
|
||||
<param name="overlap" type="bool" gui-text="Allow overlapping faces in cut-out sheet">false</param>
|
||||
<param name="hide" type="bool" gui-text="Hide glue tabs">false</param>
|
||||
<param name="hide" type="bool" gui-text="Hide glue tabs. Does not work if 'Print face numbers (labels)' is activated">false</param>
|
||||
<param name="force" type="bool" gui-text="Force glue tabs, even if intersecting faces">false</param>
|
||||
<param name="split" type="string" gui-text="Comma separated list of face numbers to disconnect from the rest" gui-description="Enable face numbers tp have a view on it. If face number option is activated the splitting will not be performed!"></param>
|
||||
<param name="strategy" type="optiongroup" appearance="combo" gui-text="Generation strategy">
|
||||
|
@ -121,29 +121,28 @@ class PapercraftUnfold(inkex.EffectExtension):
|
||||
p = etree.XMLParser(huge_tree=True)
|
||||
doc = etree.parse(stream, parser=etree.XMLParser(huge_tree=True)).getroot()
|
||||
stream.close()
|
||||
doc.set('id', self.svg.get_unique_id('dxf2papercraft-'))
|
||||
self.document.getroot().append(doc)
|
||||
|
||||
#do some viewport adjustments
|
||||
doc.set('width','')
|
||||
doc.set('height','')
|
||||
doc.set('viewBox','')
|
||||
doc.getchildren()[1].set('transform','') #this removes the "transform:scale(1, -1)" from <svg:g id="draft"> child within dxf2papercraft-<id> group
|
||||
|
||||
|
||||
dxfGroup = inkex.Group(id=self.svg.get_unique_id("dxf2papercraft-"))
|
||||
for element in doc.iter("{http://www.w3.org/2000/svg}g"):
|
||||
if element.get('id') != "draft":
|
||||
dxfGroup.append(element)
|
||||
self.document.getroot().add(dxfGroup)
|
||||
|
||||
#apply scale factor
|
||||
node = doc.getchildren()[1]
|
||||
translation_matrix = [[self.options.scalefactor, 0.0, 0.0], [0.0, self.options.scalefactor, 0.0]]
|
||||
node.transform = Transform(translation_matrix) * node.transform
|
||||
dxfGroup.transform = Transform(translation_matrix) * dxfGroup.transform
|
||||
|
||||
#Adjust viewport and width/height to have the import at the center of the canvas
|
||||
if self.options.resizetoimport:
|
||||
bbox = inkex.elements._selected.ElementList.bounding_box(node)
|
||||
bbox = dxfGroup.bounding_box() #does not work. why?
|
||||
if bbox is not None:
|
||||
root = self.svg.getElement('//svg:svg');
|
||||
offset = self.svg.unittouu(str(self.options.extraborder) + self.options.extraborder_units)
|
||||
root.set('viewBox', '%f %f %f %f' % (bbox.left - offset, bbox.top - offset, bbox.width + 2 * offset, bbox.height + 2 * offset))
|
||||
root.set('width', bbox.width + 2 * offset)
|
||||
root.set('height', bbox.height + 2 * offset)
|
||||
else:
|
||||
self.msg("Error resizing to bounding box.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
PapercraftUnfold().run()
|
Reference in New Issue
Block a user