tigger29900 Posted December 6, 2011 Share Posted December 6, 2011 I have been trying to work out a quick solution to a problem using .net but have been stumped by my lack of knowledge in programming. I need to write an app/plugin for autocad that will change the color of a layer when a checkbox is checked. I have been able to set up the user form but i am not sure how to code the actual changing of layer colors. Another feature i am trying to incorporate is the output filtering of the text contained on the layer which have had their colors changed to build an effect equipment list Any help would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
Jeff H Posted December 6, 2011 Share Posted December 6, 2011 Here is a little something to get you started where you enter a color index to change all layers. Took out little bit for checking IsDependent, etc..... for handling xref layers [CommandMethod("ChangeAllLayersColor")] public void ChangeAllLayersColor() { PromptIntegerOptions pio = new PromptIntegerOptions("\nPlease enter color index for xref colors"); pio.LowerLimit = 1; pio.UpperLimit = 255; PromptIntegerResult pir = Ed.GetInteger(pio); if (pir.Status != PromptStatus.OK) { return; } short index = (short)pir.Value; using (Transaction trx = Db.TransactionManager.StartTransaction()) { LayerTable lt = (LayerTable)trx.GetObject(Db.LayerTableId, OpenMode.ForRead); foreach (ObjectId ltrId in lt) { LayerTableRecord ltr = (LayerTableRecord)trx.GetObject(ltrId, OpenMode.ForRead, false, true); if (ltr.Color.ColorIndex != index) { if (ltrId != Db.LayerZero) { ltr.UpgradeOpen(); ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, index); } } } trx.Commit(); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.