I’m trying to add a new layer with a new material via the Rhinocommon code below, but it isn’t working. Anyone know what I might be missing?
Also, I’m hoping to make the material plastic, the same as in Rhino where you can change the type of the material to plastic.
Thanks,
Sam
Dim MyLayer = New Rhino.DocObjects.Layer
Dim index As Integer = doc.Materials.Add()
Dim mat As Rhino.DocObjects.Material = New Rhino.DocObjects.Material
mat.AmbientColor = System.Drawing.Color.Blue
Dim rm As Rhino.Render.RenderMaterial = Rhino.Render.RenderMaterial.CreateBasicMaterial(mat, doc)
doc.RenderMaterials.Add(rm)
MyLayer.RenderMaterialIndex = mat.Index
MyLayer.Name = "MyLayer"
doc.Layers.Add(MyLayer)
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var color = Color.BurlyWood;
// Create the layer
var layer = new Layer
{
Name = color.Name,
Color = color
};
// Add the layer to the document
var layerIndex = doc.Layers.Add(layer);
if (layerIndex < 0)
return Result.Nothing;
// Create a Rhino material
var rhino_material = new Material
{
Name = color.Name,
DiffuseColor = color
};
// Create a basic Render material from the Rhino material
var render_material = RenderMaterial.CreateBasicMaterial(rhino_material, doc);
// Add the basic Render material to the document
doc.RenderMaterials.Add(render_material);
// Assign the render material to the layer
doc.Layers[layerIndex].RenderMaterial = render_material;
return Result.Success;
}
In Rhino, I often switch the material type to plastic and use the bump texture leather at XXS. How would I go about achieving this or the equivalent in Rhinocommon?
Form this page I learnt how to set the material to plastic, thanks.
Next I was trying to implement the script on this page as a first step to getting the leather texture, but I run into a problem saying SimulatedTexture is not a member of RenderContent:
Basically, I’m trying to apply the standard leather with XXS scale as done in Rhino in below image. I’m thinking the leather texture file is somewhere in Rhino and I have to figure out where to access it. If there is a quick way to set this up, would really like to know:
Thanks Nathan! A video is worth a thousand pictures, really learnt some problem solving skills from your approach. And of course got my answer to this question too. Enjoyed the beats too and that is one funky keyboard you are using
I’m glad the video was useful. Keep asking questions, because that is how we know where people want or need to learn!
Showing my own approach is the reason why I started doing my Rhino live coding streams. Naturally it is not the only way, but one that helps me a lot. I also found that having calm musical background also helps watching this type of videos and streams.
And naturally I love my keyboard, that is why I have posted about it in Meta and the Gallery (: