AutoCAD/setting color

Advertisement


Question
QUESTION: I need a lisp routine to set my color control to True Color just by picking an object whose color is defined in True Color.  Matchprop can change the color of an object into True Color if the object it picts first has it.  Isn't ther something to set colors by selection?

ANSWER: OK.  You lost me.  Matchprop changes all properties including color and does so by entity selection.  If the first object you pick DOESN'T have TrueColor, then there won't be a TrueColor Property to match to.  I'm not understanding what your need is here. Please explain further.

Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn



---------- FOLLOW-UP ----------

QUESTION: Hello, Bill
I have a project from a contractor that uses Microstation exclusively.  We told them that we use AutoCAD only; however, we will be able to help them because ACAD and uSTN can now translate easily between platforms.  I have set up my ACAD to mimic uSTN so that there will be no need to fix my ACAD dwgs once they translate.  This means that I plot using an .stb.  I use only 63 layers. I set the lineweights and the linetypes of each object that I put on a layer.  The layers are used categorically, which means that the color, which must be set to “True Color” (TC) is only used to identify the layer.

Setting my properties every time I wish to draw an object is time consuming, so I want a lisp routine that can set all of them just by picking an object that has all of the desired properties.  I have a routine that can set the lineweight, linetype and layer just by picking an object.  What I need is a sub-routine that can set the color to TC, too.

I know the DXF code for TC (420).  I also have routines that can separate the “assoc 420” into the red, green, and blue elements needed.  What I don’t know how to do is use them and then get a string that I can use to set the “T” option of the color command.  The “T” option requires commas, and I have no idea if the command wants a list or a string.

I hope I’ve been clear about what I need.  If not, let me know, and I’ll try again.  
Thanks much,
JPM


Answer
John:  With AutoLISP, I'm not sure there is a way to accomplish that.  Possibly with Visual LISP, which comes from Visual Basic, but AutoLISP (what I know) won't do it.  For example.  I drew a line changed it's color properties with the True Color dialog.  Then used AutoLISP to get the properties and I got this:
Select object: ((-1 . <Entity name: 7ef82ee8>) (0 . LINE) (330 . <Entity name:
7ef82d18>) (5 . 65) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (62 . 45)
(420 . 11896650) (100 . AcDbLine) (10 -7.02095 3.06444 0.0) (11 1.28108
-4.62668 0.0) (210 0.0 0.0 1.0))
DXF code 62 is for color and it gave me color number 45.  AutoCAD returns the closest match of the 255 colors it has available.  It even looks the same on screen.  However, when I click on the object the RGB value appears in the properties toolbar.  I'm going to investigate as how to get the TrueColor RGB values.  I check on the VLAX-GET-PROPERTY command and it still returns 45.  Not 181,135,74.
I even tried using TrueColor as a symbol and got the following:  #<VLA-OBJECT IAcadAcCmColor 07ed4d00>
It seems to know what I'm talking about, but I don't know what it's talking about.
So, I'll be checking with the newsgoups on this one.
In the meantime, you can use the following routine for a non-RGB color properties and all other properties setter.
http://my.sterling.net/~bdeshawn/ddeset.lsp


Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill DeShawn

Expertise

I can address all 2-D questions and some 3-D questions. I do programming in AutoLISP if it doesn`t involve solid modeling. I can also address menu customization issues and can help you find answers to questions I can`t answer by taking your question directly to Autodesk via their newsgroups.

Experience

I used to do electronic and mechanical design for a flat panel monitor manufacturer, and now I do architectural drafting for an architect. I did and do AutoLISP and menu customization and take pride in making my lisp routines to do the work exactly the way the client likes them done.

Publications
I had a routine published in CADENCE magazine (no longer in publication and taken over by CADALYST). Some of my routines are published on my website at http://my.sterling.net/~bdeshawn

©2012 About.com, a part of The New York Times Company. All rights reserved.