Jump to content

SSGET - Polyline Select by Range in Length


Recommended Posts

Posted

Here is the code that works so far:

 

(setq ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))

What I want to do is limit the selection to a range of the polyline length, let's say 0.053 to 0.059 inclusive.

 

Is that code possible?

 

Greg

Posted

Hi,

 

Try this:

(defun c:Test ( / in ss en len)
 (if (setq in -1 ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))
   (while (setq en (ssname ss (setq in (1+ in))))
     (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))
     (or (or (and (< len 0.059) (> len 0.053) )
             (equal len 0.053 1e-4)
             (equal len 0.059 1e-4)
             )
         (ssdel en ss)
         )
     )
   )
 (sssetfirst nil ss)
 (princ)
 )

Posted

I did a minor code change on what you did Tharwat:

 

(defun c:Test ( / in ss en len mymin mymax)
 (setq mymin 0.053)
 (setq mymax 0.059)
 (if (setq in -1 ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))
   (while (setq en (ssname ss (setq in (1+ in))))
     (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))
     (or (or (and (< len mymin) (< len mymax))
             (equal len mymin 1e-4)
             (equal len mymax 1e-4)
             )
         (ssdel en ss)
         )
     )
   )
 (sssetfirst nil ss)
 (princ)
 )

The result was that it captured every other object. Strange on why it skipped like that. All of the lines but one are 0.0547 and the remaining one is 0.0581.

 

Greg

Posted
(> len mymin)

 

Perfect!

 

What would I need to do to add code to change the selection to another layer?

 

Greg

Posted
Perfect!

 

What would I need to do to add code to change the selection to another layer?

 

Greg

 

You would need something like the following.

NOTE: Localize the variable 'get' in the routine.

(if (or (and (< len 0.059) (> len 0.053))
       (equal len 0.053 1e-4)
       (equal len 0.059 1e-4)
   )
 (entmod (subst '(8 . "[color="magenta"]LayerName[/color]")
                (assoc 8 (setq [color="red"]get [/color](entget en)))
                [color="red"]get[/color]
         )
 )
 (ssdel en ss)
)

Posted

Again, perfect!

 

Now, is there a command to unselect the objects after it has finished?

 

Greg

Posted
Again, perfect!

 

Now, is there a command to unselect the objects after it has finished?

 

Greg

 

Press ESC ;) Or remove:

(sssetfirst nil ss)

Posted
Press ESC ;) Or remove:
(sssetfirst nil ss)

 

Thank you, sir!

 

Greg

Posted
Hi,

 

Try this:

(defun c:Test ( / in ss en len)
 (if (setq in -1 ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))
   (while (setq en (ssname ss (setq in (1+ in))))
     (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))
     (or (or (and (< len 0.059) (> len 0.053) )
             (equal len 0.053 1e-4)
             (equal len 0.059 1e-4)
             )
         (ssdel en ss)
         )
     )
   )
 (sssetfirst nil ss)
 (princ)
 )

 

This method will skip the entity following the entity removed from the set due to the reassignment of selection set indices.

Posted
This method will skip the entity following the entity removed from the set due to the reassignment of selection set indices.

 

Thank you Lee for paying my attention to this essential processing matter.

 

@Greg,

 

Please consider the following routine and I did remove the highlighting codes as you have requested earlier and ronjonp gratefully answered your question.

 

(defun c:Test ( / in ss en get len)
 (if (setq in -1 ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))
   (while (setq en (ssname ss (setq in (1+ in))))
     (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))
     (and (or (and (< len 0.059) (> len 0.053))
              (equal len 0.053 1e-4)
              (equal len 0.059 1e-4)
              )
          (entmod (subst '(8 . "LayerName") (assoc 8 (setq get (entget en))) get))
          )
     )
   )
 (princ)
 )

Posted

Thank you Lee and Tharwat!

 

I made the recommended changes and it works flawlessly.

 

Greg

  • 3 years later...
Posted
On 3/17/2018 at 10:58 PM, Tharwat said:

 

Thank you Lee for paying my attention to this essential processing matter.

 

@Greg,

 

Please consider the following routine and I did remove the highlighting codes as you have requested earlier and ronjonp gratefully answered your question.

 

 


(defun c:Test ( / in ss en get len)
 (if (setq in -1 ss (ssget "_C" '(7.244 2.071) '(16.665 10.003) '((0 . "*POLYLINE") (8 . "PIPE-IsoPrim"))))
   (while (setq en (ssname ss (setq in (1+ in))))
     (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en)))
     (and (or (and (< len 0.059) (> len 0.053))
              (equal len 0.053 1e-4)
              (equal len 0.059 1e-4)
              )
          (entmod (subst '(8 . "LayerName") (assoc 8 (setq get (entget en))) get))
          )
     )
   )
 (princ)
 )
 

 

sir, how about multiple specific length ? 

thanks in advance.

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