generative modeling for Rhino
I am new to using Python and the Python component, so excuse me if this is an obvious question. I am having some problems with the following code, in which I am simply trying to assign a colour to a mesh cube:
colour = [4,200,6]
cube_colour = rs.ObjectColor(cube, colour)
a = cube_colour
but get the following error:
Runtime error (ArgumentTypeException): expected RhinoDoc, got GrasshopperDocument
line 431, in ObjectColor, "C:\Users\Lynne\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\object.py"
Ultimately I want to assign colours to objects, possibly change these and then bake them with the colour with the hope of exporting them as VRML files for colour 3D printing.
Any help gratefully received :-)
it is currently impossible to assign colors (or material or layers) to Grasshopper objects because the Grasshopper SDK does not pass this information from an object to another. I could actually make the function run, but then this would not give any results.
On the other hand, you could bake objects with a color or a layer into the Rhino document.
It is possible to have this kind of scripts in Pyton, in this sense. Do you need any help with this?
Thanks for your swift reply.
Ok that explains the problem thanks.
I had a look at the text example, as a newbie I found it quite hard to follow but I gather you are communicating with the Rhino doc rather than grasshopper to assign the attributes?
Looking at the other end, to save an object as an VRML with the colour attached it seems it needs to be actually assigned as the material colour on the layer. (I tried the bake component in Lunchbox with a colour but it doesn't seem to 'stick' to the object when I import it back in again from the VRML)
My thought was just keep lists of objects that will be the same colour, output them separately, and bake separately onto different layers with the appropriate colour. It would just be nice to have it a little more integrated as I wanted to work with the colours as weighting values in the script. If this could be done in a relatively easy and similar way to the colour text example I would be interested to get some advice on that..