This commit is contained in:
Mario Voigt 2021-10-17 23:24:32 +02:00
parent 2b8e15b3d7
commit 0d91114305
3 changed files with 130 additions and 110 deletions

View File

@ -20,7 +20,6 @@
<param name="creationunit" type="optiongroup" appearance="combo" gui-text="Creation Units"> <param name="creationunit" type="optiongroup" appearance="combo" gui-text="Creation Units">
<option value="mm">mm</option> <option value="mm">mm</option>
<option value="cm">cm</option> <option value="cm">cm</option>
<option value="m">m</option>
<option value="in">in</option> <option value="in">in</option>
<option value="pt">pt</option> <option value="pt">pt</option>
<option value="px">px</option> <option value="px">px</option>
@ -44,7 +43,6 @@
<param name="length_filter_unit" type="optiongroup" appearance="combo" gui-text="Length filter unit"> <param name="length_filter_unit" type="optiongroup" appearance="combo" gui-text="Length filter unit">
<option value="mm">mm</option> <option value="mm">mm</option>
<option value="cm">cm</option> <option value="cm">cm</option>
<option value="m">m</option>
<option value="in">in</option> <option value="in">in</option>
<option value="pt">pt</option> <option value="pt">pt</option>
<option value="px">px</option> <option value="px">px</option>

View File

@ -4,18 +4,20 @@
<id>fablabchemnitz.de.join_paths</id> <id>fablabchemnitz.de.join_paths</id>
<param name="tab" type="notebook"> <param name="tab" type="notebook">
<page name="subdividePath" gui-text="Join Paths / Create Tabs And Dimples"> <page name="subdividePath" gui-text="Join Paths / Create Tabs And Dimples">
<label appearance="header">Join Paths</label>
<param name="optimized" type="bool" gui-text="Optimized joining">true</param> <param name="optimized" type="bool" gui-text="Optimized joining">true</param>
<param name="margin" type="float" min="0.0001" max="99999.0000" precision="4" gui-text="Merge margin">0.0100</param> <param name="margin" type="float" min="0.0001" max="99999.0000" precision="4" gui-text="Merge margin">0.0100</param>
<label appearance="header">Create Tabs And Dimples</label> <label appearance="header">Create Tabs And Dimples</label>
<label>Enable to insert dimples (pressfit noses) into the gaps (instead regular straight lines)</label> <label>Enable to insert dimples (pressfit noses) into the gaps (instead regular straight lines)</label>
<param name="add_dimples" type="bool" gui-text="Create dimples">false</param> <param name="add_dimples" type="bool" gui-text="Create dimples">false</param>
<param name="dimples_to_group" type="bool" gui-text="Unify into single group">false</param>
<param name="dimple_type" type="optiongroup" appearance="combo" gui-text="Dimple type"> <param name="dimple_type" type="optiongroup" appearance="combo" gui-text="Dimple type">
<option value="peaks">peaks</option> <option value="peaks">peaks</option>
<option value="arcs">arcs</option> <option value="arcs">arcs</option>
<option value="tabs">tabs</option> <option value="tabs">tabs</option>
</param> </param>
<param name="draw_dimple_centers" type="bool" gui-text="Draw dimple centers">false</param> <param name="draw_dimple_centers" type="bool" gui-text="Draw dimple centers">false</param>
<param name="dimple_invert" type="bool" gui-text="Invert dimples">false</param> <param name="dimple_invert" type="bool" gui-text="Invert dimple sides">false</param>
<param name="draw_both_sides" type="bool" gui-text="Draw both sides">false</param> <param name="draw_both_sides" type="bool" gui-text="Draw both sides">false</param>
<param name="dimple_height_mode" type="optiongroup" appearance="combo" gui-text="Height by ..."> <param name="dimple_height_mode" type="optiongroup" appearance="combo" gui-text="Height by ...">
<option value="by_height">by height</option> <option value="by_height">by height</option>
@ -31,7 +33,17 @@
<option value="pt">pt</option> <option value="pt">pt</option>
<option value="px">px</option> <option value="px">px</option>
</param> </param>
<param name="dimples_to_group" type="bool" gui-text="Unify into single group">false</param> <label appearance="header">Dimple gap filter</label>
<param name="dimple_gap_filter" type="bool" gui-text="Apply min/max filter">false</param>
<param name="dimple_min_gap" type="float" min="0.000" max="99999.000" precision="3" gui-text="Min">1</param>
<param name="dimple_max_gap" type="float" min="0.000" max="99999.000" precision="3" gui-text="Max">40</param>
<param name="dimple_gap_filter_units" gui-text="Filter units" type="optiongroup" appearance="combo">
<option value="mm">mm</option>
<option value="cm">cm</option>
<option value="in">in</option>
<option value="pt">pt</option>
<option value="px">px</option>
</param>
</page> </page>
<page name="desc" gui-text="Help"> <page name="desc" gui-text="Help">
<label xml:space="preserve">This effect joins the Bezier curves, with straight line segments. If the end nodes are close enough, they are merged into a single one. With the optimized option selected, the new curve starts from the top most curve from the selection. The curves are then joined based on the distance of their closest end point to the previous curve. <label xml:space="preserve">This effect joins the Bezier curves, with straight line segments. If the end nodes are close enough, they are merged into a single one. With the optimized option selected, the new curve starts from the top most curve from the selection. The curves are then joined based on the distance of their closest end point to the previous curve.

