Author Topic: Cannot run LSP by script  (Read 1053 times)

0 Members and 1 Guest are viewing this topic.

w64bit

  • Newt
  • Posts: 78
Cannot run LSP by script
« on: July 11, 2022, 01:56:48 PM »
I want to run a LSP by a script but the command is not recognized even if LSP it's loaded.
The DELDUPVERTEX command is working if I not run it by script.

https://cadtips.cadalyst.com/polylines/delete-duplicate-vertices-a-polyline?q=polylines/delete-duplicate-vertices-a-polyline&print=1

Code: [Select]
(if (setq poly (ssget "X" '((0 . "LWPOLYLINE")))) (command "DELDUPVERTEX" "ALL" "" "1E-12")))
Is there anything I can do to be able to run it by script?

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Cannot run LSP by script
« Reply #1 on: July 11, 2022, 05:05:03 PM »
you could take the lisp and load it into your AppLoad Startup Suite Contents button. Then have the script call it.
Civil3D 2020

mhupp

  • Bull Frog
  • Posts: 250
Re: Cannot run LSP by script
« Reply #2 on: July 12, 2022, 12:31:01 AM »
you can only run one lisp at a time. So when calling DELDUPVERTEX it pauses your lisp to run DELDUPVERTEX. once its done yours will continue.

Code - Auto/Visual Lisp: [Select]
  1. (if (setq poly (ssget "X" '((0 . "LWPOLYLINE"))))
  2.   (C:DELDUPVERTEX)  ;all and 1e-12 will probably have to be entered manually.
  3. )

w64bit

  • Newt
  • Posts: 78
Re: Cannot run LSP by script
« Reply #3 on: July 12, 2022, 04:22:39 AM »
I started to run in the script:
Code: [Select]
DELDUPVERTEX ALL  1E-12
but if there are no LWPOLYLINE in the drawing, the program closes and ALL is then considered as a command.
Is there any other way to put DELDUPVERTEX in a script and to avoid stopping the script (not running DELDUPVERTEX when there are no LWPOLYLINES)?
Of course, with no manual input (I intend to run this code on multiple files).

baitang36

  • Bull Frog
  • Posts: 213
Re: Cannot run LSP by script
« Reply #4 on: July 13, 2022, 02:02:34 AM »
I want to run a LSP by a script but the command is not recognized even if LSP it's loaded.
The DELDUPVERTEX command is working if I not run it by script.

https://cadtips.cadalyst.com/polylines/delete-duplicate-vertices-a-polyline?q=polylines/delete-duplicate-vertices-a-polyline&print=1

Code: [Select]
(if (setq poly (ssget "X" '((0 . "LWPOLYLINE")))) (command "DELDUPVERTEX" "ALL" "" "1E-12")))
Is there anything I can do to be able to run it by script?

The problem is that function c:deldupvertex has no parameters, and you cannot pass parameters to it. It can only be entered manually, and cannot be called by program.
he feasible way is to modify the definition of this function and implement your requirements in the program? Did you write the source code of this program?

w64bit

  • Newt
  • Posts: 78
Re: Cannot run LSP by script
« Reply #5 on: July 13, 2022, 02:50:24 AM »
No, I didn't write it. I downloaded the FAS from Cadalyst.
« Last Edit: July 13, 2022, 02:54:32 AM by w64bit »

mhupp

  • Bull Frog
  • Posts: 250
Re: Cannot run LSP by script
« Reply #6 on: July 13, 2022, 09:43:27 AM »
try overkill instead of DELDUPVERTEX

w64bit

  • Newt
  • Posts: 78
Re: Cannot run LSP by script
« Reply #7 on: July 15, 2022, 06:07:38 AM »
OVERKILL it messes overlapped plines.
I think that the solution is to change the LSP provided by baitang36 (thank you) by eliminating all manual input.
This lisp it too complicated for me to do the changes. Can anyone please help?
« Last Edit: July 15, 2022, 06:15:24 AM by w64bit »

mhupp

  • Bull Frog
  • Posts: 250
Re: Cannot run LSP by script
« Reply #8 on: July 15, 2022, 08:14:26 AM »
You can limit how overkill works. But if you still want to go the lisp route maybe this would work.
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/duplicate-vertex/m-p/1592378/highlight/true#M206978