Inkscape.org
Creating New Extensions Running extension effect() insider another extension.
  1. #1
    DrQt DrQt @DrQt

    Hi,

    I know I can import other extension scripts.

    I'm struggling to call the imported extension effect() function on. 

    def incadiff_panes(self, pane_):
    	import incadiff
    	diff_layer = self.svg.add(Layer.new('DIFF'))
    	diff_ = []
    	for pane in pane_:
    		diff_shape         = pane['shape'].copy()
    		diff_shape.label   = diff_shape.label + '_DIFF'
    		diff_layer.add(diff_shape)
    		pane['shape_diff'] = diff_shape
    		diff_.append(diff_shape)
    	# select shapes in list and run incadiff on them?
    	id_list = [d.get_id() for d in diff_]
    	# inkex.errormsg(id_list)
    	selection = self.svg.selection
    	# selection.set(id_list[0],id_list[1])
    	selection.clear()
    	for id in id_list:
    		selection.add(id)
    
    	inca = incadiff.IncadiffExtension(self)

    Throws

    AttributeError: module 'incadiff' has no attribute 'IncadiffExtension'

     

  2. #2
    DrQt DrQt @DrQt

    I see examples of  scripts that import pathmodifier, and then inherit it in the main class.

    Feels like the wrong thing, but maybe the only way?

    I’ll try to get it going with the CLI actions first. 

  3. #3
    DrQt DrQt @DrQt

    I see examples of  scripts that import pathmodifier, and then inherit it in the main class.

    Feels like the wrong thing, but maybe the only way?

    I’ll try to get it going with the CLI actions first. 

  4. #4
    DrQt DrQt @DrQt

    I realized I can inherit the classes of the two extensions I'm hoping to use within my script.

    Trying it tonight.

    The expectation is that all the effect functions shadow each other, but any other methods are available?

  5. #5
    Gavin Johnson Gavin Johnson @snow6oy

    I think the idea is to inherit from inkex and then implement your logic by overriding the effect() function.

    class Incadiff(inkex.EffectExtension):
      def effect(self):
        elem = self.svg.selection
        # add your effect here 
    
        

     

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Running extension effect() insider another extension.