As was introduced in previous DraftSight LISP blogs, like https://swym.3ds.com/#post:15937 or https://swym.3ds.com/#post:7040
the RunCommand () method can be used for loading and running a LISP script from an API program, as in this C# snippet:
…
dsApp.RunCommand("(load \\"C:\\\\\\\\abc.lsp\\" ) \\n", false); // load the C:\\abc.lsp script
dsApp.RunCommand("ABC", false); //run the abc.lsp .
…
How can a LISP procedure, command or a script, return values to an API program that executed it, or launch another DraftSight API or just a Windows program?
The LISP startapp, write-line, and other commands* can be useful.
* To review more related LISP commands, in the LISP (Premium) DraftSight Help, Search, enter the 'Windows' keyword and review the search result.
Using the startapp function to execute a Windows application can be hlpful:
The startapp format is: (startapp application [file_name])
In which the arguments are:
The argument application specifies the Windows application to start. The argument must be a string. If application contains no valid path specification, the function browses the environment variable PATH for the application.
Another useful command is the write-line .
The write-line function writes the specified string to the file that an API application can then read. The command is specified by file_descriptor or displays it in the Command Window.
Return Value
The function returns string.
Examples
: (write-line "ABC")
"ABC"
: (setq fd (open "abc.txt" "w")) ;;; fd is the file descriptor
: (write-line "ABC" fd)
"ABC"
