Help with selection set

Help with selection set

Jonathan3891
Advisor Advisor
863 Views
5 Replies
Message 1 of 6

Help with selection set

Jonathan3891
Advisor
Advisor

I'm having an issue with a selection set.

 

This is a work in progress but what it does is creates 3d grating out the grate hatch pattern.

 

The problem I'm having is after the lines are turned into polylines, I'm losing the selection set "SS2".

 

(defun c:ttt (/ OS PTZ SS SS2)
  (setq OS (getvar 'osmode))
  (setvar 'osmode 7)
  (command "id" pause)
  (setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))
  (command "-hatch" "_P" "Grate" "32" "" "S" pause "" "")
  (setq SS (entlast))
  (command "_.CHANGE" SS "" "_P" "_E" PTZ "")
  (command "explode" SS)
  (setq SS2 (ssget "_P"))
  (command "_pedit" "m" SS2 "" "y" "w" "3/16" "")
  (command "_.CHANGE" SS2 "" "_P" "_T" "1" "") ;;;SS2 stops working
  )

On a side note.

How come this works:

(command "id" pause)
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

But this doesn't work:

( getpoint "\nTEST POINT : ")
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

 


Jonathan Norton
Blog | Linkedin
0 Likes
864 Views
5 Replies
Replies (5)
Message 2 of 6

Moshe-A
Mentor
Mentor

@Jonathan3891 ,

 

i'll start from the end, the following works cause the ID command saves the coordinates to LASTPOINT sysvar and (getpoint) does not.

 

 

(command "id" pause)
(setq PTZ (rtos (setq PTZ# (caddr (getvar 'lastpoint))) 4 4))

 

back to start:

when you explode Grant Hatch Pattern it releases a group of Horizontal and Vertical lines - Agree? you can not join them to one polyline? plus EXPLODE does not puts the exploded objects in previous selection set so you can not expect to get them with (setq ss2 (ssget "p"))  [though there is a way to do this with vla-objects activex] but as said they will not be joined. 

 

to gather all objects after explode you can do something like this:

 

(setq ss2 (ssadd) ename (entlast))
(command "explode" "last")
(while (setq ename (entnext ename))
  (ssadd ename ss2)
)

??

 

moshe

 

 

 

0 Likes
Message 3 of 6

Jonathan3891
Advisor
Advisor

Thank you @Moshe-A  for your input.

 

I'm not wanting to join them to one polyline, only make them all polylines.

The selection set is working all the way up to the PEDIT portion.

(command "_pedit" "m" SS2 "" "y" "w" "3/16" "")

After the PEDIT the selection set (SS2) become nil.

 

I'm looking for a solution to  keep the selection set after they are converted to polylines so I can apply a thickness to them

(command "_.CHANGE" ss2 "" "_P" "_T" "1" "")

Jonathan Norton
Blog | Linkedin
0 Likes
Message 4 of 6

jwhite
Advocate
Advocate

The entities in SS2 are destroyed during the pedit command. All new entities are created. You'll need to do what Moshe_A suggests to gather all of the new pline entities.

0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

@Jonathan3891 wrote:
....

I'm looking for a solution to  keep the selection set after they are converted to polylines ....


 

Unfortunately, a selection set is a type of collection of entity names  [in this case, of the Line entities].  Those entities in the collection no longer exist  after they've been joined into Polylines.

 

One thing you can do:  Before the PEDIT, save the last thing drawn to a variable:

(setq ent (entlast))

 

Then after the PEDIT, put all the things resulting from that [all entities newer than that saved one ] into a selection set:

 

(setq newSS (ssadd)); initially empty

(while (setq ent (entnext ent)) (ssadd ent newSS))

 

Then do further operations on newSS

Kent Cooper, AIA
0 Likes
Message 6 of 6

john.uhden
Mentor
Mentor

Ya can;t trust (entlast) to return the absouletly last entity created in the drawing database.  (entlast) may return a complex polyline with following vertices, or a block reference with one or more attributes.

I'm using my wife's laptop without any AutoCAD, so from memory,,,

(defun lastent ( / e elast)
  (setq elast (entlast))
  (while (setq e (entnext elast))
    (setq elast e)
  )
  elast
)

That'll getcha the absolute last graphical entity in the drawing (prior to whatever action you take to create new entities).

John F. Uhden

0 Likes