Jump to content

Selection Set based on handle


MJLM

Recommended Posts

I am trying to select all lines that have a handle greater than given. I type

 

(setq hdl (getstring "\nEnter handle: "))

(setq lngrss (ssget "X" (list (cons 0 "LINE") (cons -4 ">") (cons 5 hdl)))

 

However this returns nil.

 

How could I do this?

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

What do you mean by "handle"

Usually people filter by layer, lineweight, linetype....

 

:)

 

Handle is a unique number or a mixed value of chars and numbers in a string type that can not be duplicated with any other object in the same drawing .

Link to comment
Share on other sites

As Tharwat said this is a unique identifier of any entity in the drawing. It is stored always with flag "5" in hexadecimal format. I cant filter according to line type, color or layer as my lines share the same properties.

Link to comment
Share on other sites

MJLM, the handle is a string representing a hexadecimal number, so I'm not sure if you can reliable define a filter to sort all entities that have thier handle smaller than a certain value.

To parse entities by their creation order I suggest to rather check the ENTNEXT function.

Link to comment
Share on other sites

So it's like the ename?

The difference between handle and entity name is that first is invariable, while the second will be different in each session for same entity. However, both were unique in one drawing.

Link to comment
Share on other sites

Try this code to highlight a line if it match its handle of course .

 

You need to regen to unhighlight the entity back if any line entity highlighted .

 

(if (and (/= "" (setq hdl (getstring "\nEnter handle: ")))
        (setq go t s (ssget "_X" '((0 . "LINE"))))
   )
 ((lambda (i /)
    (while (and go (setq n (ssname s (setq i (1+ i)))))
      (if (vl-some '(lambda (u) (and (eq (car u) 5) (eq (cdr u) (strcase hdl)))) (entget n))
        (progn (redraw n 3) (setq go nil))
      )
    )
  )
   -1
 )
)

Link to comment
Share on other sites

The difference between handle and entity name is that first is invariable, while the second will be different in each session for same entity. However, both were unique in one drawing.

Thanks for clearing this up guys :)

Link to comment
Share on other sites

From the Swamp

 

http://www.theswamp.org/index.php?action=post;quote=98894;topic=7796.0;last_msg=98928

 

 

author=Jürg Menzi

 

In addition to the other answers...

From help:

The ssget function recognizes all group codes except entity names (group –1), handles (group 5), and xdata codes (groups greater than 1000).

 

I think that this still holds true. -David

Link to comment
Share on other sites

MJLM , did you see my post No 9 ? was it helpful at any ?

 

Yes, thank you but this doesnt quite work for me cause I already pick the entity myself. I want to see all other lines created after the one I pick.

I managed to solve that, maybe not fully but it s on the right direction, by colorizing all lines in the drawing from color A to color B. So cold colors are past and warm colors are present. It kinda help me do what I want.

Link to comment
Share on other sites

I want to see all other lines created after the one I pick.

May achieve that by parsing drawing's database using ENTNEXT and the entity name of picked line as starting argument.

Link to comment
Share on other sites

Yes, thank you but this doesnt quite work for me cause I already pick the entity myself. I want to see all other lines created after the one I pick.

I managed to solve that, maybe not fully but it s on the right direction, by colorizing all lines in the drawing from color A to color B. So cold colors are past and warm colors are present. It kinda help me do what I want.

 

I see you have changed your mind cause what you have just said is different than the first post .

Link to comment
Share on other sites

Not necesarily, Tharwat. Seems that OP was hopping to get all entities added after a particular one based on the assumption that their handles will always be given in an ascending order.

Link to comment
Share on other sites

Not necesarily, Tharwat.

How is that not necessarily ? I did give an example of codes that related to their first post and now it looks wrong because they changed their mind and searching for something else.

Link to comment
Share on other sites

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

 

(defun c:selpents ( / _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 before picked entity")))
 (while (not (equal e ent))
   (ssadd e ss)
   (setq e (_entnext e))
 )
 (sssetfirst nil ss)
 (princ)
)

Edited by marko_ribar
Link to comment
Share on other sites

I see you have changed your mind cause what you have just said is different than the first post .

 

Yes, that was a work around I thought and it works. It is not the best solution

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