svg - Inkscape CLI FileRevert 在 1.1 或 1.2 中不起作用,尝试刷新 Inkscape GUI

标签 svg inkscape

我正在开发一个使用 inkscape 来操作 SVG 的 SVG 动画工具,我需要更新 inkscape 以显示动画 SVG 的选定状态,以便让用户进行更改(它是一个外部工具而不是插件) )。

例如:一个矩形从 x:100 到 x:300,当矩形位于 x:200 时用户暂停动画,然后该工具用 x:200 保存 SVG 状态,唯一的问题是 inkscape 是没有刷新,所以我需要关闭然后打开 inkscape,或者手动转到"file">“恢复”。

我一直在调查,发现有一个名为 FileRevert 的动词(在 1.2 中删除动词之前),我尝试使用版本 1.1 并使用 inkscape GUI 打开此命令:

inkscape --verb FileRevert test.svg

这是命令的完整输出:(完整日志在最后)

user@user:~/Desktop$ ./ink2.AppImage --verb FileRevert test.svg

WARNING: ignoring verb FileRevert - GUI required for this verb.

** (org.inkscape.Inkscape:6946): CRITICAL **: 08:40:38.988: static void Inkscape::FileVerb::perform(SPAction*, void*): assertion 'ensure_desktop_valid(action)' failed

所以错误似乎是没有检测到 GUI,如果我必须告诉 cli GUI 在哪里或从 GUI 打开 inkscape,我不知道,但我尝试了这个,终端被阻止,直到您关闭 inkscape。

然后我尝试使用 inkscape 1.2 操作,因为文档说所有动词都可以用作操作:

enter image description here

但是 --action-list 中没有 FileRevert 操作,并且在 1.2 发行说明中也没有有关 FileRevert 弃用的信息,因此很难猜测发生了什么。

这是使用操作尝试 FileRevert 的输出:(完整日志在最后)

user@user:~/Desktop$ ./ink.AppImage --actions="FileRevert" test.svg

InkscapeApplication::parse_actions: could not find action for: FileRevert

因此,它似乎无法找到 FileRevert 操作,这可能意味着它不受支持或已弃用。

我正在使用 linux mint,以防万一。

欢迎任何帮助,或者解决我的问题的任何替代解决方案... atm 我正在考虑非常糟糕的替代方案,例如每次您想要刷新时自动关闭并重新打开 inkscape,或者选择 inkscape 窗口并触发热键来恢复文件。

谢谢!

完整日志 1.1 动词 try:

  user@user:~/Desktop$ ./ink2.AppImage --verb FileRevert test.svg
        Setting _INKSCAPE_GC=disable as a workaround for broken libgc
        Gtk-Message: 08:40:38.030: Failed to load module "xapp-gtk3-module"
        
        ** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="">: CSS Style property: "stroke-width" with default value (1) not needed.
        
        ** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
        
        ** (org.inkscape.Inkscape:6946): WARNING **: 08:40:38.964: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
    
        WARNING: ignoring verb FileRevert - GUI required for this verb.
        
        ** (org.inkscape.Inkscape:6946): CRITICAL **: 08:40:38.988: static void Inkscape::FileVerb::perform(SPAction*, void*): assertion 'ensure_desktop_valid(action)' failed

完整日志 1.2 操作尝试:

user@user:~/Desktop$ ./ink.AppImage --actions="FileRevert" test.svg
    Setting _INKSCAPE_GC=disable as a workaround for broken libgc
    Gtk-Message: 08:49:36.363: Failed to load module "xapp-gtk3-module"
    InkscapeApplication::parse_actions: could not find action for: FileRevert
    
    ** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.377: <svg:rect id="">: CSS Style property: "stroke-width" with default value (1) not needed.
    
    ** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.377: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.
    
    ** (org.inkscape.Inkscape:7139): WARNING **: 08:49:37.378: <svg:rect id="rect786">: CSS Style property: "stroke-width" with default value (1) not needed.

编辑:该工具在 Inkscape 中工作和更新的演示: https://www.youtube.com/watch?v=fDAIVKd19YU

最佳答案

Inkscape 1.2.x 及以上版本似乎未实现 file_revert 操作。查看问题here .

但是,我建议使用 dbus反而。以下是在运行 inkscape 时如何使用 dbus 恢复文档的示例:

gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.Activate document-revert [] {}

要获取可以通过 dbus 调用的操作列表,请运行以下命令:

gdbus call --session --dest org.inkscape.Inkscape --object-path /org/inkscape/Inkscape/window/1 --method org.gtk.Actions.List

除了终端之外,您还可以在 C++、Python 等代码上使用 dbus。有关绑定(bind)列表,请参阅:here .

关于svg - Inkscape CLI FileRevert 在 1.1 或 1.2 中不起作用,尝试刷新 Inkscape GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74037708/

相关文章:

javascript canvas pie loader加载时暂停

twitter-bootstrap - 是否可以将 Bootstrap Glyphicons svg 文件加载到 Inkscape 中?

pdf - 如何以编程方式将包含文本的 SVG 文件转换为 PDF 文件(特别是在 CentOS 5.3 x86_64 上)?

perl - 从 perl 使用 Inkscape shell

javascript - 如何修复集群捆绑图中的缩放和平移?

javascript - 创建三 Angular 菜单

xml - 如何在 xmlstarlet 中声明 XPath 命名空间?

javascript - 无法使用 Raphael 为 SVG 矩形的不透明度设置动画

svg - 如何在 Inkscape 中强制将字形转换为嵌入的矢量路径

python - 通过 Python 脚本向 Inkscape 中的对象添加节点