Skip to content
July 22, 2010 / stevebaer

StarMaker – An advanced sample

starmaker

Here’s a sample that demonstrates quite a few of the advanced features in Rhino.python. This sample was written and tested on Windows (I doubt it is going to work very well on OSX given that Windows.Forms are being used.) You are going to need to be running at least the July 20th build of Rhino 5 to test this.

StarMaker is composed of two script files; starmaker.py and sliderform.py. Save these files to the same directory.

What does it do? StarMaker just creates a new curve based on points from a closed planar polyline and some input from a form. Run the Polygon command and create a polygon with something like 30 edges. Then run starmaker.py

Some python features demonstrated:

  1. Multiple Script Files – the python script is broken into two files. sliderform.py doesn’t do anything on it’s own and is imported into starmaker.py
  2. Direct use of RhinoCommon – the script uses some of the functionality provided by the rhinoscript python functions, but it really makes heavy use of .NET classes defined in RhinoCommon
  3. Custom Windows Form – This is pretty cool!!! sliderform.py is a custom Wnidows Form user interface. This file was actually created in SharpDevelop (http://www.icsharpcode.net/opensource/sd/). SharpDevelop has a nice user interface editor for creating custom forms which are written as python files. Try opening sliderform.py in SharpDevelop and click on the design button. (See the attached SharpDev image)
  4. Custom Display for Preview Geometry – The red curve, dotted lines, and points in the screenshot are not actual geometry in the rhino document but are drawn using display callbacks (also know as conduits)

Calling RhinoCommon from python hasn’t been covered too much on this site so much of the script may look foreign.

I want to thank Marc Fornes of http://www.theverymany.com for inspiring this sample.
sharpdev

The python scripts can be found here

5 Comments

Leave a Comment
  1. Bradley rothenberg / Oct 8 2014 5:15 pm

    Steve,

    I was going through the sliderform & starmaker script you posted here, & had a question about the variable “e” that you use in most of the functions that access the gui window. What is this variable for? I understand self & sender, but e is less apparent.

    thanks!

    Bradley

    • stevebaer / Oct 8 2014 5:20 pm

      Most events in .NET follow the pattern of

      Event(object sender, EventArgs e);

      The event args are custom to each type of event that occurs.

  2. Bradley rothenberg / Oct 8 2014 6:17 pm

    is this what I should be reading to understand this:

    http://msdn.microsoft.com/en-us/library/edzehd2t(v=vs.110).aspx

  3. Bradley rothenberg / Oct 8 2014 8:03 pm

    Steve,

    thanks for responding so quickly! Another question is what is the reasoning behind using the display conduit ?? Is it that much faster to use the display conduit vs. re-writing actual geometry?

    thanks!

    Bradley

    • stevebaer / Oct 16 2014 6:36 pm

      Yes, display conduits are typically what you use for previewing geometry before you actually go ahead and add it to the document

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: