Scoutr4 Posted November 11, 2022 Posted November 11, 2022 I think I'm making a mistake in the foreach line or the list data but I couldn't fix the error. Can someone check? When i click to mainline it should list all lines and arcs. I tried LM:ListDifference but it gives error. It didn't fit the working logic. (defun c:test() (setq checknum 0) (setq mylist (ssget '((0 . "LINE")))) (while (< checknum 1) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex mylist))) (setq vla (vlax-ename->vla-object ent) start (vlax-curve-getStartPoint vla) end (vlax-curve-getendpoint vla)) (setq midarc (ssget "_C" start end '(( 0 . "ARC")))) (setq sline (ssget "_C" start start '(( 0 . "LINE,ARC")))) (setq eline (ssget "_C" end end '(( 0 . "LINE,ARC")))) (setq oldlist (list midarc sline eline)) (setq list1 (sslength mylist)) (setq list2 (sslength oldlist)) (if (/= list1 list2) (progn (setq mylist (append mylist oldlist))) (progn (setq checknum 1))) )) (princ) ) Example.dwg Quote
mhupp Posted November 12, 2022 Posted November 12, 2022 Don't know what your trying to do but here are a few things. Your using sslength on a list not a selection set. oldlist is a list of entity names so you need to use length (setq oldlist (list midarc sline eline)) could return nil nil nil making (setq list2 (length oldlist)) would always at least be 3 never 0 also (if (/= list1 list2) is just comparing counts not the actual entity's so they could be equal and things wouldn't be added to the selection set. You probably want to build a point list then use that with ssget but with the fence option. "_F" This will highlight anything crossing lines you select. (defun c:test (/ mylist ent vla start end coords SS) ;you should always declare your variables (setq mylist (ssget '((0 . "LINE")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex mylist))) (setq vla (vlax-ename->vla-object ent) start (vlax-curve-getStartPoint vla) end (vlax-curve-getendpoint vla) ) (if (not (member start coords)) (setq coords (cons start coords)) ) (if (not (member end coords)) (setq coords (cons end coords)) ) ) (setq SS (ssget "_F" coords '((0 . "LINE,ARC")))) (sssetfirst nil SS) (princ) ) Quote
Scoutr4 Posted November 13, 2022 Author Posted November 13, 2022 (edited) Hi mhupp, I solved the problem. I wanted to reply to your comment. If I reply to your comments in order I agree with your comment, but I was getting the same error even if I used lenght. I gave up on creating lists and combined the 2 ssget selections using the ssadd function. Yes i noticed that. I gave up using this method. Because ssget was not working efficiently when it was nil. I set up an equation like this (or (setq midarc (ssget "_C" start end '(( 0 . "ARC"))))(setq x "hello")) In the next steps I set a condition for the value of x so that I have control of the ssget selections. I couldn't make the choices I wanted with the fence option. When I typed (list end end) instead of coords, it was giving an error because it clicked on the same spot. That's why I didn't use the fence option. Edited November 13, 2022 by Scoutr4 Quote
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.