Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get vplayer color of a selected object

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
chalkbot
1098 Views, 9 Replies

Get vplayer color of a selected object

Hi guys, I've been away from these boards for a while now.

 

Anyways, I thought this would be a simple tblsearch process, but as far as I can tell, there isn't a tblsearch symbol table for vplayer settings, so I need to get more creative I guess.

 

I want to be able to get the vplayer color of a selected object as part of a larger routine I'm putting together. Any tips would be much appreciated.

9 REPLIES 9
Message 2 of 10
pbejse
in reply to: chalkbot

You can retirive it via vla-getXRecordData method, thing is values for layer overrides will give you more than just one data

colors/linetype/lineweight and so on... Also consider number of viewports with layer overrides. Layer"Sample" on one viewport  might have a different value on another viewport. that will a cluster of information to sort. it will take some doing on your part.

 

You can use the attached file  by Lee Mac as a starting point

 

(LM:GetOverrideData "Layername")

 

 

 

Message 3 of 10
_Tharwat
in reply to: chalkbot

This may help ...

 

(setq ss (car (entsel "\n Select :")))
(setq e (entget ss))
(setq
  co (cdr
       (assoc 5
              (entget (cdr (assoc 340 (entget (cdr (assoc 330 e))))))
       )
     )
)

 Tharwat

Message 4 of 10
chalkbot
in reply to: _Tharwat

pbejse,

 

I tried using (LM:GetOverrideData "layername") from the lisp you attached on an xref object with no overrides and it returns nil, which is fine for my purposes. Then I changed the color override to 253 and ran the routine again. Here is what it returned:

 

(((102 . "{ADSK_LYR_COLOR_OVERRIDE") (335 -115693792 -83283613) (420 .
-1023409923) (102 . "}")))

 

I see that there is data there, which tells me that it does recognize there is an override, but I don't see the color in there anywhere. In fact, I'm not sure what any of that information is, or if it is useful to me.

 

TharwaT313,

 

I tried the lisp snippet you provided under similar circumstances and got mixed results. Sometimes it would return a number like "11" or "16" which was hopeful, because that's exactly what I wanted. Unfortunately, the number never seemed to have any correlation (that I could work out) to the actual override color, which again, I had set to 253. Curiously, if I ran the routine again, it would just return ":; error: bad argument type: lentityp nil"  I couldn't work out what the problem was.

 

If either of you guys have any insight for me it would be much appreciated. Thanks again for the suggestions.

 

 

Message 5 of 10
pbejse
in reply to: chalkbot


@chalkbot wrote:

pbejse,

 

(((102 . "{ADSK_LYR_COLOR_OVERRIDE") (335 -115693792 -83283613) (420 .
-1023409923) (102 . "}")))

 

I see that there is data there, which tells me that it does recognize there is an override, but I don't see the color in there anywhere. In fact, I'm not sure what any of that information is, or if it is useful to me.

 


335 is the viewport where the layers are overridden.

420 Is the color, need to convert it to RGB -> ACI

 

Use this (from Lee Mac)

 

(defun LM:True->RGB ( c )
  (list
    (lsh (lsh (fix c)  8) -24)
    (lsh (lsh (fix c) 16) -24)
    (lsh (lsh (fix c) 24) -24)
  )
)

 

(last (LM:TRUE->RGB -1023409923 ))---> 253, but if you are using TrueColor thats another matter.

 

Like i saide before "Cluster od DATA" if there are more than one viewport with overrides. results are more data..

 

Check out Lee Macs website (found on his signature) for Color Conversion functions

 

 

Message 6 of 10
chalkbot
in reply to: pbejse

Got it to work in my routine. Thanks for the help!

Message 7 of 10
Lee_Mac
in reply to: chalkbot

Thanks for the acknowledgements and recommendations pbejse, appreciated Smiley Wink

Message 8 of 10
chalkbot
in reply to: Lee_Mac

Thank you as well Lee, you are a genius.  Smiley Happy

Message 9 of 10
Lee_Mac
in reply to: chalkbot

Thank you kindly Chalkbot, although I still have much to learn Smiley Wink

Message 10 of 10
chalkbot
in reply to: chalkbot

Okay, I realize it's been a while since I posted the original question, but I now have a follow up question.

 

If you have multiple viewports, and you use Lee Mac's LM:GetOverrideData routine, it returns data for each viewport in the drawing, as you might expect.

 

The curious thing is that if you have a color override in only one viewport, it returns that color for all viewports if there is no separate override on them.

 

For example, if I have 3 viewports, and I set a vplayer color in one of them to red, and the other 2 to green, lee's routine returns data which can be translated to indicate each viewport, and the corresponding override color.

 

However, If I set a vplayer color in viewport 1 to red, and I leave the other 2 with no overrides, lee's routine returns data that shows all 3 viewports as being overriden to red. (if I am not mistaken)

 

I'm working on a routine that needs to know the override status of a layer in every viewport, so I was hoping there was a way to determine if the override color returned by LM:GetOverrideData is active in each viewport. Thanks!

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

Post to forums  

Autodesk Design & Make Report

”Boost