I share your distaste for “coercing” (casting), yet that is the method recommended in official tutorials like this one for baking to layer:
How would you modify that bake to layer script to avoid using ‘
The not so funny thing is that extensive searching fails to find any reference to these coerce methods or what can be used in their place?
I eventually got most of what I wanted for bake-to-layer (with custom material), but it fails to handle groups:
I can recognize the type difference between ‘Guid’ when passing ungrouped geometry and ‘List[object]’ when passing a group. I can traverse the list object and see that it consists of type ‘Brep’ objects but so far, I have failed to find a way to get a ‘Guid’ or the ‘AttributedGeometry’ I want from the breps?
doc_object = rs.coercerhinoobject(geo) print type(doc_object) print type(geo) if type(geo) is not System.Guid: #assume 'List[object]' for group for G in geo: print 'G =', type(G), type(rs.coercerhinoobject(G))
And like the coerce methods, good luck finding any reference to type ‘AttributedGeometry’ anywhere in the API docs! How the hell can that be?
(“No results were found for your query.”)
I have a hunch that even if I could bake the geometry in the group with this approach, it wouldn’t be grouped anymore, so this is probably all wrong anyway?
Really, I’d MUCH rather be focused on my GH model instead of scripting my own bake-to-layer component. All the more so because my experience with the Rhino API documentation and examples scattered throughout the forum has been utterly dreadful and frustrating.