hi,
inkscape v1.4
how (with a .py extension) do i apply path effects ?more specifically - add new offset effect with 2.22mm offset.
plus - how do i change an already existing path effect?
TNX
import inkex from uuid import uuid4 # Make LPE class class LpeTemplate(inkex.BaseElement): tag_name = 'inkscape:path-effect' class LpeOffset(inkex.EffectExtension): def add_arguments(self, pars): pass def effect(self): pass selection_list = self.svg.selected if len(selection_list) < 1: inkex.errormsg('Please select at least one object') return offset_float_list = [10, 20, 30, 60] lpe_offset_attributes_dict = {'effect':'offset', #'id':'path-effect1', 'is_visible':'true', 'lpeversion':'1.3', 'linejoin_type':'miter', 'unit':'mm', 'offset':'1', 'miter_limit':'4', 'attempt_force_join':'false', 'update_on_knot_move':'false'} for offset_float in offset_float_list: current_lpe_offset = LpeTemplate() self.svg.defs.append(current_lpe_offset) for key, value in lpe_offset_attributes_dict.items(): current_lpe_offset.set(key, str(value)) current_lpe_offset.set('id', str(uuid4())) current_lpe_offset.set('offset', str(offset_float)) for selected in selection_list: duplicate_element = selected.duplicate() duplicate_element.set('inkscape:path-effect', f'#{current_lpe_offset.get_id()}') if __name__ == '__main__': LpeOffset().run()
What is required is a 'kick' to force the Inkscape main program to recalculate the offset LPE when the extension returns.
I found for the offset LPE .duplicate() seems to make this happen.
.duplicate()
It can also be done with a command call to rotate 90cw then 90ccw ( so no net effect ) however that is slower and more complex.
tnx...
i achieved this with simpler syntax:
effect = inkex.elements.PathEffect(effect="offset", id="path-effect3", is_visible="true", lpeversion="1.3", linejoin_type="miter", unit="mm", offset="0.4", miter_limit="4", attempt_force_join="false", update_on_knot_move="true")
self.svg.defs.add(effect) selected.set('inkscape:path-effect', effect.get_id(as_url = 1))
hi,
inkscape v1.4
how (with a .py extension) do i apply path effects ?
more specifically - add new offset effect with 2.22mm offset.
plus - how do i change an already existing path effect?
TNX
What is required is a 'kick' to force the Inkscape main program to recalculate the offset LPE when the extension returns.
I found for the offset LPE
.duplicate()
seems to make this happen.It can also be done with a command call to rotate 90cw then 90ccw ( so no net effect ) however that is slower and more complex.
tnx...
i achieved this with simpler syntax:
effect = inkex.elements.PathEffect(effect="offset",
id="path-effect3",
is_visible="true",
lpeversion="1.3",
linejoin_type="miter",
unit="mm",
offset="0.4",
miter_limit="4",
attempt_force_join="false",
update_on_knot_move="true")
self.svg.defs.add(effect)
selected.set('inkscape:path-effect', effect.get_id(as_url = 1))