View File

@ -134,11 +134,18 @@ class JoinPaths(inkex.EffectExtension):
pars.add_argument("--dimple_height", type=float, default=4) pars.add_argument("--dimple_height", type=float, default=4)
pars.add_argument("--dimple_angle", type=float, default=45) pars.add_argument("--dimple_angle", type=float, default=45)
pars.add_argument("--dimple_tab_angle", type=float, default=45) pars.add_argument("--dimple_tab_angle", type=float, default=45)
pars.add_argument("--dimple_gap_filter", type=inkex.Boolean, default=False)
pars.add_argument("--dimple_min_gap", type=float, default=1)
pars.add_argument("--dimple_max_gap", type=float, default=40)
pars.add_argument("--dimple_gap_filter_units", default="mm")
pars.add_argument("--dimple_height_units", default="mm") pars.add_argument("--dimple_height_units", default="mm")
pars.add_argument("--tab", default="sampling", help="Tab") pars.add_argument("--tab", default="sampling", help="Tab")
def effect(self): def effect(self):
selections = self.svg.selected selections = self.svg.selected
if len(self.svg.selected) == 0:
self.msg('Please select some paths first.')
return
pathNodes = self.document.xpath('//svg:path',namespaces=inkex.NSS) pathNodes = self.document.xpath('//svg:path',namespaces=inkex.NSS)
paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes } paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes }
#paths.keys() Order disturbed #paths.keys() Order disturbed
@ -191,13 +198,16 @@ class JoinPaths(inkex.EffectExtension):
dx2 = p2[0]-p1[0] dx2 = p2[0]-p1[0]
dy2 = p2[1]-p1[1] dy2 = p2[1]-p1[1]
dist2 = math.sqrt(dx2*dx2 + dy2*dy2) dist2 = math.sqrt(dx2*dx2 + dy2*dy2)
if dx2 == 0: if dx2 == 0:
slope=sys.float_info.max #vertical slope=sys.float_info.max #vertical
else: else:
slope=(p2[1] - p1[1]) / dx2 slope=(p2[1] - p1[1]) / dx2
slope_angle = 90 + math.degrees(math.atan(slope)) slope_angle = 90 + math.degrees(math.atan(slope))
if (self.options.dimple_gap_filter is True \
and dist2 >= self.svg.unittouu(str(self.options.dimple_min_gap) + self.options.dimple_gap_filter_units) \
and dist2 < self.svg.unittouu(str(self.options.dimple_max_gap) + self.options.dimple_gap_filter_units)
) \
or self.options.dimple_gap_filter is False:
if self.options.dimple_height_mode == "by_height": if self.options.dimple_height_mode == "by_height":
dimple_height = self.svg.unittouu(str(self.options.dimple_height) + self.options.dimple_height_units) dimple_height = self.svg.unittouu(str(self.options.dimple_height) + self.options.dimple_height_units)
else: else: