Grasshopper

algorithmic modeling for Rhino

I know Guilio made an elegant C# code for baking objects with color and material. The one I can find on his website works for up to Grasshopper 8.0. Does Guilio or anyone else have a version that works for 9.0? I meant to learn C# and do it myself, but I have a deadline coming up so I'm asking help here.

Thanks in advance!

Darren

Views: 7985

Replies to This Discussion

Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
att.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
att.ObjectColor = Color.Blue;
att.LayerIndex = doc.Layers.Find("myLayer", false);

doc.Objects.AddCurve(x, att);

 

cheers FF

FF, Which part of the script am I supposed to replace with this? It seems they refer to lines spread out through the script.

it was just a sample...sorry for the lack of explanation:

AddCurve can be anything e.g. AddBrep, AddPoint...the important thing is you pass the att object which is of type ObjectAttributes.

ObjectAttributes has several properties, such as objectColor and important is to set colorSource to ColorFromObject so it uses the objectColor to display the object in Rhino.

To setup a material you do have to do the same: set the MaterialSource to MaterialFromObject and then the MaterialIndex = some Integer that refers to the desired Material.

Do you need some example file? What's your c# level?

Best regards,

FF

In my original post I said that Guilio has a C# script that works for up to GH 8.0, I just need an updated version that works for GH 9.0. I have no previous experience w/ C#.

Attachments:

Hi Darren,

here is an updated version of the original script for GH 8.0 from Giulio. Everything should work for Rhino5 and GH 0.9.0014.

if something is wrong with it please report, if not have fun with it ;-)

Best regards

FF

Attachments:

FF, it works fine! Thnx a lot!

Hi F,

I've had an issue with the script, after inputting my geo and materials the preview disappears and the baking doesn't seem to work. Any ideas?

Cheers,

Al

You could try Scarab.Generic ObjectBake. This is derived from Giulio's code but behaves more like a custom preview with the ability to bake the default GH way.

Hannes,

Thanks for the tip. With fresh eyes this morning I saw I just hadn't set the boolean to true...

Cheers anyway, it works great.

Al

Thank you FLorian and Darren, great work!

nice!

More people should see this thread. Florian Frank, your script works great, many thanks. 

George

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service