Jump to content

Separating SSGET Selection Set into equivalent of ENTSEL


Recommended Posts

Posted

Hey guys,

 

I'm in the process of re-writing a routine that previously asked the user for an ENTSEL (operating on a single element).

 

I would now like the user to be able to select multiple elements and have the SSGET selection set passed to the remainder of the routine as single elements (the equivalent of an ENTSEL) - stepping through the selection set with REPEAT & SSNAME.

 

I hope that makes enough sense.

 

Partial code is currently:

(setq entss (entsel "\nSelect group: " ))
[b][color=red](setq ent2 (car entss))[/color][/b]

 

Aiming for something like:

(setq ss (ssget))
(setq numtot (sslength ss))
(setq con 0)
(repeat numtot 
[color=red][b](setq ent2 (ssname ss con))[/b][/color]
.....
(setq con 0)
)

 

I'm struggling to understand how to get the return of SSNAME to be the same as the return of CAR. Is there where ENTGET would come into play?

 

Hoping someone can please point me in the right direction.

 

Thanks a lot for any help.

Posted (edited)

You must increment or decrement the index of your selection set,

so in your code you are using variable "con" as index in the set.

 

You should have a line of code incrementing "con":

 

 (setq con (1+ con))

 

 

Here is a standard way to accomplish this by decrementing index "i":

 

(setq ss (ssget))
(repeat (setq i (sslength ss))
    (setq  ent2 (ssname ss (setq i (1- i)))
    ;...........rest of code here..........
); end of repeat

 

ymg

Edited by ymg3
Posted

There are lots of ways to step thru a PICKSET

 

(while (not ss)
      (setq ss (ssget)))
(setq i 0)
(while (setq en (ssname ss i))
      (setq ed (entget en))
;;;Do You Thing Here
      (setq i (1+ i)))

 

-David

Posted

Thanks for the replies guys, I'll test it out a bit later.

 

YMG3, are missing an ENTGET?

Posted

lamensterm,

 

The entget can go in rest of your code or like so:

 

(setq  ent2 (entget (ssname ss (setq i (1- i))))

 

Did not put it on purpose to illustrate the index action on ssname

 

Have a good Day;

 

ymg

Posted
This tutorial may help you - essentially, the ssname function will return the entity name of the entity at each index in a selection set; this entity name is the same as the data returned by the (car (entsel)) expression, since (entsel) will return a list of the entity name of the selected entity and the coordinates of the center of the pick box, and therefore (car (entsel)) will return the first item of this list, i.e. the entity name.
Posted

Thanks a lot for the replies. I've done a bit more testing & tweaking and I think I now have the routine working well, so many thanks for the assistance.

 

It turned out the code I went with was similar to my original, the main change being the decrementing method for stepping through the Selection Set.

 

(setq ss (ssget ))
(repeat (setq i (sslength ss))
(setq ent2 (ssname ss (setq i (1- i))))
...do stuff...
)

 

.. Is what I arrived at. It turned out there was no need for the ENTGET (as explained by Lee - thanks a lot for the information & linking the article Lee).

 

The code will eventually become part of a routine that reads ProSteel group data from the 3D model and attaches a hyperlink to the 2D shop drawing based on the mark number of the group. So it should be pretty handy once it is sorted out.

 

Couldn't have done it without you guys, thanks again for all the help.

Posted

Just curious..

 (entsel) on it's own returns for an entity on my testing drawing:
(<Entity name: 7ef032d8> (5.94638 4.47885 0.0))
Hence obviously the (car (entsel))
or more usually: (entget(car(entsel))) to return the dxf codes.

What does  (5.94638 4.47885 0.0)) represent? Coordinates?

The actual coordinates of the entity are: 10.0,5.0,0.0

Posted

Happy Hobbit,

 

They are the coordinates of the cursor location when you clicked.

 

ymg

Posted

Oh.... Thank you. I didn't know that.

 

So no use to man nor beast really?

Posted
Couldn't have done it without you guys, thanks again for all the help.

 

You're most welcome!

 

So no use to man nor beast really?

 

Why do you say that?

 

For example, what if you want the user to select a polyline segment - without the cursor position, how would you know which segment was selected?

Posted

Good point (no pun intended)

 

You win

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...