Selecting objects by layer, then changing properties

Selecting objects by layer, then changing properties

chadwickt
Advocate Advocate
368 Views
3 Replies
Message 1 of 4

Selecting objects by layer, then changing properties

chadwickt
Advocate
Advocate

Hello!

I am wanting to do the following:

Select all objects on the layer "Visible (ANSI)"

Change those objects to the "0" layer

Select all objects on the layer "Hidden (ANSI)"

Change those objects to the "0" layer and set the linetype to HIDDEN2

 

Since there is not a command line version of the QSELECT command, I am unable to do this with macros or scripts. Can this be done with Lisp or some other way? Thanks in advance!

0 Likes
Accepted solutions (1)
369 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant

AutoLisp can do that, but:

Are all such objects always in the current space when you would run such a routine?  AutoLisp can do it in different ways -- one of them is a little simpler, but won't work on things in multiple spaces.

Kent Cooper, AIA
0 Likes
Message 3 of 4

chadwickt
Advocate
Advocate

Hi Kent, thanks for your reply! I am pretty sure it is all in Model space. It is geometry imported from Autodesk Inventor.

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

Then if you're in Model Space at the time, you can do something like this [untested]:

 

(if (setq ss (ssget "_X" '((8 . "Visible (ANSI)"))))

  (command "_.chprop" ss "" "_layer" "0" "")

)

(if (setq ss (ssget "_X" '((8 . "Hidden (ANSI)"))))

  (command "_.chprop" ss "" "_layer" "0" "_ltype" "HIDDEN2" "")

)

 

Those could be defined into a single command name if desired.

 

That could be simplified if you know there will always be objects on those Layer to change the properties of, but the simplified version would run into trouble if either Layer didn't have anything on it.

 

Interestingly, this (command)-function CHPROP approach, unlike other AutoLisp approaches involving manipulating entity data or VLA properties, does not require the HIDDEN2 Linetype to be loaded in the drawing already -- it will find it.  But the other approaches can work on objects that are not in the current space, which this way cannot.

 

P.S. Is it necessary to check whether/ensure that the Layers are unlocked?

Kent Cooper, AIA