I’m trying to export my drawings to PDF using Python. I’ve found the example below, but the AddPageView line return ‘None’. It’s a simple enough function I don’t know what to try… but I tried executing the code before and after saving the document - in case that made a difference.
def PDFExport(doc,FName:str):
dpi = 300
pdf_settings = Rhino.FileIO.FilePdf.Create()
layout_name = "A4_Miller"
page_height = 210
page_width = 297
# Create a new view for printing
view = doc.Views.AddPageView(layout_name, page_width, page_height)
OK, so I’ve tried this a few different ways, and I’m still getting a problem.
In my case, the doc object is passed into the function. doc is created via the CreateHeadless method, but I’ve also tried using the Create method - neither work.
I also tried assigning the doc objct using Rhino.RhinoDoc.ActiveDoc as you have, but that doesn’t work either.
In all cases, doc returns as None.
For what it’s worth, I had problems creating with templates not creating layouts using the CreateHeadless method previously - see here: RhinoDoc.CreateHeadless doesn't create document layouts
I wonder if they’re related issues?
Familiarity, convenience, so far, it’s done everything I need and I haven’t found a reason not to use it…
The end result of my project will be a standalone python script that carries out a number of functions - a significant part of which requires interactions with Rhino.
Hi @Gerrard_Hickson, i cannot say anything about CreateHeadless as i tested only with a regular rhino document. Does your script run from one of the build in python editors or using RunPythonScript ?
Maybe you should first try to solve the problem with scriptcontext ? Both script editors import module search paths before running scripts. It could be that this is the reason you’re not able to access the modules in VS which are imported using:
import scriptcontext
You might try this:
1.Open _EditPythonScript (the old IronPython script editor)
2.Go to Tools > Options > Files > Module Search Paths
3.Note the paths listed in the dialog
In my case, the scriptcontext module is located here: