TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: vincent.r on August 17, 2019, 02:40:53 AM
-
(if (/= (vl-string-search "SV" do2) nil)
(progn
(setq ndo2 (strcat "_" (substr do2 1 2) (substr do2 (strlen do2) 1)))
(setq csvlist (cons (strcat "[_SVSIM2]" ndo2) csvlist))
)
(setq ndo2 (strcat "_" (substr do2 1 3) (substr do2 (strlen do2) 1)))
(setq csvlist (cons (strcat "[_SVSIM2]" ndo2) csvlist))
)
Why it is giving me "; error: syntax error" ? Its strange for me. Any help will be highly appreciated.
-
(if (/= (vl-string-search "SV" do2) nil)
(progn
(setq ndo2 (strcat "_" (substr do2 1 2) (substr do2 (strlen do2) 1)))
(setq csvlist (cons (strcat "[_SVSIM2]" ndo2) csvlist))
)
(progn
(setq ndo2 (strcat "_" (substr do2 1 3) (substr do2 (strlen do2) 1)))
(setq csvlist (cons (strcat "[_SVSIM2]" ndo2) csvlist))
)
)
Why it is giving me "; error: syntax error" ? Its strange for me. Any help will be highly appreciated.
Due to extra expressions ...
-
You can go with Tharwat (better solution) or eliminate the progn's entirely and run the setq's together
-
Since the only difference between the then and else arguments is the number of characters supplied to the first substr expression, the code could be condensed to:
-
Thanks Tharwat and Dlanore for simple solution. Lee you are always explanative. you are rocking as usual.
I stuck in one more place. I am trying to find closest text from a another text's co-ordinate. I want to add just distance to list and not with Ename to compare closest one. Screenshot also attached.
Code -
(while (/= (sslength motorassocvfd) 0)
(setq checkvfd (ssname motorassocvfd 0))
(if (vl-string-search "VFD IP " (cdr (assoc 1 (entget checkvfd))) 0)
(progn
(setq distvfd (distance (car motorcoord) (cdr (assoc 10 (entget checkvfd)))))
(setq checkdvfd (cons distvfd checkvfd))
(setq Enamesvfd (cons checkvfd Enamesvfd))
)
)
(setq motorassocvfd (ssdel checkvfd motorassocvfd))
)
(setq found (vl-position (apply 'min checkdvfd) checkdvfd))
(setq a_vfd (cdr (assoc 1 (entget (nth found ENamesvfd)))))
-
Hi,
Try it this way and the variable name 'closest' should obtain the shortest distance.
(if closest
(if (< distvfd closest
) (setq closest distvfd
)) )
)
)
-
Thanks Tharwat. Your code is working perfect. You are great Guru.
-
You're most welcome.