Looking for Truecolor data in Block Definition

Looking for Truecolor data in Block Definition

Anonymous
Not applicable
1,535 Views
13 Replies
Message 1 of 14

Looking for Truecolor data in Block Definition

Anonymous
Not applicable

I have created a layer with some R,G,B value - say 1,1,1 When I look at the block definition, all I see is a 62 code entry of 18.  This seems to be true for any arbitrary RGB values I choose. How do I extract the RGB values from the block definition?

If I create an entity and explicitly give it that color, I see the same Group 62 code and an additional Group 420 code which does not appear in the block definition.

 

I do see the 420 code in the DXF export.

 

Question:

1) How do I get the 420 code from the block definition?

2) What is the algorithm for extracting the RGB values?

 

Thanks

 

Lukas

0 Likes
Accepted solutions (1)
1,536 Views
13 Replies
Replies (13)
Message 2 of 14

serag.hassouna
Advocate
Advocate

The best bet I think you should take is to consult ActiveX's TrueColor property instead of looking through DXF group codes.
IMO, from the times I've dealt with DXF group codes, they are beneficial at these situations:

  1. Uniqueness of the group code within the list resulted from entget.
  2. Selection Set filtering, usually used with entity types that are known by their 0 group code.

 

0 Likes
Message 3 of 14

dgorsman
Consultant
Consultant

Block definition doesn't have a layer, or a color... it's just a named collection of entities used to define the block.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 4 of 14

cadffm
Consultant
Consultant

Your description is somehow totally wrong OR I'm translating this wrong- (then sorry).

 

"I have created a layer with some R,G,B value - say 1,1,1"

Note: LAYER property of objects is DXF 8 (layer)

 

"When I look at the block definition,"

You will find a Layer and perhaps a color, but that is not what you are searching for,

or perhaps a translating problem on my side: Do you mean "When I look at objects inside the block definition,"??

 

 

"all I see is a 62 code entry of 18. "

You talked about LAYER with color 1,1,1 - if you like to display a objects in color of that layer,

the object have to refer to this Layer DXFCODE=8

(or for objects inside a Blockdefinition, Layer0 is also possible, if blockreferences are on that layer.)

 

The COLOR of object must be BYLAYER (DXF 62 0) / or without dotted-pair 62

(or for objects inside a Blockdefinition, Color BYBLOCK (DXF 62 256) is also possible, if color blockreferences are set to BYLAYER)

 

>> We don't know about your Block content/structure and nothing about the properties of your blockreferences)

 

 

Sebastian

0 Likes
Message 5 of 14

Anonymous
Not applicable

I will restate the problem:

 

Start a new drawing

Create "Layer1" and assign it some arbitrary Truecolor R,G,B

I'm looking for a Lisp routine "Color_from_Table"  - which when you submit (Color_from_Table "Layer1"), it returns the expected RGB string.

0 Likes
Message 6 of 14

cadffm
Consultant
Consultant
Only one question more:
If you set the color of Layer to 1 or 211, do you want this color number or the truecolor rgb value?

Thats important if you handle with aci colors.

For truecolor
Get vla-get-truecolor of your vla layer object.
(Vla-get-truecolor (vla-item(vla-get-layers(vla-get-activedocument(vlax-get-acad-object))) "MyLayer1"))

Sebastian

0 Likes
Message 7 of 14

cadffm
Consultant
Consultant
0 Likes
Message 8 of 14

serag.hassouna
Advocate
Advocate

The solution is written through the context of the documentation page I've mentioned before
you can get the function to return a string of "RED GREEN BLUE" like that

 

(defun Color_From_Table (layer / color)
  (setq color (vla-get-truecolor (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) layer)))

  (strcat (itoa (vla-get-red color)) " " (itoa (vla-get-green color)) " " (itoa (vla-get-blue color))) ;what the function returns
);end defun [Color_From_Table]

 

and the result

 

(Color_From_Table "Layer1")
"1 1 1"

 

________

you can make any other customized forms of representations you want.
__________________
To recap you have these functions to deal with:

  1. (vla-get-truecolor entity): returns the vla-object pointer to the "AcadAcCmColor" object that holds the color values.
  2. (vla-get-red color-object): returns the red value (type:integer) of a color object.
  3. (vla-get-green color-object): returns the red value (type:integer) of a color object.
  4. (vla-get-blue color-object): returns the red value (type:integer) of a color object.

_______
If you want to convert between ACI and RGB see this post.
& try to use (vla-get-colorindex color-object).

0 Likes
Message 9 of 14

Anonymous
Not applicable
Brilliant!

but

sadly, for some stupid corporate IT reason we have to use nothing later than AutoCAD 2004 on a segregated legacy system and that version does not recognize vlax-get-acad-object

Any thoughts?

Thanks!
0 Likes
Message 10 of 14

cadffm
Consultant
Consultant
(Vl-load-com) to load visuallisp extension

Sebastian

0 Likes
Message 11 of 14

cadffm
Consultant
Consultant
and think about my question about the ACI colors, depending on what your code should be used for

Sebastian

0 Likes
Message 12 of 14

Anonymous
Not applicable
Perfect!

Thanks again
0 Likes
Message 13 of 14

Anonymous
Not applicable
Accepted solution

Perfect!

 

and ACI colors is just a matter of pulling the code 62 value from (tblsearch "LAYER" [layername])

 

So problem solved

0 Likes
Message 14 of 14

serag.hassouna
Advocate
Advocate

Have you tried implementing the function by adding (vl-load-com) to the first line?

(defun Color_From_Table (layer / color)
  (vl-load-com) ;Load ActiveX Support
  (setq color (vla-get-truecolor (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) layer)))

  (strcat (itoa (vla-get-red color)) " " (itoa (vla-get-green color)) " " (itoa (vla-get-blue color))) ;what the function returns
);end defun [Color_From_Table]


Or you can just type (vl-load-com) in the command line - only once during the drawing session - to load the ActiveX extension functions. That's what I did to make the first version work fine.
______________
@cadffm, thanks for reminding us about it.
_________
@Anonymous I'm glad to see you reaching to another working solution.

0 Likes