DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Colour By Layer - Changing Layer Colour

Started by skyline, September 15, 2012, 01:43:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

skyline

I have a drawing which is all messed up with colours and layers. It occurred due to the old problem in V19 where I ran out of group numbers and the drawing went nuts. I had tried to use the command 'separate by colour' to get my layers back but alas the result made no sense. I think this command has been removed now. Now I have upgraded to V22.

So I am trying to sort it out and I want to assign everything in the drawing to various layers, then apply the required colour to all the objects in each layer. However, what ever method I try I can only get one line at a time to change colour so I will be here for days.

How can I retrospectively get all objects or lines in a layer to change colour to the colour selected in the layer options box? I'm sure it must be simple. I thought if I assigned the layers, then selected the colour I wanted in Layer Options and clicked 'Apply' this would do it, but it does nothing.

Cheers

JJG

Do you tried to do this through infobox ?

on my XP machine, when I select multiple vectors, I'm abble to check (or uncheck) color by layer, or linestyle by layer, even when all the selected vectors are not on the same layer ...

Hope it's help you.

skyline

My machines running on XP too. Yes I have used info box as well. I can change the colour/layer of a single object this way but not multiple ones.

Cheers

JJG

Are you sure ?

I just tried this in v19 and v21, and it seems to me it works ... (even inside groups, improper solids, etc ...)

JJG

Skyline,

of course, you must have defined the assigned colors and line styles by layers, in Options/Options/Layer before to affect the desired objects to.

JJG

Skyline,

In case you do not manage to do this work with the infobox, which will surprise me though,
you will find below two macros that allow you to do this job automatically.

enjoy !

"Assign color by layer" :
'Assign color by layer     JJG 2012
'This macro has the advantage of performing the work through groups and improper solid unfit, without the need to disassemble them before

Alias ENT_COLORBYLAYER  &H0117

sys(1027)=1 ' message box style = OK/Cancel
message "this macro will assign the color by layer to the selection, or to the whole drawing : Caution, its action is not undoable ...",
if sys(1028)=2 then end

sys(1027)=4 'message box style = Yes/No
message "It is strongly recommended that you save the drawing before running this command (in case you want to undo this command ...): Save Now?"
if sys(1028)=6 then 'if message box=yes
>Save
  {
  }
end if

If sys(80)>0 then
sys(1027)=3 'message box style = Yes/No/Cancel
message " Selected only ?..."
if sys(1028)=2 then end
if sys(1028)=7 then
goto ALL 'if message box=no (if not selected only)
   else
goto SEL
end if
   else
goto ALL
end if

FIN:
sys(36)=0
sys(80)=0
Sys(1027) = 0

>regenerate
{
}

Message "Job done !"
End

ALL:
sys(36)=2

For i = 1 to Sys(9) ' Sys(9) is the number of entities
  Entity i
  Change Ent_ColorByLayer, 1
'This parameter allows you to query or change the entity's color association.
'A value of 1 indicates that the entity is colored depending on its layer;
'a value of 0 indicates that the entity's color is independent of its host layer.
  Update i
Next i

Goto FIN


SEL:
sys(36)=2

nbent=sys(80) ' Sys(80) is the number of entities currently selected
For t=1 to nbent
  Getselect t,j
  Entity j
  Change Ent_ColorByLayer, 1
  Update j
Next j

Goto FIN



and "Assign line style by layer" :
'Assign line style by layer     JJG 2012
'This macro has the advantage of performing the work through groups and improper solid unfit, without the need to disassemble them before

Alias ENT_LINESTYLEBYLAYER  &H0118

sys(1027)=1 ' message box style = OK/Cancel
message "this macro will assign the color by layer to the selection, or to the whole drawing : Caution, its action is not undoable ...",
if sys(1028)=2 then end

sys(1027)=4 'message box style = Yes/No
message "It is strongly recommended that you save the drawing before running this command (in case you want to undo this command ...): Save Now?"
if sys(1028)=6 then 'if message box=yes
>Save
  {
  }
end if

If sys(80)>0 then
sys(1027)=3 'message box style = Yes/No/Cancel
message " Selected only ?..."
if sys(1028)=2 then end
if sys(1028)=7 then
goto ALL 'if message box=no (if not selected only)
   else
goto SEL
end if
   else
goto ALL
end if

FIN:
sys(36)=0
sys(80)=0
Sys(1027) = 0

>regenerate
{
}

Message "Job done !"
End

ALL:
sys(36)=2

For i = 1 to Sys(9) ' Sys(9) is the number of entities
  Entity i
  Change Ent_LineStyleByLayer, 1
'This parameter allows you to query or change the entity's linestyle association.
'A value of 1 indicates that the entity's linestyle is set by its layer;
'a value of 0 indicates that the entity's linestyle is independent of its host layer.
  Update i
Next i

Goto FIN


SEL:
sys(36)=2

nbent=sys(80) ' Sys(80) is the number of entities currently selected
For t=1 to nbent
  Getselect t,j
  Entity j
  Change Ent_LineStyleByLayer, 1
  Update j
Next j

Goto FIN

Lar

#6
Quote from: skyline on September 15, 2012, 02:13:56 AM
... Yes I have used info box as well. I can change the colour/layer of a single object this way but not multiple ones.

Skyline, it is normally possible to set 'color by layer' for all entities at once by selecting them and using the info box.

If this is not working for you it may be because you have turned on 'show details' (the circulating-arrows button up top, just below the layers field, the one just before the last). When 'show details' is active the info box is dealing with individual entities in a selection set. Turn it off and the info box deals with the whole selection set.

Lar

skyline

Thanks for the advice Lar and JJG. I did not realise that about the info box and I was trying to do using the selection box in info box. So I have assigned colours to the layers, selected all objects by layer and applied using the colour bar button and it does indeed do the business.

Cheers.