Skip to content

Commit 3787909

Browse files
author
Jürgen Weigert
committed
V0.24: Renamed Height to Zsize, Raise to Zoffset
1 parent 9f12fbe commit 3787909

File tree

3 files changed

+56
-47
lines changed

3 files changed

+56
-47
lines changed

paths2openscad-de.inx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<param type="string" name="fname" gui-text="Ausgabedatei" xml:lang="de">{NAME}.scad</param>
1616
<_param name="fname_help" type="description" xml:lang="de">Mit '{NAME}.scad' wird der Name vom svg übernommen.</_param>
1717

18-
<param type="float" precision="2" name="height" min="0" max="1000" gui-text="Höhe [mm]" xml:lang="de">5.0</param>
19-
<param type="description" name="height_help" xml:lang="de">Vorgegebene Höhe der 3D-Extrusion (wenn keine Höhe im SVG-Objekt steht).</param>
18+
<param type="float" precision="2" name="zsize" min="0" max="1000" gui-text="Höhe [mm]" xml:lang="de">5.0</param>
19+
<param type="description" name="zsize_help" xml:lang="de">Vorgegebene Höhe der 3D-Extrusion (wenn keine Höhe im SVG-Objekt steht).</param>
2020

2121
<param type="boolean" name="parsedesc" gui-text="Beschreibung Auslesen" xml:lang="de">true</param>
2222
<param type="description" name="parsedesc_help" xml:lang="de">Lese die extrudierte Höhe, Boden und Skalierung pro SVG-Objekt aus dessen Beschreibung oder ID. Siehe auch den Reiter Extrusion-Syntax.</param>
@@ -90,11 +90,13 @@ das Objekt "Antimaterie". D.h. es wird von allen normalen
9090
Objekten weggeschnitten (subtrahiert).
9191
</param>
9292
<param type="description" name="extrusion_2" appearance="header" xml:lang="de">Syntax in der Objekteigenschaft Beschreibung</param>
93-
<param xml:space="preserve" type="description" name="extrusion_3" xml:lang="de">Height: 10 mm oder Height: a12.3 mm
94-
Höhe der linearen Extrusion des Objekts. Die Höhe zeigt
93+
<param xml:space="preserve" type="description" name="extrusion_3" xml:lang="de">Zsize: 10 mm
94+
Länge der linearen Extrusion des Objekts. Die Länge zeigt
9595
nach oben, auch für "Antimaterie".
9696

97-
Raise: 4.5 mm
97+
Antimatter: true
98+
99+
Zoffset: 4.5 mm
98100
Hebt das Objekt an, um Balkone (oder Fenster) zu erzeugen.
99101

100102
Scale: 90 % oder Scale: 120,60 %
@@ -123,7 +125,7 @@ umgerechnet: 96 px = 1 inch = 25.4 mm.
123125
(Vor inkscape 0.92 war der Standard 90 px pro inch,
124126
Adobe Produkte verwenden oft 75 px pro inch)
125127

126-
v0.23
128+
v0.24
127129
Dan Newman (dan newman @ mtbaldy us)
128130
Josef Skladanka (jskladan @ redhat com)
129131
Juergen Weigert (juergen @ fabmail org)

paths2openscad.inx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<param name="fname" type="string" _gui-text="Output file">{NAME}.scad</param>
1616
<_param name="fname_help" type="description">Use '{NAME}.scad' here to use the name from svg.</_param>
1717

18-
<param name="height" type="float" min="0" max="1000" precision="2" _gui-text="Height [mm]">5.0</param>
19-
<_param name="height_help" type="description">Default 3D extrude height (when no height is parsed from an svg object).</_param>
18+
<param name="zsize" type="float" min="0" max="1000" precision="2" _gui-text="Z-Size [mm]">5.0</param>
19+
<_param name="zsize_help" type="description">Default 3D extrude length (when no zsize is parsed from an svg object).</_param>
2020

2121
<param name="parsedesc" type="boolean" _gui-text="Description parsing">true</param>
22-
<_param name="parsedesc_help" type="description">Read the extruded height, raise, scale per svg object from its description or ID. See the Extrusion Syntax tab for details.</_param>
22+
<_param name="parsedesc_help" type="description">Read the extruded zsize, zoffset, scale per svg object from its description or ID. See the Extrusion Syntax tab for details.</_param>
2323
<_param name="spacer" type="description"><!-- --></_param>
2424

