Author Topic: How to select all objects from exploded regions  (Read 1236 times)

0 Members and 1 Guest are viewing this topic.

nekonihonjin

  • Newt
  • Posts: 103
How to select all objects from exploded regions
« on: October 17, 2022, 06:23:28 PM »
Hi guys,

 

I have a selection of region items created with SECTION command, after created I want to convert them into polylines.

Code: [Select]
(vl-cmdf "_section" obj "" p3 p4 pt1)

(setq objr (ssget "X" (list '(0 . "REGION") (cons 8 lyr))))

(vl-cmdf "_chprop" objr "" "Layer" layername "")

.......

.......

(setq ss (ssget "X" (list '(0 . "REGION"))))

I want to keep the object in the same layer of the 3Dsolid it came from, so selecting by layer it's not a good idea.

Since they are not in Z=0, when exploded the result are 3Dpolylines and other stuff being created that cannot be joined properly.

 
So I'm using FLATTEN comand to get them to Z=0 and the command explodes them into plines and splines, that can be joined.


The problem is I can't figure out a way to select all objects after using flatten


Right now I have to ask the user to select all exploded objects, I would like to aviod that.
 

Code: [Select]
(acet-flatn ss hide)

(command "_zoom" "_E")

(prompt "\nSelect lines to be joined: ")

(setq objf (ssget))

(command "_pedit" "_M" objf "" "_Y" "_J" "" "")

 

Hope you guys can give some ideas, thanks!

mhupp

  • Bull Frog
  • Posts: 250
Re: How to select all objects from exploded regions
« Reply #1 on: October 17, 2022, 10:10:15 PM »
This should do what you want. Every time you modify an entity in a drawing it will re-writes it to the end of the drawing database. this uses that by saying anything after this point (LastEnt) I want to add  to into a selection set.

Quote
Since they are not in Z=0, when exploded the result are 3Dpolylines and other stuff being created that cannot be joined properly.

I don't know what other stuff is being created so this might not work

Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssadd)) ;need a blank selection set to add items to
  2. ...
  3. (setq LastEnt (entlast)) ;put this right before you explode the region
  4.  
  5. ...
  6.  
  7. (if (setq en (entnext LastEnt)) ;will add any entity to selection set ss after LastEnt
  8.   (while en
  9.     (ssadd en ss)
  10.     (setq en (entnext en))
  11.   )
  12. )
  13. (command "_pedit" "_M" SS "" "_Y" "_J" "" "") ;join selection set SS

The visual lisp way creates new individual entity's that made up the region but also keeps the old region as well.
Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssadd)) ;sill need a blank selection set
  2. ...
  3. (setq obj (vlax-ename->vla-object objrx)) ;get objr's vla-object name
  4. (setq itms (vlax-invoke objr 'explode)) ;explode command creates a list of new entity's
  5. (vla-delete obj) ;delete by vla-object name
  6. ;(entdel objrx) ;or delete by entity name
  7. (foreach ent itms
  8.   (ssadd (vlax-vla-object->ename ent) ss) ;steps though list and adds them to selection set SS
  9. )
  10. (command "_pedit" "_M" SS "" "_Y" "_J" "" "") ;join selection set SS

nekonihonjin

  • Newt
  • Posts: 103
Re: How to select all objects from exploded regions
« Reply #2 on: October 18, 2022, 03:27:30 PM »

Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssadd)) ;need a blank selection set to add items to
  2. ...
  3. (setq LastEnt (entlast)) ;put this right before you explode the region
  4.  
  5. ...
  6.  
  7. (if (setq en (entnext LastEnt)) ;will add any entity to selection set ss after LastEnt
  8.   (while en
  9.     (ssadd en ss)
  10.     (setq en (entnext en))
  11.   )
  12. )
  13. (command "_pedit" "_M" SS "" "_Y" "_J" "" "") ;join selection set SS


This did the work! thanks Mhupp!!