Grasshopper

algorithmic modeling for Rhino

Within a python component I am trying to automate a process of setting a view and exporting geometry to illustrator.  I understand how to call a command via rs.Command, but I am struggling to understand the command line syntax that allows me more control over the command without the use of a dialogue box or the command line.

Specifically, I need help with:

rs.Command("-Export")...To illustrator

rs.Command("-NamedView") to set the view to a specific named view.

Anyone with experience or advice, I would greatly appreciate it.

Thanks for your time,

Jackson

Views: 4900

Replies to This Discussion

This thread over on the old Rhino.Python forum might help with understanding how to construct and format strings for use with the rs.command() function. Also, note that you might have to set the scriptcontext from Grasshopper to the current active Rhino document for a command to work. Hope that helps..

Anders

Thanks for the help! I think I have figured out everything in the command syntax that I except how to pass an variable input (a string representing the path, for example) into the command arguments.

Can this be done?

Thanks,


Jackson

If you think of the whole command input as one string, it is pretty easy to use Python string concatenation to build up commands which takes whatever parameters you need. I have attached an example for importing a Dwg file which takes a file path parameter as an input, note that you have to be a bit careful with using correct spacing (in yellow):

Attachments:

Right now I have the following syntax worked out should anyone need the reference.  All work fine.  But I would like to be able to pass a panel of file names, views, etc. into the commands.

rs.Command("_-DocumentProperties" " _Unit _UnitSystem=Inch _No _Enter _Enter _Enter")

rs.Command("_-NamedView" " _Restore Viewname _Enter")

rs.Command("_-Make2d" + " _DrawingLayout=CurrenView _ShowTangentEdges=No _CreateHiddenLines=No _ShowViewRectangle=No _MaintainSourceLayers=Yes _Enter")

rs.Command("_-Export" + " filename.ai _PreserveUnits=Yes AIScale=1 Unit=inch Rhinoscale=1 ViewportBoundary=No Color=RGB _Enter")

 

Jackson

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service