TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: tiberian1138 on May 25, 2021, 09:32:48 AM
-
I am trying to develop a list routing to automate the joining of lines. Problem is that when I use JOIN in the lisp routine it gives me a different set of options than when I use JOIN at the Command prompt.
Inside the Lisp routine it returns - Select source object:
When typed at the Command prompt it retunes - Select source object or multiple objects to join at once:
I have tried all the variations of "Join" that I know of and it always remains the same. Below is the lisp routine I am working with. The purpose is to de-curve a polyline, explode it and then join previous to remove all of the individual segments. It works flawlessly to the point of the "Join" command and then fails.
(princ "\nSelect plines to DECURVE: ") )
EDIT (John): Added code tags.
-
Untested, but according to my knowledge, it should work...
(defun C:DC (/ *error* qaf a b)
(defun *error* (m)
(if qaf (setvar 'qaflags qaf))
(if m (prompt m))
(princ)
)
(setq qaf (getvar 'qaflags))
(setvar 'qaflags 1)
(princ "\nSelect pline to DECURVE: ")
(setq a (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE"))))
(setq b (ssname a 0))
(command "_.pedit" b "d" "")
(command "_.explode" b)
(command "_.join" "p" "")
(*error* nil)
)
BTW. Always localize your variables...
-
I am trying to develop a list routing to automate the joining of lines. Problem is that when I use JOIN in the lisp routine it gives me a different set of options than when I use JOIN at the Command prompt.
Inside the Lisp routine it returns - Select source object:
When typed at the Command prompt it retunes - Select source object or multiple objects to join at once:
I have tried all the variations of "Join" that I know of and it always remains the same. Below is the lisp routine I am working with. The purpose is to de-curve a polyline, explode it and then join previous to remove all of the individual segments. It works flawlessly to the point of the "Join" command and then fails.
(defun C:DC()
(princ "\nSelect plines to DECURVE: ")
(setq a (ssget))
(setq b (ssname a 0))
(command "_.pedit" b "d" "")
(command "_.explode" b)
(command "_.join" p)
(princ)
)
Also look into (initcommandversion).
-
Untested, but according to my knowledge, it should work...
.....
BTW. Always localize your variables...
Thanks. I tried it and it still fails at the point of executing the JOIN command.
Also, I am still VERY new to writing lisp routines and honestly don't understand your comment about localizing my variables.
-
So with the insight given above, I was able to figure out what I was doing wrong. Here is the corrected routine that now works as I wanted it to. But I am always willing to accept additional positive and productive critiquing.
(princ "\nSelect Plines to Decurve: ") )
EDIT (John): Added code tags.
-
I am still VERY new to writing lisp routines and honestly don't understand your comment about localizing my variables.
Lee Mac explains localizing your variables in his Lisp Tutorials: http://lee-mac.com/localising.html
It will save you a lot of headaches in the future.