SVG export woes

Issues:

  1. Resulting SVG has geometry cut off on the sides.
  2. It breaks Model space display where to restore it I have to switch my view to any Paper space tab and back to Model space. Or restart Rhino.

Input:

SVG:

import rhinoscriptsyntax as rs
import scriptcontext as sc

objs = rs.GetObjects("Pick something")
rs.SelectObjects(objs)
sc.doc.Views.ActiveView.ActiveViewport.ZoomExtentsSelected()
sc.doc.ExportSelected(rs.WorkingFolder() + "/test.svg")

SVG test.3dm (130.0 KB)

Rhino 7 SR14 2021-12-14 (Rhino 7, 7.14.21348.13001, Git hash:master @ 5ab502b613f84488d00228948505c6f28ebfe598)
License type: Commercial, build 2021-12-14
License details: LAN Zoo Network Node

Windows 10.0.19042 SR0.0 or greater (Physical RAM: 64Gb)

Computer platform: LAPTOP - Plugged in [100% battery remaining]

Non-hybrid graphics configuration.
Primary display and OpenGL: NVIDIA Quadro RTX 3000 (NVidia) Memory: 6GB, Driver date: 4-5-2021 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 462.30
> Integrated accelerated graphics device with 4 adapter port(s)
- Windows Main Display is laptop’s integrated screen or built-in port

Secondary graphics devices.
DisplayLink USB Device (DisplayLink) Memory: 0MB, Driver date: 4-16-2020 (M-D-Y).
> External USB display device with 3 adapter port(s)
- Secondary monitor attached to adapter port #0
DisplayLink USB Device (DisplayLink) Memory: 0MB, Driver date: 4-16-2020 (M-D-Y).
> External USB display device with 0 adapter port(s)
- There are no monitors attached to this device. Laptop lid is probably closed
DisplayLink USB Device (DisplayLink) Memory: 0MB, Driver date: 4-16-2020 (M-D-Y).
> External USB display device with 0 adapter port(s)
- There are no monitors attached to this device. Laptop lid is probably closed
DisplayLink USB Device (DisplayLink) Memory: 0MB, Driver date: 4-16-2020 (M-D-Y).
> External USB display device with 0 adapter port(s)
- There are no monitors attached to this device. Laptop lid is probably closed
Intel(R) UHD Graphics (Intel) Memory: 1GB, Driver date: 6-1-2021 (M-D-Y).
> Integrated graphics device with 3 adapter port(s)
- Secondary monitor is laptop’s integrated screen or built-in port

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: None
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 4-5-2021
Driver Version: 27.21.14.6230
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 6 GB

Rhino plugins that do not ship with Rhino

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Commands.rhp “Commands” 7.14.21348.13001
C:\Program Files\Rhino 7\Plug-ins\WebBrowser.rhp “WebBrowser”
C:\Program Files\Rhino 7\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7\Plug-ins\RPC.rhp “RPC”
C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.14.21348.13001
C:\Program Files\Rhino 7\Plug-ins\RhinoRender.rhp “Legacy Rhino Render”
C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.14.21348.13001
C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.14.21348.13001
C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.14.21348.13001
C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp “Displacement”

#1 issue only happens with the very first export. And exporting other geometry from different location and coming back to re-export the first set of geometry works as a workaround.

    svg_fix = Rhino.DocObjects.ObjRef(sc.doc.Objects.AddPoint(Rhino.Geometry.Point3d(0, 0, 0))).Object()
    svg_fix.Select(True)
    sc.doc.ExportSelected(rel_path + "fix.svg")
    os.remove(rel_path + "fix.svg")
    sc.doc.Objects.Delete(svg_fix, True)

#2 issue is fixed by:

    display_fix = sc.doc.Views.AddPageView("hi", 36, 24)
    sc.doc.Views.ActiveView = display_fix
    sc.doc.Views.ActiveView = model_space
    display_fix.Close()

While we’re at this, is there a way to control linework thickness in SVG? 'cause it’s not the same as PDF.

I would recommend using the ViewCaptureSettings class to control the aspects of generating SVGs instead of calling ExportSelected and depending on previous SVG export settings.

1 Like

^ That’s so much better. Though just noticed arrowheads don’t get exported. :cry:

Can we do something with this, so I don’t have to use Rhino command with bunch of text output in the command line, Steve?

Rhino.RhinoApp.RunScript("-_Export " + chr(34) + dwg_file + chr(34) + " Scheme " + chr(34) + "2007 Natural" + chr(34) + " _Enter", False)

Supporting options on import and export without using RunScript is a large project that we are hoping to work on in Rhino 8.

1 Like