Run a command within a headless RhinoDoc

By using Rhino inside CPython I have created a new headless RhinoDoc. Do anyone know how to execute a command within this RhinoDoc? For example something simple like ‘_-Line 0,0,0 10,0,0’?

Pål

That is definitely not possible at the moment. It is a good idea though so I added it to our wishlist at
https://mcneel.myjetbrains.com/youtrack/issue/RH-55034

2 Likes

Thank you for confirming. Is it then impossible to export the doc objects to another file format than 3dm? Or can it be done with other options?

Pål

There is a bug that is blocking this from working at the moment, but you should eventually be able to just use the Export function on RhinoDoc for this

import rhinoinside
import os
rhinoinside.load()
import Rhino

if __name__ == "__main__":
    doc = Rhino.RhinoDoc.CreateHeadless(None)
    doc.Import(os.path.join(os.getcwd(), 'test.3dm'))
    doc.Export(os.path.join(os.getcwd(), 'test.obj'))
1 Like

RH-55065 and RH-55034 are fixed in the latest WIP

2 Likes

After the latest fix, I have successfully created a line in a cpython rhino doc using runcript.

doc = Rhino.RhinoDoc.New(None)
Rhino.RhinoDoc.ActiveDoc = doc
Rhino.Commands.CommandStyleAttribute(2)
Rhino.RhinoApp.RunScript('_Line 0,0,0 10,10,10,',False)

I would now try to use the same functionality to export all objects to DWG

doc = Rhino.RhinoDoc.New(None)
Rhino.RhinoDoc.ActiveDoc = doc
Rhino.Commands.CommandStyleAttribute(2)
Rhino.RhinoApp.RunScript('_Line 0,0,0 10,10,10,',False)
Rhino.RhinoApp.RunScript('_SelAll _-Export filename.dwg _Enter',False)

Bot the runscript calls returns True, but no file is exported. Will RunScript not support file export?

It works!

Try opening it with head:
1.write the file as 3dm somewhere
2.open it with Rhino.RhinoDoc.Create(str(rhino_path))

then run it. (I am testing with the headless now)

have a look at your document’s folder

I’m trying it to work with pdf but no luck… any thoughts?