Inkscape扩展脚本入门

Inkscape官网

https://inkscape.org/

建议下载1.3版本

官方插件脚本文档

https://inkscape-extensions-guide.readthedocs.io/en/latest/index.html

但这个文档似乎和当前版本不符合,直接按照其内的方法写脚本会有问题

Inkscape插件加载目录

默认情况下,插件加载目录为

C:\User\用户名\AppData\Roaming\inkscape\extensions

也可以通过菜单、编辑、首选项、系统,设置这个目录

 插件脚本

一个完整的Inkscape插件需要两个文件:*.inx、*.py,并且将这两个文件放到上面的目录,若格式正确,就能被加载出来,显示到扩展菜单下

以下为最基本的Hello World插件示例

hello_world.inx

<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">

<!-- 1. Replace this with the title of your extension. This will Show in the extensions menu-->
<_name>Hello World</_name>

<!-- 2. Fill this in. It ensures that your extension has a unique ID -->
<id>yourname.yourorganization.title</id>

<!-- 3. Show the relative path to your extension. For example, `~/.config/inkscape/extensions/template.py` would be `template.py`-->
<dependency type="file" location="inx">hello_world.py</dependency>
<!-- <dependency type="executable" location="extensions">inkex.py</dependency> -->

<effect>
    <object-type>all</object-type>
    <effects-menu>

    <!-- 4. Where is your extension located? (You can nest menus) -->
    <submenu _name="submenu"/>

    </effects-menu>
</effect>
<script>

    <!-- 5. Same as #4 -->
    <command location="inx" interpreter="python">hello_world.py</command>

</script>
</inkscape-extension>

hello_world.py

#!/usr/bin/env python
# coding=utf-8

import inkex

from inkex.elements import TextElement

class Greet(inkex.GenerateExtension):

    def generate(self):
		# return inkex.errormsg(_("Hello"))
        textElement = TextElement()
        textElement.text = 'Hello World'
        return textElement

if __name__ == '__main__':
    Greet().run()

若格式正确,加载之后就能在看到菜单、扩展、Hello World

执行后能看到文档内被新建一个文本

参考文档

https://pdfroom.com/books/inkscape-guide-to-a-vector-drawing-program-4th-edition/eKRd6xyo2Zp/download

https://inkscape-extensions-guide.readthedocs.io/en/latest/index.html

https://inkscape.org/forums/beyond/cannot-import-inkex/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装inkscape需要以下步骤: 1. 下载inkscape软件安装包并安装。根据系统版本选择下载适合的版本,如系统为win10 64bits,则下载对应的64位安装包。安装过程中,按照提示一步一步进行即可。 2. 安装latex环境。inkscape插件依赖于latex环境,因此需要先安装texlive或者miktex。根据个人喜好选择其中一个软件进行安装即可。 3. 安装其他必要的软件。安装inkscape插件还需要安装pstoedit和ghostscript软件。这两个软件可以在官方网站上下载安装。 4. 将二进制目录添加到环境变量。为了使inkscape在执行一些扩展时能够正确调用相关程序,需要将inkscape安装目录下的二进制目录添加到系统的环境变量中。具体操作可以参考系统的环境变量设置方法。 5. 下载并安装inkscape插件。可以从GitHub上搜索需要的插件,比如在https://github.com/fsmMLK可以找到很多inkscape插件。找到想要安装的插件页面后,下载对应的文件(通常是.inx和.py文件),然后将这两个文件复制到inkscape插件目录中。插件目录的路径通常是在C:\Program Files\Inkscape\share\extensions。 请按照以上步骤进行inkscape的安装和插件的安装,这样就可以开始使用inkscape进行绘图了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [inkscape推荐插件安装](https://blog.csdn.net/ouening/article/details/82928140)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值