Author Topic: Keeping a Selection Set with the Explode command  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Keeping a Selection Set with the Explode command
« on: June 16, 2022, 05:45:38 PM »
I am trying to find a method to where I can select Mtext or MLeader and explode it, then with the new single lined texts; apply a new command which would move the text to layer 0.

I know this a basic to make bold, but I am trying to figure how to tie everything together using the following:
Code: [Select]
(defun C:test (/ ss)
(setq ss (ssget "x"))
(initcommandversion 2)   
(command "explode" "p" "")
(command "change" ss "" "p" "la" "0" "")
(princ))

How would I go about doing that?

Civil3D 2020

framednlv

  • Newt
  • Posts: 64
Re: Keeping a Selection Set with the Explode command
« Reply #1 on: June 16, 2022, 06:33:21 PM »
Code: [Select]
(defun C:test (/ ss)
(setvar "qaflags" 1)
(setq ss (ssget ))
(command "explode" ss "")
(command "change" "p" "" "p" "la" "0" "")
(setvar "qaflags" 0)
(princ))

slj.engenharia@gmail.com

  • Mosquito
  • Posts: 3
Re: Keeping a Selection Set with the Explode command
« Reply #2 on: August 02, 2022, 09:40:33 AM »
;;;option 1
(defun c:test (/ ss)
  (setq ss (ssget "x"))
  (initcommandversion 2)
  (command "explode" "p" "")

  (setq ss (ssget "P"));_add this line

  (command "change" ss "" "p" "la" "0" "")
  (princ)
)
;;;option 2
(defun c:test (/ ss)
  (setq ss (ssget "x"))
  (initcommandversion 2)
  (command "explode" "p" "")
 
  (setq ss (ssget "x"));_add this line

  (command "change" ss "" "p" "la" "0" "")
  (princ)
)

mhupp

  • Bull Frog
  • Posts: 250
Re: Keeping a Selection Set with the Explode command
« Reply #3 on: August 02, 2022, 03:09:12 PM »
I don't think "P" works since everything "exploded" items are considered new and not previous.

Visual lisp way creates a copy of ent and explodes it into sub entity's. The foreach will allow you to step thought each sub entity.
Code - Auto/Visual Lisp: [Select]
  1. (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode))
  2. (foreach obj poly


Autolisp way sets a "save point" with lastent and then explodes selected entity's. With all new entity's created are behind lastent in the dxf file. the while loop for en will add these to a selection set you define.
Code - Auto/Visual Lisp: [Select]
  1. (setq LastEnt (entlast))
  2. (command "_.Explode" SS)
  3. (setq SS (ssadd))
  4. (if (setq en (entnext LastEnt))
  5.   (while en ;add all new entity's created by explosion back into selection set.
  6.     (ssadd en SS)
  7.     (setq en (entnext en))
  8.   )
  9. )

slj.engenharia@gmail.com

  • Mosquito
  • Posts: 3
Re: Keeping a Selection Set with the Explode command
« Reply #4 on: August 09, 2022, 08:11:17 AM »
Hello mhupp
with all respect,
the new selection set with "p" works after the explode,
   (command "explode" "p" "")
   (setq ss (ssget "p"))
I constantly use this method.
Try, do a test.

mhupp

  • Bull Frog
  • Posts: 250
Re: Keeping a Selection Set with the Explode command
« Reply #5 on: August 14, 2022, 03:18:33 PM »
Yes I your right I looked over my code and was doing several other operations after explode that would negate the Previous selection to only select a few items of the original explode.
or I was stepping though a selection set doing the explode one by one and then grouping them back up again.

apologizes