Hide Unhide Specif Layer from Python Extension

Discussion about writing code for Inkscape.
shababhsiddique
Posts: 1
Joined: Sat Aug 03, 2013 2:57 pm

Hide Unhide Specif Layer from Python Extension

Postby shababhsiddique » Sat Aug 03, 2013 3:06 pm

Hi

I am new to scripting inkscape extension. I have so far covered the basics and created a working hello world example. I cant find a good resource/documentation where i can find full list of available functions that i can use from python in extensions. So i am posting here for your help. If you guys can point me to such resource it would be great as well.

I am trying to build an extension to hide/unhide specific layers(layers have specific names) from my extension. I have no clue about how to proceed. Are there any function like-

# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()

#get layer by name and hide it ??
svg.getLayerByName("Name_of_layer").hide() <<< ???? :idea:


Thanks in advance. I really appreciate your time to read this out.

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Hide Unhide Specif Layer from Python Extension

Postby hulf2012 » Sat Aug 10, 2013 1:00 pm

Hello,
I'm also interested in learn more about the extensions. And it's hard for me to explain what you have to do to reach the goal that you want:
Have you read this?:
http://wiki.inkscape.org/wiki/index.php/Script_extensions
http://wiki.inkscape.org/wiki/index.php/Generating_objects_from_extensions
http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial

Also, pay attention to this

Code: Select all

<g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     style="display:none" />
  <g
     inkscape:groupmode="layer"
     id="layer2"
     inkscape:label="Layer 2"
     style="display:inline"
/>


Hence, in your code you have to have a string variable with the value"display:none", and add that string to the style atribute of the layer

The implementation depends of you
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.


Return to “Programming”