.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to change color in AutoCAD Mechanical Layer definition

1 REPLY 1
SOLVED
Reply
Message 1 of 2
mcicognani
549 Views, 1 Reply

Unable to change color in AutoCAD Mechanical Layer definition

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;
1 REPLY 1
Message 2 of 2
mcicognani
in reply to: mcicognani

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;

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost