Getting object label/id in C++ code.

Discussion about writing code for Inkscape.
StoryTime
Posts: 2
Joined: Thu Jun 02, 2011 9:27 pm

Getting object label/id in C++ code.

Postby StoryTime » Thu Jun 02, 2011 9:33 pm

Hi!

I'm new to this forum, hope this is a good place to ask:

I'm writing a Live Path Effect. In the effect code, I need to get the label and/or id (the values you see in the Object Properties dialog) of the path object to which the effect is being applied. I tried this:

LivePathEffectObject *myLPE = (LivePathEffectObject*)this->getLPEObj();
myLPE->defaultLabel();

... but of course this gets me the label of the path effect, not the path.

Any suggesitons welcome...

StoryTime
Posts: 2
Joined: Thu Jun 02, 2011 9:27 pm

Re: Getting object label/id in C++ code.

Postby StoryTime » Fri Jun 03, 2011 9:00 pm

Got the answer courtesy of Johan via the inkscape-devel mailing list (Thanks Johan!). Will post here in case it helps anyone else:

By design, LPEs do not know about SVG objects and all that. An LPE just receives a path (the actual path data only) and should output a path.However, a trick was implemented to allow for some special LPEs that need a bit more information. Have a look at Effect::doBeforeEffect, which is called before doEffect and receives the item on which the LPE is applied (LPEBendPath uses it for example). Careful though: test whether your stuff works when the LPE is applied on a group!-


Return to “Programming”