2525
<param name="scadview" type="boolean" _gui-text="View in OpenSCAD">false</param>
@@ -83,27 +83,29 @@ Mac: /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD</_param>
8383
</page>
8484

8585
<page name="extrusion" _gui-text="Extrusion Syntax">
86-
<_param name="extrusion_1" type="description" xml:space="preserve">The height and other parameters can be defined through an svg object's description label or id. The menu 'Object-&gt;Objects ...' shows an overview of all, the menu 'Object-&gt;Object Properties ...' (Shift-Ctrl-O) shows details of one selected object.
86+
<_param name="extrusion_1" type="description" xml:space="preserve">The zsize and other parameters can be defined through an svg object's description label or id. The menu 'Object-&gt;Objects ...' shows an overview of all, the menu 'Object-&gt;Object Properties ...' (Shift-Ctrl-O) shows details of one selected object.
8787

8888
If an object's ID is in either name_XXX_mm or name_XXXmm
89-
format, then XXX is translated into height in millimeters.
89+
format, then XXX is translated into zsize in millimeters.
9090
Use . or _ as separator for a decimal number.
9191
Note that all whitespace or comma are saved as '_' in ID.
9292

93-
If the height is prefixed with a letter 'a', the
93+
If the zsize is prefixed with a letter 'a', the
9494
object is "anti-matter", it is cut away (subtracted)
9595
from all normal objects.
9696
</_param>
9797
<_param name="extrusion_2" type="description" appearance="header">Syntax for the object property description</_param>
98-
<_param name="extrusion_3" type="description" xml:space="preserve">Height: 10 mm or Height: a12.3 mm
99-
Linear extrusion height of the object. Note that the
100-
height always counts upwards, even for "anti-matter".
98+
<_param name="extrusion_3" type="description" xml:space="preserve">Zsize: 10 mm
99+
Linear extrusion length of the object. Note that the
100+
zsize always counts upwards, even for "anti-matter".
101101

102-
Raise: 4.5 mm
102+
Antimatter: true
103+
104+
Zoffset: 4.5 mm
103105
Move an object upwards to create a balcony (or window).
104106

105107
Scale: 90 % or Scale: 120,60 %
106-
Taper the object along its height. The bottom surface always
108+
Taper the object along its zsize. The bottom surface always
107109
is as drawn, but the top surface is scaled to this value.
108110
If two values are given (separated by Komma), different scaling
109111
applies along X- and Y-axis.
@@ -125,7 +127,7 @@ definition of 96 px = 1 inch = 25.4 mm.
125127
(Before inkscape 0.92 the standard was 90 px per inch,
126128
Adobe products often use 75 px per inch)
127129

128-
v0.23
130+
v0.24
129131
Dan Newman (dan newman @ mtbaldy us)
130132
Josef Skladanka (jskladan @ redhat com)
131133
Juergen Weigert (juergen @ fabmail org)

paths2openscad.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# 0.12 parse svg width="400mm" correctly. Came out downscaled by 3...
2424
#
2525
# 2017-04-08, [email protected]
26-
# 0.13 allow letter 'a' prefix on height values for anti-matter.
26+
# 0.13 allow letter 'a' prefix on zsize values for anti-matter.
2727
# All anti-matter objects are subtracted from all normal objects.
2828
# raise: Offset along Z axis, to make cut-outs and balconies.
2929
# Refactored object_merge_extrusion_values() from convertPath().
@@ -53,7 +53,7 @@
5353
# value for explicit Y scaling. Renamed the autoheight command line
5454
# option to 'parsedesc' with default true. Renamed dict auto to
5555
# extrusion. Rephrased all prose to refer to extrusion syntax rather
56-
# than auto height.
56+
# than auto zsize.
5757
# 2017-06-18, [email protected]
5858
# 0.18 pep8 relaxed. all hard 80 cols line breaks removed.
5959
# Refactored the commands into a separate tab in the inx.
@@ -76,6 +76,9 @@
7676
# 0.23 fixed rect with x=0 not rendered.
7777
# FIXME: should really use inksvg.py here too!
7878
#
79+
# 2018.09-09, [email protected]
80+
# 0.24 merged module feature, renamed Heigh,Raise to Zsize,Zoffset
81+
#
7982
# CAUTION: keep the version numnber in sync with paths2openscad.inx about page
8083

