Jump to content

Recommended Posts

Posted

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?

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • MJLM

    8

  • Tharwat

    6

  • MSasu

    4

  • marko_ribar

    4

Top Posters In This Topic

Posted

What do you mean by "handle"

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

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

Posted

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.

Posted
So it's like the ename?

 

You can say that .

 

Handle somehow it means the ear to users to catch with . :lol:

Posted

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.

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

Posted

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

Posted
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 :)

Posted

I think that this still holds true. -David

 

Apparently and unfortunately yes.

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

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

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

Posted

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.

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

Posted (edited)

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

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