GregGleason Posted March 16, 2018 Share Posted March 16, 2018 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 16, 2018 Share Posted March 16, 2018 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) ) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 16, 2018 Author Share Posted March 16, 2018 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 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 16, 2018 Share Posted March 16, 2018 (> len mymin) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 16, 2018 Author Share Posted March 16, 2018 (> len mymin) Perfect! What would I need to do to add code to change the selection to another layer? Greg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 16, 2018 Share Posted March 16, 2018 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) ) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 16, 2018 Author Share Posted March 16, 2018 Again, perfect! Now, is there a command to unselect the objects after it has finished? Greg Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 16, 2018 Share Posted March 16, 2018 Again, perfect! Now, is there a command to unselect the objects after it has finished? Greg Press ESC Or remove: (sssetfirst nil ss) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 16, 2018 Author Share Posted March 16, 2018 Press ESC Or remove: (sssetfirst nil ss) Thank you, sir! Greg Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 17, 2018 Share Posted March 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 17, 2018 Share Posted March 17, 2018 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) ) Quote Link to comment Share on other sites More sharing options...
GregGleason Posted March 17, 2018 Author Share Posted March 17, 2018 Thank you Lee and Tharwat! I made the recommended changes and it works flawlessly. Greg Quote Link to comment Share on other sites More sharing options...
uzumaki narudin Posted December 23, 2021 Share Posted December 23, 2021 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.