Issue
I need to set the color of my newly created Layer object. I use “Layer.Color.SetColor(120,120,0)”, but it does not work. How can the color of a layer be changed?
Solution
To control the color of a layer create a new color object and assign it to the layer using the color property. Use the SetColor property of the color object to control the color.
Here is a VBA example:
Dim oDD As DrawingDocument
oDD = ThisApplication.ActiveDocument
Dim oL As Layer
oL = oDD.StylesManager.Layers(1).Copy(“MyNewLayer”)
Dim oC As Inventor.Color
oC = ThisApplication.TransientObjects.CreateColor(120, 120, 120)
Call oC.SetColor(120, 120, 0)
oL.Color = oC
End Sub
In C#.Net
public static void setNewLayerColor() { try { Inventor.Application app = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); DrawingDocument oDD = app.ActiveDocument as DrawingDocument; LayersEnumerator layers = oDD.StylesManager.Layers; Layer oL = layers[1].Copy("MyNewLayer") as Layer; Inventor.Color oC = app.TransientObjects.CreateColor(120, 120, 120, 0); oC.SetColor(120, 120, 0); oL.Color = oC; } catch { } }

Leave a Reply