I know, this is a little specific, don't know how many of you has worked with ACADM... however, this is the problem.
I can access to intrinsic mechanical layer definition and Balaji kindly supplied a vb sample that shown how to change Linetype.
Problem is, I can change name and linetype, but cannot change color. No error shown, but the color remain as before.
Tried different solution, but the object trueColor refuse to cooperate!
Here my code snippet:
AcadApplication acadApp = (AcadApplication)Application.AcadApplication; AcadmApplication acmApp = (AcadmApplication)acadApp.GetInterfaceObject("AcadmAuto.AcadmApplication"); // get layer manager and layer definitions McadLayerObjectMgr acmLayMgr = acmApp.ActiveDocument.LayerObjectMgr; McadLayerCfgs layers = acmLayMgr.GetAllLayers();
// cycle through layers and adjust name, linetype and color foreach (McadLayerCfg lay in layers) { switch (lay.Name.ToLowerInvariant()) { case @"am_3":
lay.Name = "MyHiddenLayer"; // this works lay.LineType = "HIDDEN"; // this works lay.trueColor.ColorIndex = AXDBLib.AcColor.acGreen; // this doesn't work, no error reported break;
Solved! Go to Solution.
Solved by mcicognani. Go to Solution.
Ok, found a way. I got confused because AcadAcCmColor is defined also in namespace AutoCAD. Using AXDBLib explicitly did the trick!
AXDBLib.AcadAcCmColor c = new AXDBLib.AcadAcCmColor(); c.ColorMethod = AXDBLib.AcColorMethod.acColorMethodByACI; c.ColorIndex = AXDBLib.AcColor.acGreen; lay.trueColor = c;