Grasshopper

algorithmic modeling for Rhino

Hallo,

The local code component works like a charm, but for one small tiny thing: the user input of the Detailed Export Options can not automated for a batch.

i'm tiling up parts of a city to be 3D printed, and i need around 300 tiles, Rhino allows for the general export options to be saved as default export options. The detailed export options i have to click to confirm the user-input (precision with STL or amount of meshes with OBJ) is there a way to automate this (300 times pression ok is not an option).

Is there a way in the local code component to also automate this.

i try to avoid programs that record the action and reproduce it (winautomation for example).

any help would be appreciated :D

-Oscar Willems, TU Delft

Views: 3659

Replies to This Discussion

Hi,

did you ever solved this? I am currently facing the same Problem.....

Thanks!

Python is the simplest scripting component and it can issue detailed Rhino command lines, including export options. You use a - before the command to avoid dialog boxes, to afford pure command line. Do this manually yourself in Rhino to figure out the order of text input you need, then use Python to do that. It's a bit quirky with spaces and Enter to sequence through a full multi-line-input command, but eventually works:

import rhinoscriptsyntax
import Rhino

for q in range (0,len(Brep)):
  Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(Brep[q], Rhino.DocObjects.ObjectAttributes())

rhinoscriptsyntax.Command("SelAll")
rhinoscriptsyntax.Command("-Export " + FILE_NAME + ".obj y=n Enter Enter") #y=n turns off silly Y/Z axis swap!
rhinoscriptsyntax.Command("Delete Enter")


That takes a Python "Brep" variable input containing multiple items perhaps, bakes them to Rhino one at a time from Python via AddBrep, then starts issuing Rhino command lines, with the Enter commands cycling through normal Rhino -Export inputs as normally needed when done manually in Rhino. The .obj text tells Rhino to output file type, since there's no option for that in the command line, just the name.

To debug the Rhino command line, run the Python via Recompute or through its script editor pop up window and expand the Rhino command line window to scroll up and see what is working in the command line or not and tweak the script.

Enclosed is two spheres internalized into a Brep component, being baked to an OBJ file, with a Rhino -Export command line option invoked.

Python is so terribly simple that you should be able to use Google to get right up to speed on loops, and string manipulation as needed to do things with the file name. To add new inputs or remove them, you magnify way into the Python component to find the +/- icons that appear, and be very aware of the right click options menu when you select each input or output of the Python component. In Python the input/output variables in the script are just the names you assign to those, but the two options at the bottom of the menu very much matter to make it work, giving it a type hint of brep, for instance, and giving it list instead of item access.

Attachments:

Hello

I am missing something here. When I animate the slider, I only get .bmp. Do I need to make an adjustment in the code?

(centipede is not under development anymore). 

Thank you in advance. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service