Select all objects on layers with preset names

Select all objects on layers with preset names

mpa-la
Advocate Advocate
1,560 Views
6 Replies
Message 1 of 7

Select all objects on layers with preset names

mpa-la
Advocate
Advocate

Hello all, I have searched, and tried for a couple of hours to write it myself, but alas...  I want a command that selects all the hatches on multiple layers that always have the same name.  Lets call the layers A, B, C, and D.  I want to issue the command, not have to select anything manually, then all the hatches on those layers would get selected and get changed to solid.  I know this is not a terribly complicated lisp, and someone that knows what they're doing could probably write it in 5 minutes!  Can anybody point me at an existing lisp that's similar that I could edit, or make something up quickly for me?  Thanks in advance!!

0 Likes
Accepted solutions (1)
1,561 Views
6 Replies
Replies (6)
Message 2 of 7

DC-MWA
Collaborator
Collaborator
Accepted solution

I am no guru, but this seems to work.

 

(defun c:test (/ ss i en)
(if (setq ss (ssget "X" '((0 . "HATCH")(8 . "LayerA,LayerB,LayerC,LayerD"))))
(repeat (setq i (sslength ss))
(setq en (ssname ss (setq i (1- i))))
(command "-hatchedit" en "p" "SOLID")
);repeat
);if
(princ)
)

Message 3 of 7

hosneyalaa
Advisor
Advisor

try

(defun c:test (/ ss i en)
(if (setq ss (ssget "_X" '((0 . "HATCH") )))
  (progn
(repeat (setq i (sslength ss))
  
(setq en (ssname ss (setq i (1- i))))
  (setq objvl (vlax-ename->vla-object en))
  (vla-setPattern objvl acHatchPatternTypePreDefined "SOLID" )
  
); repeat
)
); if
(princ)
)

 

7.gif

0 Likes
Message 4 of 7

mpa-la
Advocate
Advocate
Hey PC-MWA, that works perfect!!! I can also look at your routine and see where I went astray. Thank you so much!!
0 Likes
Message 5 of 7

mpa-la
Advocate
Advocate

Thanks for the routine, but it seems to change all hatches in the drawing to solid.  I need something that targets just the hatches on specified layers, but I can see a use for your routine as well, so I am going to add it to my repertoire!  Thanks so much for looking at that for me!

0 Likes
Message 6 of 7

DC-MWA
Collaborator
Collaborator

You are very welcome Sorry for delay in responding, crazy busy.

0 Likes
Message 7 of 7

devitg
Advisor
Advisor

@mpa-la , change to 

 

 (setq ss (ssget "X" '((0 . "HATCH")(8 . "LayerA,LayerB,LayerC,LayerD"))))

 

Where 

 

LayerA,LayerB,LayerC,LayerD

 

are yours's layers names  , you  can also use a WILDCAR if layers names have some common letters  

 

(8 . "*A,*B,*C,*D")