Inkscape: Unterschied zwischen den Versionen
Aus Vosp.info
F (Diskussion | Beiträge) |
F (Diskussion | Beiträge) |
||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
== extensions == | == extensions == | ||
− | === ancXmlAttribute: xml element um | + | === ancXmlAttribute: xml element um Attribut erweitern === |
− | diese extension ist Beispielhaft und minimal | + | '''was macht diese Extension und wodurch zeichnet sie sich aus''' |
+ | * diese extension ist Beispielhaft und minimal | ||
+ | * sie soll ein ausgewähltes Element einfach ein Attribut anfügen und einen übergebenen wert zuweisen | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | folgende links haben mir dabei geholfen | + | '''folgende links haben mir dabei geholfen''' |
+ | * [http://www.hoboes.com/Mimsy/hacks/write-inkscape-extension-create-multiple-duplicates/ Write an Inkscape extension: create multiple duplicates] | ||
* [http://docs.python.org/2/library/xml.etree.elementtree.html 19.7. xml.etree.ElementTree — The ElementTree XML API] | * [http://docs.python.org/2/library/xml.etree.elementtree.html 19.7. xml.etree.ElementTree — The ElementTree XML API] | ||
+ | * [http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial PythonEffectTutorial] | ||
+ | |||
+ | '''Installation''' | ||
+ | * damit sie läuft müssen folgende beiden Dateien in eines von den beiden Verzeichnissen kopiert werden | ||
+ | ** /usr/share/inkscape/extensions/ | ||
+ | ** .config/inkscape/extension/ | ||
+ | |||
==== ancXmlAttribute.inx ==== | ==== ancXmlAttribute.inx ==== | ||
Zeile 73: | Zeile 78: | ||
effect = C() | effect = C() | ||
effect.affect() | effect.affect() | ||
+ | </source> | ||
+ | |||
+ | === Element in Text und Bild umwandeln === | ||
+ | |||
+ | |||
+ | ==== ancXmlAttribute.inx ==== | ||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> | ||
+ | <_name>Objektzuordnung</_name> | ||
+ | <id>org.inkscape.serviceplusv3</id> | ||
+ | <dependency type="executable" location="extensions">inkex.py</dependency> | ||
+ | <param name="spv3kindof" type="enum" _gui-text="Objektart:"> | ||
+ | <_item value="">...</_item> | ||
+ | <_item value="text">Text</_item> | ||
+ | <_item value="image">Bild</_item> | ||
+ | <_item value="qrcode">qrcode</_item> | ||
+ | <_item value="calendar">Kalender</_item> | ||
+ | </param> | ||
+ | <effect> | ||
+ | <object-type>all</object-type> | ||
+ | <effects-menu> | ||
+ | <submenu _name="netz.coop"/> | ||
+ | </effects-menu> | ||
+ | </effect> | ||
+ | <script> | ||
+ | <command reldir="extensions" interpreter="python">serviceplusV3.py</command> | ||
+ | </script> | ||
+ | </inkscape-extension> | ||
+ | |||
+ | </source> | ||
+ | ==== ancXmlAttribute.py ==== | ||
+ | <source lang="python"> | ||
+ | #!/usr/bin/env python | ||
+ | |||
+ | import sys, copy | ||
+ | sys.path.append('/usr/share/inkscape/extensions') | ||
+ | import inkex | ||
+ | from simplestyle import * | ||
+ | |||
+ | class C(inkex.Effect): | ||
+ | def __init__(self): | ||
+ | inkex.Effect.__init__(self) | ||
+ | self.OptionParser.add_option( | ||
+ | "-s", | ||
+ | "--spv3kindof", | ||
+ | action="store", | ||
+ | type="string", | ||
+ | dest="spv3kindof", | ||
+ | default="text", | ||
+ | help="Objektart:" | ||
+ | ) | ||
+ | |||
+ | def effect(self): | ||
+ | if self.selected: | ||
+ | for id, node in self.selected.iteritems(): | ||
+ | if self.options.spv3kindof=='image': | ||
+ | node.tag = 'image' | ||
+ | XHTML_NAMESPACE = "http://www.w3.org/1999/xlink" | ||
+ | XHTML = "{%s}" % XHTML_NAMESPACE | ||
+ | node.set(XHTML+"href", "file:///home/neumann/.config/inkscape/extensions/serviceplusV3.png") | ||
+ | |||
+ | elif self.options.spv3kindof=='text': | ||
+ | rect = copy.deepcopy(node) | ||
+ | flowRoot = inkex.etree.Element('flowRoot') | ||
+ | flowRoot.set('style', 'font-size:16px;text-anchor:start;text-align:justify;') | ||
+ | flowRegion = inkex.etree.SubElement(flowRoot, 'flowRegion') | ||
+ | flowPara = inkex.etree.SubElement(flowRoot, 'flowPara') | ||
+ | flowPara.text = 'qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm' | ||
+ | flowRegion.append(rect) | ||
+ | self.current_layer.append(flowRoot) | ||
+ | #self.current_layer.remove(node) # loesche schablonen kasten | ||
+ | else: | ||
+ | node.set('serviceplusV3', self.options.spv3kindof) | ||
+ | node.set('ancObj', self.options.spv3kindof) | ||
+ | |||
+ | effect = C() | ||
+ | effect.affect() | ||
+ | |||
</source> | </source> |
Aktuelle Version vom 19. November 2013, 01:49 Uhr
Inhaltsverzeichnis
extensions
ancXmlAttribute: xml element um Attribut erweitern
was macht diese Extension und wodurch zeichnet sie sich aus
- diese extension ist Beispielhaft und minimal
- sie soll ein ausgewähltes Element einfach ein Attribut anfügen und einen übergebenen wert zuweisen
folgende links haben mir dabei geholfen
- Write an Inkscape extension: create multiple duplicates
- 19.7. xml.etree.ElementTree — The ElementTree XML API
- PythonEffectTutorial
Installation
- damit sie läuft müssen folgende beiden Dateien in eines von den beiden Verzeichnissen kopiert werden
- /usr/share/inkscape/extensions/
- .config/inkscape/extension/
ancXmlAttribute.inx
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>xml Attribute setzen</_name>
<id>org.inkscape.ancXmlAttribute</id>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="kindof" type="enum" _gui-text="Attribut Wert">
<_item value="">...</_item>
<_item value="text">Text</_item>
<_item value="image">Bild</_item>
<_item value="qrcode">qrcode</_item>
<_item value="calendar">Kalender</_item>
</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu _name="netz.coop"/>
</effects-menu>
</effect>
<script>
<command reldir="extensions" interpreter="python">ancXmlAttribute.py</command>
</script>
</inkscape-extension>
ancXmlAttribute.py
#!/usr/bin/env python
import sys
sys.path.append('/usr/share/inkscape/extensions')
import inkex
from simplestyle import *
class C(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option(
"-k",
"--kindof",
action="store",
type="string",
dest="kindof",
default="text",
help="spv3 Objektart:"
)
def effect(self):
if self.selected:
for id, node in self.selected.iteritems():
node.set('ancXmlAttribute', self.options.kindof)
effect = C()
effect.affect()
Element in Text und Bild umwandeln
ancXmlAttribute.inx
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Objektzuordnung</_name>
<id>org.inkscape.serviceplusv3</id>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="spv3kindof" type="enum" _gui-text="Objektart:">
<_item value="">...</_item>
<_item value="text">Text</_item>
<_item value="image">Bild</_item>
<_item value="qrcode">qrcode</_item>
<_item value="calendar">Kalender</_item>
</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu _name="netz.coop"/>
</effects-menu>
</effect>
<script>
<command reldir="extensions" interpreter="python">serviceplusV3.py</command>
</script>
</inkscape-extension>
ancXmlAttribute.py
#!/usr/bin/env python
import sys, copy
sys.path.append('/usr/share/inkscape/extensions')
import inkex
from simplestyle import *
class C(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option(
"-s",
"--spv3kindof",
action="store",
type="string",
dest="spv3kindof",
default="text",
help="Objektart:"
)
def effect(self):
if self.selected:
for id, node in self.selected.iteritems():
if self.options.spv3kindof=='image':
node.tag = 'image'
XHTML_NAMESPACE = "http://www.w3.org/1999/xlink"
XHTML = "{%s}" % XHTML_NAMESPACE
node.set(XHTML+"href", "file:///home/neumann/.config/inkscape/extensions/serviceplusV3.png")
elif self.options.spv3kindof=='text':
rect = copy.deepcopy(node)
flowRoot = inkex.etree.Element('flowRoot')
flowRoot.set('style', 'font-size:16px;text-anchor:start;text-align:justify;')
flowRegion = inkex.etree.SubElement(flowRoot, 'flowRegion')
flowPara = inkex.etree.SubElement(flowRoot, 'flowPara')
flowPara.text = 'qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm qqq www eee rrr ttt zzz uuu iii ooo ppp aaa sss ddd fff ggg hhh jjj kkk lll yyy xxx ccc vvv bbb nnn mmm'
flowRegion.append(rect)
self.current_layer.append(flowRoot)
#self.current_layer.remove(node) # loesche schablonen kasten
else:
node.set('serviceplusV3', self.options.spv3kindof)
node.set('ancObj', self.options.spv3kindof)
effect = C()
effect.affect()