8184
# This program is free software; you can redistribute it and/or modify
@@ -108,12 +111,14 @@
108111

109112
DEFAULT_WIDTH = 100
110113
DEFAULT_HEIGHT = 100
111-
# Parse all these as 56.7 mm height:
114+
# Parse all these as 56.7 mm zsize:
112115
# "path1234_56_7_mm", "pat1234____57.7mm", "path1234_57.7__mm"
113-
RE_AUTO_HEIGHT_ID = re.compile(r".*?_+([aA]?\d+(?:[_\.]\d+)?)_*mm$")
114-
RE_AUTO_HEIGHT_DESC = re.compile(r"^(?:ht|[Hh]eight):\s*([aA]?\d+(?:\.\d+)?) ?mm$", re.MULTILINE)
115-
RE_AUTO_SCALE_DESC = re.compile(r"^(?:sc|[Ss]cale):\s*(\d+(?:\.\d+)?(?: ?, ?\d+(?:\.\d+)?)?) ?%$", re.MULTILINE)
116-
RE_AUTO_RAISE_DESC = re.compile(r"^(?:[Rr]aise|[Oo]ffset):\s*(\d+(?:\.\d+)?) ?mm$", re.MULTILINE)
116+
#
117+
# the verbs Height and Raise are deprecated. Use Zsize and Zoffset instead.
118+
RE_AUTO_ZSIZE_ID = re.compile(r".*?_+([aA]?\d+(?:[_\.]\d+)?)_*mm$")
119+
RE_AUTO_ZSIZE_DESC = re.compile(r"^(?:[Hh]eight|[Zz]size):\s*([aA]?\d+(?:\.\d+)?) ?mm$", re.MULTILINE)
120+
RE_AUTO_SCALE_DESC = re.compile(r"^(?:sc|[Ss]cale):\s*(\d+(?:\.\d+)?(?: ?, ?\d+(?:\.\d+)?)?) ?%$", re.MULTILINE)
121+
RE_AUTO_ZOFFSET_DESC = re.compile(r"^(?:[Rr]aise|[Zz]offset):\s*(\d+(?:\.\d+)?) ?mm$", re.MULTILINE)
117122
DESC_TAGS = ['desc', inkex.addNS('desc', 'svg')]
118123

119124
# CAUTION: keep these defaults in sync with paths2openscad.inx
@@ -382,8 +387,8 @@ def __init__(self):
382387
help='Curve smoothing (less for more)')
383388

384389
self.OptionParser.add_option(
385-
'--height', dest='height', type='string', default='5', action='store',
386-
help='Height (mm)')
390+
'--zsize', dest='zsize', type='string', default='5', action='store',
391+
help='Z-size (mm)')
387392

388393
self.OptionParser.add_option(
389394
'--min_line_width', dest='min_line_width', type='float', default=float(1), action='store',
@@ -403,7 +408,7 @@ def __init__(self):
403408

404409
self.OptionParser.add_option(
405410
'--parsedesc', dest='parsedesc', type='string', default='true', action='store',
406-
help='Parse height and other parameters from object descriptions')
411+
help='Parse zsize and other parameters from object descriptions')
407412

