pickset manipulating

pickset manipulating

vishshreevT578L
Advocate Advocate
2,295 Views
12 Replies
Message 1 of 13

pickset manipulating

vishshreevT578L
Advocate
Advocate

PICKSET.jpg

I want to manipulate this pickset,

I mean i want to make separate list of all the text, line, Mtext, polyline.

can anyone please suggest

Shreev
0 Likes
Accepted solutions (3)
2,296 Views
12 Replies
Replies (12)
Message 2 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this sub...

 

(defun :ssByType (ss / typlst i a en typ)
  (repeat (setq i (sslength ss))
    (setq en (ssname ss (setq i (1- i)))
          typlst (if (setq a (assoc (setq typ (cdr (assoc 0 (entget en)))) typlst))
                   (subst (cons typ (ssadd en (cdr a))) a typlst)
                   (cons (cons typ (ssadd en)) typlst)))))

 

 

Sometimes could be useful some quick a simple way to filter...

 

#2

(ssget ss)
(setq ssline (ssget "_P" '((0 . "LINE"))))
(sssetfirst nil ss) ; ss must be highlighted again
(setq sscircle (ssget "_P" '((0 . "CIRCLE"))))

 

#3

(setq ssline (acet-ss-ssget-filter ss '((0 . "LINE"))))
(setq sscircle (acet-ss-ssget-filter ss '((0 . "CIRCLE"))))

Message 3 of 13

Kent1Cooper
Consultant
Consultant

@vishshreevT578L wrote:

....

I want to manipulate this pickset,

I mean i want to make separate list of all the text, line, Mtext, polyline.

can anyone please suggest


If 'pickset' is a variable containing [as the name implies] a selection set, and you mean you want to make separate selection sets of the different entity types in it, try this:

(sssetfirst nil pickset); selects/grips/highlights everything in it; then:

(setq TextFromPickset (ssget '((0 . "TEXT")))); puts all Text objects from current active selection into a variable

(sssetfirst nil pickset); do it again, then:

(setq LinesFromPickset (ssget '((0 . "LINE")))); puts all Line objects into a variable

.... etc. for other types

 

If you really want to make lists of them all, there are a couple of ways you could do that.  One is to make the separate selection sets as above, and then code could be added to make a list from each of those.  Another is to step through the pickset variable's selection set, and put each item into a list corresponding to its entity type [EDIT: for example, @ВeekeeCZ's first suggested subroutine].  Is something like one of those what you really need?

Kent Cooper, AIA
0 Likes
Message 4 of 13

vishshreevT578L
Advocate
Advocate
Thanks sir
Can i do this using vlisp
Shreev
0 Likes
Message 5 of 13

Ranjit_Singh
Advisor
Advisor

or you can use mapcar to go through each entity and add to separate sets

(setq ssline (ssadd) sstext (ssadd) sslwp (ssadd))
(mapcar '(lambda (x) 
	(cond 	((and (= (car x) 3) (= (cdr (assoc 0 (entget (cadr x)))) "LINE")) (ssadd (cadr x) ssline))
		((and (= (car x) 3) (= (cdr (assoc 0 (entget (cadr x)))) "TEXT")) (ssadd (cadr x) sstext))
		((and (= (car x) 3) (= (cdr (assoc 0 (entget (cadr x)))) "LWPOLYLINE")) (ssadd (cadr x) sslwp))
		(T ())
)) (ssnamex ss1))
0 Likes
Message 6 of 13

vishshreevT578L
Advocate
Advocate

SORRY...FOR THE WRONG QUESTION POSTED.

SIR....

I MEANT HERE TO SAY THAT I DON`T WANT TO GO FOR SELECTION SET EACH AND EVERY TIME.

FROM THIS SSSET ITSELF I WANT TO LIST ALL ENTITIES SEPARATELY...NOW I WANT TO MAKE IT NIL AND AGAIN GO FOR NEW SELECTION SET.

Shreev
0 Likes
Message 7 of 13

ВeekeeCZ
Consultant
Consultant

@vishshreevT578L wrote:

SORRY...FOR THE WRONG QUESTION POSTED.

SIR....

I MEANT HERE TO SAY THAT I DON`T WANT TO GO FOR SELECTION SET EACH AND EVERY TIME.

FROM THIS SSSET ITSELF I WANT TO LIST ALL ENTITIES SEPARATELY...NOW I WANT TO MAKE IT NIL AND AGAIN GO FOR NEW SELECTION SET.


Then try this.... (hope I understood this time)

(defun :lstByType (ss / typlst i a en typ)
  (repeat (setq i (sslength ss))
    (setq en (ssname ss (setq i (1- i)))
          typlst (if (setq a (assoc (setq typ (cdr (assoc 0 (entget en)))) typlst))
                   (subst (cons typ (cons en (cdr a))) a typlst)
                   (cons (cons typ (list en)) typlst)))))

(defun c:test ()
  (assoc "LINE" (:lstByType (ssget)))
)
0 Likes
Message 8 of 13

vishshreevT578L
Advocate
Advocate

(SETQ SSET (SSGET)) ;NOW I HAVE A SELECTION SET OF ALL ENTITIES AS THE IMAGE ATTACHED ABOVE

 

NOW FROM THIS SELECTION SET (SSET) I HAVE TO MAKE A LIST OF RESPECTIVE ENTITIES.....

 

LIKE I CAN DO AS BELOW

(SETQ SSTEXT (SSGET "_P" '((0 . "TEXT")))) ; ALL TEXT ARE STORED TO VARIABLE SSTEXT

 

BUT AGAIN AFTER THIS I HAVE TO MAKE MY SELECTION SET NIL THEN GET A SELECTION SET, I WANT TO WRITE ONE CONDITION FROM WHICH ALL SIMILAR ENITIES ARE STORED TO THERE RESPECTIVE VARIABLE..

 

SORRY AND HOPE MY QUESTION IS CORRECT NOW..

 

 

 

 

Shreev
0 Likes
Message 9 of 13

SeeMSixty7
Advisor
Advisor

Try this. this will create a "ENTTYP"-ss for you based on the Enttypes in the list below.

If you run this in your drawing, you will end up with 3 variables that have selections sets.

LINE-SS

TEXT-SS

LWPOLYLINE-SS

 

If any of these entity types exist in your drawing there will be something in the selection set for that entity type. If you want different entity types simply add them to the entTypes list.

 

Good luck

 

(defun GetSSBreakout()
 (setq Overallss (ssget "X")
    entTypes (list "LINE" "TEXT" "LWPOLYLINE")
 )
 (if Overallss
  (progn
   (foreach enttype entTypes
    (set (read (strcat enttype "-ss")) (ssadd))
   )
   (setq OverallNum (sslength Overallss)
      overallcnt 0
   )
   (while (< overallcnt overallnum)
    (setq ent (ssname overallss overallcnt)
       data (entget ent)
       enttyp (cdr (assoc 0 data))
       overallcnt (1+ overallcnt)
    )
    (if (member enttype enttypes)
     (set (read (strcat enttype "-ss")) (ssadd (cdr (assoc -1 data))))
    )
   )
  )
 )
)

0 Likes
Message 10 of 13

ВeekeeCZ
Consultant
Consultant

@vishshreevT578L wrote:

 

 

(SETQ SSET (SSGET))

... 

LIKE I CAN DO AS BELOW

(SETQ SSTEXT (SSGET "_P" '((0 . "TEXT")))) ; ALL TEXT ARE STORED TO VARIABLE SSTEXT

 

BUT AGAIN AFTER THIS I HAVE TO MAKE MY SELECTION SET NIL THEN GET A SELECTION SET...

 


As me and Kent said before, you don't need to select your entities again manually using simple (ssget), just use (sssetfirst nil SSET), then you can use the Previous parameter of (ssget) function again... (ssget "_P" '((0 . "ANYTYPE")))

 

(SETQ SSET (SSGET))

(SETQ SSTEXT (SSGET "_P" '((0 . "TEXT"))))

(sssetfirst nil SSET)

(SETQ SSLINE (SSGET "_P" '((0 . "LINE"))))

(sssetfirst nil SSET)

(SETQ SSMTEXT (SSGET "_P" '((0 . "MTEXT"))))

 

... using (acet-ss-ssget-filter) you don't need to use (sssetfisrt...)

 

(SETQ SSET (SSGET))

(setq sstext (acet-ss-ssget-filter SSET '((0 . "TEXT"))))

(setq ssline (acet-ss-ssget-filter SSET '((0 . "LINE"))))
(setq sscircle (acet-ss-ssget-filter SSET '((0 . "CIRCLE"))))

 

HTH

 

0 Likes
Message 11 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@ВeekeeCZ wrote:

...


As me and Kent said before, you don't need to select your entities again manually using simple (ssget), just use (sssetfirst nil SSET), then you can use the Previous parameter of (ssget) function again... (ssget "_P" '((0 . "ANYTYPE")))

 

(SETQ SSET (SSGET))

(SETQ SSTEXT (SSGET "_P" '((0 . "TEXT"))))

....


With the set selected/gripped/highlighted by (sssetfirst), you don't need the "_P" part [see Post 3]:

 

(sssetfirst nil (SETQ SSET (SSGET)))

(SETQ SSTEXT (SSGET '((0 . "TEXT"))))

(sssetfirst nil SSET)

(SETQ SSLINE (SSGET '((0 . "LINE"))))

(sssetfirst nil SSET)

(SETQ SSMTEXT (SSGET '((0 . "MTEXT"))))

....


Kent Cooper, AIA
0 Likes
Message 12 of 13

vishshreevT578L
Advocate
Advocate
(DEFUN PL:GET-TBL-ENTS ( / CORN1 CORN2 )
(SETQ CORN1 (GETPOINT "\nSelect ll corner of table : "))
(SETQ CORN2 (GETCORNER CORN1 "\nSelect ur corner of table : "))
(LIST
(SSGET "_C" CORN1 CORN2 '((0 . "LINE")))
(SSGET "_C" CORN1 CORN2 '((0 . "LWPOLYLINE")))
(SSGET "_C" CORN1 CORN2 '((0 . "TEXT")))
)
)

(SETQ SEL (PL:GET-TBL-ENTS))


Hello Sir,


In the above code i get a list of a selection set by "getpoint method" i
want the same result using just ssget function.


I tried to do by the method you suggested of about sssetfirst Nil but i am
not getting what i want please solve my querry



Please solve my querry
Shreev
Shreev
0 Likes
Message 13 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

@vishshreevT578L wrote:
....
In the above code i get a list of a selection set by "getpoint method" i
want the same result using just ssget function.

I tried to do by the method you suggested of about sssetfirst Nil but i am
not getting what i want please solve my querry....

Since it is necessary, in the (sssetfirst nil) approach, to run that (sssetfirst) function prior to each entity-type-filtered (ssget) function, so that it has a pre-selection to pick from and will not ask the User to select things each time, I believe it is therefore also necessary to build the list of selection sets one at a time with the (sssetfirst) functions between the entity-type selections, rather than have the (ssget) functions grouped within a (list) function.  Try this [lightly tested]:

(defun SSLIST (/ sset)
  (sssetfirst nil (setq sset (ssget)))
  (setq sslist (list (ssget '((0 . "TEXT"))))); start the list
  (sssetfirst nil SSET)
  (setq sslist (cons (ssget '((0 . "LWPOLYLINE"))) sslist)); add to it
  (sssetfirst nil SSET)
  (setq sslist (cons (ssget '((0 . "LINE"))) sslist)); add to it
); defun

Usage:  (SSLIST) [in parentheses, as your example was defined -- could instead be (defun C:SSLIST ...) to use a command name without the parentheses].

 

Kent Cooper, AIA
0 Likes