I’m having the exact same problem, @dale do you have any news on this?
I also tried running the same code on OSX and there it actually does create a new Layout view in headless mode, but I cannot set the size and name of the Layout. The issue on OSX has already been described here.
Sample Code:
import Rhino
import scriptcontext as sc
path = '/Path/To/Output/headless_test.3dm'
# Make new doc
test_doc = sc.doc.CreateHeadless(None)
# Add some example data
sample_text = Rhino.Geometry.TextEntity()
sample_text.Plane = Rhino.Geometry.Plane.WorldXY
sample_text.Text = "Hello Rhino!"
sample_text.Justification = Rhino.Geometry.TextJustification.MiddleCenter
sample_text.FontIndex = test_doc.Fonts.FindOrCreate("Arial", False, False)
test_doc.Objects.AddText(sample_text)
# Create Layout
test_doc.PageUnitSystem = Rhino.UnitSystem.Millimeters
pageview = test_doc.Views.AddPageView("LayoutTest", 200, 200)
# Save
opts = Rhino.FileIO.FileWriteOptions()
test_doc.Write3dmFile(path, opts)
test_doc = None
print('Done!')
Tested with the latest Version 7 (7.8.21196.05002, 2021-07-15)
@stevebaer@dale
Hi,
I am also facing the above issue, Is there any alternate way to import a Layout in headless mode.
Please update since its blocking in developing a plugin in rhino 7.
The ImportLayout command will imported selected layouts into the current document. We can probably expose this to RhinoCommon and have it work on headless documents (too).