Jump to content

Selection Set based on handle


MJLM

Recommended Posts

I think that it's bad idea to colorize entities... Please, test this code, I think it's better approach to select entities...

 

I have to say that it seems to work great! Only one thing, can we make it select all entities created after the one selected rather than all before?

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • MJLM

    8

  • Tharwat

    6

  • MSasu

    4

  • marko_ribar

    4

Top Posters In This Topic

Here you go... You have to have Express Tools installed - it uses (acet-ss-remove) function...

 

(defun c:selaents ( / _entnext ss e ent )

 (defun _entnext ( en / ee )
   (setq ee en)
   (while (wcmatch (cdr (assoc 0 (entget (setq ee (entnext ee))))) "ATTRIB,VERTEX,SEQEND"))
   ee
 )
 
 (setq ss (ssadd))
 (setq e (entnext))
 (setq ent (car (entsel "\nPick entity for selecting entities created after picked entity")))
 (while (not (equal e ent))
   (ssadd e ss)
   (setq e (_entnext e))
 )
 (sssetfirst nil (ssdel ent (acet-ss-remove ss (ssget "_X"))))
 (princ)
)

Edited by marko_ribar
Link to comment
Share on other sites

Both my codes changed to accept condition first-last entity picked... Test it now, please...

 

Sorry for inconvenience, M.R.

Link to comment
Share on other sites

Both my codes changed to accept condition first-last entity picked... Test it now, please...

 

Sorry for inconvenience, M.R.

 

I played with your code a bit and I came up with this simplified code which seems to work fine to get all entities from the one I select.

 

(defun c:test (/)

(setq ss (ssadd))
(setq e (entlast))

(setq ent (car (entsel "\nPick line for selecting entities created after picked line: ")))

(while (not (equal ent e))
	(ssadd ent ss)
	(setq ent (entnext ent))
)

(sssetfirst nil ss)
)

 

I m posting this code not to compare. I m just trying to understand what do I need this wcmatch check. What does "ATTRIB,VERTEX,SEQEND" means?

Link to comment
Share on other sites

I m posting this code not to compare. I m just trying to understand what do I need this wcmatch check. What does "ATTRIB,VERTEX,SEQEND" means?

 

If checked entity is parent entity that is if it contains child entities like ATTRIB or VERTEX entities (3dpolyline - VERTEX, 2d heavy polyline, pellipse which is type of 2d heavy polyline - VERTEX, insert - block with ATTRIB, dimension - block with ATTRIB, leader - block with ATTRIB), (entnext e) function will return - if e argument is one of mentioned entities, very next child entity that is VERTEX or ATTRIB, and these entities you can't select... Actually you have to step through them until next parent entity is found and that entity is then selectable... Very next parent entity after child entity such as SEQEND entity which comes after ATTRIB or VERTEX entity is entity that we are searching - it's selectable and you can add it into sel. set with (ssadd) function... If searched entites aren't parent - simple entities like LINE, CIRCLE, ARC, ELLIPSE, SPLINE, HELIX, LWPOLYLINE, INSERT without ATTRIBUTES, XLINE, RAY, TEXT, DTEXT, MTEXT... then (entnext e) will return very next BASE entity which can be simple entity mentioned or again parent, but if it's parent then you have to step through all it's child entities with (entnext) until next simple or parent BASE entity is reached... Only BASE entities you can add to sel. set which can then be used into selecting on screen with (sssetfirst) function...

 

I hope I clayfied why (wcmatch) function was needed - to find with (_entnext) function which was defined as sub-function very next BASE entity; (while) loop used inside this sub-function was checking for all child entities and after SEQEND entity, next BASE entity is returned as result of evaluation of (_entnext) sub-function... Return value of very next base entity is last variable inside (_entnext) - variable "ee"...

 

HTH, M.R.

Edited by marko_ribar
Link to comment
Share on other sites

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...