Author Topic: Join command in a lisp routine results in different options.  (Read 2401 times)

0 Members and 1 Guest are viewing this topic.

tiberian1138

  • Mosquito
  • Posts: 3
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.

Code - Auto/Visual Lisp: [Select]
  1. (defun C:DC()
  2.  (princ "\nSelect plines to DECURVE: ")
  3.  (setq a (ssget))
  4.  (setq b (ssname a 0))
  5.  (command "_.pedit" b "d" "")
  6.  (command "_.explode" b)
  7.  (command "_.join" p)
  8.  (princ)
  9. )



EDIT (John): Added code tags.

 
« Last Edit: May 25, 2021, 03:15:43 PM by John Kaul (Se7en) »

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Join command in a lisp routine results in different options.
« Reply #1 on: May 25, 2021, 10:20:58 AM »
Untested, but according to my knowledge, it should work...

Code: [Select]
(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...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Join command in a lisp routine results in different options.
« Reply #2 on: May 25, 2021, 10:28:15 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.

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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

tiberian1138

  • Mosquito
  • Posts: 3
Re: Join command in a lisp routine results in different options.
« Reply #3 on: May 25, 2021, 11:33:59 AM »
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.


tiberian1138

  • Mosquito
  • Posts: 3
Re: Join command in a lisp routine results in different options.
« Reply #4 on: May 25, 2021, 11:57:18 AM »
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.

Code - Auto/Visual Lisp: [Select]
  1. (defun C:DC()
  2.  (princ "\nSelect Plines to Decurve: ")
  3.  (setq a (ssget))
  4.  (setq b (ssname a 0))
  5.  (command "_.pedit" b "d" "")
  6.  (command "_.explode" b "")
  7.  (command "_.join" "p" "")
  8.  (princ)
  9. )


EDIT (John): Added code tags.
« Last Edit: May 25, 2021, 03:14:39 PM by John Kaul (Se7en) »

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Join command in a lisp routine results in different options.
« Reply #5 on: May 29, 2021, 09:49:56 AM »
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.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D