408413
self.OptionParser.add_option(
409414
'--scadview', dest='scadview', type='string', default='false', action='store',
@@ -548,7 +553,7 @@ def getDocProps(self):
548553
# inkex.errormsg("switching to 96 dpi")
549554

550555
# BUGFIX https://github.com/fablabnbg/inkscape-paths2openscad/issues/1
551-
# get height and width after dpi. This is needed for e.g. mm units.
556+
# get zsize and width after dpi. This is needed for e.g. mm units.
552557
self.docHeight = self.getLength('height', DEFAULT_HEIGHT)
553558
self.docWidth = self.getLength('width', DEFAULT_WIDTH)
554559

@@ -689,28 +694,28 @@ def object_merge_extrusion_values(extrusion, node):
689694
# let the node override inherited values
690695
rawid = node.get('id', '')
691696
if rawid is not None:
692-
height = RE_AUTO_HEIGHT_ID.findall(rawid)
693-
if height:
694-
extrusion['height'] = height[-1].replace("_", ".")
697+
zsize = RE_AUTO_ZSIZE_ID.findall(rawid)
698+
if zsize:
699+
extrusion['zsize'] = zsize[-1].replace("_", ".")
695700
# let description contents override id contents.
696701
for tagname in DESC_TAGS:
697702
desc_node = node.find("./%s" % tagname)
698703
if desc_node is not None:
699-
height = RE_AUTO_HEIGHT_DESC.findall(desc_node.text)
700-
if height:
701-
extrusion['height'] = height[-1]
704+
zsize = RE_AUTO_ZSIZE_DESC.findall(desc_node.text)
705+
if zsize:
706+
extrusion['zsize'] = zsize[-1]
702707
zscale = RE_AUTO_SCALE_DESC.findall(desc_node.text)
703708
if zscale:
704709
if ',' in zscale[-1]:
705710
extrusion['scale'] = '[' + zscale[-1] + ']'
706711
else:
707712
extrusion['scale'] = zscale[-1]
708-
zraise = RE_AUTO_RAISE_DESC.findall(desc_node.text)
709-
if zraise:
710-
extrusion['raise'] = zraise[-1]
711-
if extrusion['height'][0] in ('a', 'A'):
713+
zoffset = RE_AUTO_ZOFFSET_DESC.findall(desc_node.text)
714+
if zoffset:
715+
extrusion['zoffset'] = zoffset[-1]
716+
if extrusion['zsize'][0] in ('a', 'A'):
712717
extrusion['neg'] = True
713-
extrusion['height'] = extrusion['height'][1:]
718+
extrusion['zsize'] = extrusion['zsize'][1:]
714719
# END object_merge_extrusion_values
715720

716721
path = self.paths[node]
@@ -822,14 +827,14 @@ def object_merge_extrusion_values(extrusion, node):
822827
self.f.write(' scale([25.4/%g, -25.4/%g, 1]) union()\n {\n' % (self.dpi, self.dpi))
823828

824829
# And add the call to the call list
825-
# Height is set by the overall module parameter
826-
# unless an extrusion height is parsed from the description or ID.
827-
extrusion = {'height': 'h', 'raise': '0', 'scale': 100.0, 'neg': False}
830+
# Z-size is set by the overall module parameter
831+
# unless an extrusion zsize is parsed from the description or ID.
832+
extrusion = {'zsize': 'h', 'zoffset': '0', 'scale': 100.0, 'neg': False}
828833
if self.options.parsedesc == 'true':
829834
object_merge_extrusion_values(extrusion, node)
830835

831836
call_item = 'translate ([0,0,%s]) poly_%s(%s, min_line_mm(%s), %s);\n' % (
832-
extrusion['raise'], id, extrusion['height'], stroke_width_mm, extrusion['scale'])
837+
extrusion['zoffset'], id, extrusion['zsize'], stroke_width_mm, extrusion['scale'])
833838

834839
if extrusion['neg']:
835840
self.call_list_neg.append(call_item)
@@ -1232,7 +1237,7 @@ def effect(self):
12321237
fudge = 0.1;
12331238
''')
12341239
# writeout users parameters
1235-
self.f.write('height = %s;\n' % (self.options.height))
1240+
self.f.write('zsize = %s;\n' % (self.options.zsize))
12361241
self.f.write('line_fn = %d;\n' % (self.options.line_fn))
12371242
self.f.write('min_line_width = %s;\n' % (self.options.min_line_width))
12381243
self.f.write('function min_line_mm(w) = max(min_line_width, w) * %g/25.4;\n\n' % self.dpi)
@@ -1259,9 +1264,9 @@ def effect(self):
12591264

12601265
# The module that calls all the other ones.
12611266
if self.options.stlmodule == 'true':
1262-
self.f.write('}\n\n//%s(height);\n' % (name))
1267+
self.f.write('}\n\n//%s(zsize);\n' % (name))
12631268
else:
1264-
self.f.write('}\n\n%s(height);\n' % (name))
1269+
self.f.write('}\n\n%s(zsize);\n' % (name))
12651270
self.f.close()
12661271

12671272
except IOError as e:

0 commit comments

Comments
 (0)