I was wondering if someone could help me write a script to automate a very tedious workflow.
I want to keep this simple. I work by organizing multiple 2D drawings inside a grid on one single Rhino file.
What I need to do is automate the printing of each of these drawings to separate PDFs files (one for each grid cell).
Not sure which is the best direction to take: To use “Layouts” or “Print Window”.
Using Layout offers no advantage to me for this specific workflow.
Each cell should be a different pdf. You can imagine doing this with the Ctrl + P and “moving” the “Print Window” form its center to the center of each cell and saving and naming each PDF gets quite tedious. (Not to mention the select > invert > hide combo to get each individual drawing alone).
Maybe to simplify things I could first print 1 pdf with all correct settings (given that Rhino remembers used settings) and then run the script.
Any insight would mean a tremendous help!
Thanks in advance,
Shynn
Thank you so much @Mahdiyar, this is great! You have saved me so much time! I owe you one.
PD:
Could you explain what do the 34, 20 means in coordinates?
Also, it is possible to set a scale? Within the script, it doesnt need to ask the user for it. Sometimes my grid cells are not 1:1 and so I dont want huge sized paper pdfs.
Hi @Mahdiyar I tried to run your script on another file and it seems it crashed.
I realized you check for all objects in the document, and then test if these are curves or polylines. On my working files I have many Make2Ds that have thousands of curves and a lot of these are polylines… So I am guessing thats why it crashed.
Maybe it is easier to just select the objects of “x” layer, say “Bounding Curves” ?
Edit: I modified the script like so and the layer selection works:
objs = rs.ObjectsByLayer("Curves", True)
rs.EnableRedraw(False)
for obj in objs:
rs.HideObject(rs.InvertSelectedObjects())
createLayout(str(i))
i = i +1
rs.ShowObjects(objs)
rs.Command("_Show")
Still, for some reason the createLayout def is generating some weird results (even if using it without modifications) where objects are not properly zoomed at, or not zoomed at all.
Edit02: Nvm, it works if the Layout Unit is set to the same Unit as the File before running the script, for example both in meters.
I think the last step for this to work is to sort the curves along the x axis and y axis, so that the layout is created in order no? How would that be in Python?