Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Keith Brown on August 01, 2013, 04:01:21 PM
Title: Setting the color of a layer
Post by: Keith Brown on August 01, 2013, 04:01:21 PM
So I am trying to modify a routine that I got from BlackBox that works perfectly. What it does is create a new layer based on the layer of a selected object and the value that is in the LayerAppend variable. It sets the color of the layer based on a hard coded value. Here is the routine
What I would like to do is modify the routine so that if the value of Hanger_LayerColor is nil then it takes the color of the object layer. So this is what I thought would work.
Also note that DXF Group 62 will not be present for entities with colour set to ByLayer.
Title: Re: Setting the color of a layer
Post by: Keith Brown on August 01, 2013, 05:06:40 PM
After doing some more research that was one of the first things that I did. I am now getting the error that the activex server returned an error: Parameter not optional. This leads me to believe that I am not getting the color of the object correctly.
Title: Re: Setting the color of a layer
Post by: Keith Brown on August 01, 2013, 05:22:43 PM
I did some more testing and the error is definitely in the code where I am trying to grab the color of the object. So......... Now I am trying to figure out how to get the color of the first item in a selection set.
Title: Re: Setting the color of a layer
Post by: Lee Mac on August 01, 2013, 05:29:19 PM
Also note that DXF Group 62 will not be present for entities with colour set to ByLayer.
Title: Re: Setting the color of a layer
Post by: dgorsman on August 01, 2013, 05:36:14 PM
Maybe throw in another (if ... ) around the (cdr ...) at the end, such that if it *is* nil it will get the layer of that object and extract the ACI value.
I wonder if we can still assign acBylayer/"BYLAYER" as a color of a layer... I know it can be done with line types.
Title: Re: Setting the color of a layer
Post by: Keith Brown on August 01, 2013, 05:47:59 PM
I decided to go another route and instead of getting the color of the object I went with getting the color of the layer that the object resides on. I think that this will work for my purposes. Here is the code.
So if I change the value of Hanger_LayerColor to nil the new layer will have the color of the objects layer. If I leave it alone the new layer will have a white color. Exactly what I wanted.