TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cmwade77 on October 21, 2020, 07:31:10 PM

Title: Running External Programs
Post by: cmwade77 on October 21, 2020, 07:31:10 PM
I am currently using StartApp to launch an external program; however, I need to wait for that external program to finish its job before my LISP routine continues. I know it would be possible to use DOSLib to do this; however, I would like to avoid dependence on a third party if I can, does anyone have some ideas?

I could potentially loop until a file is created; however, there is the very real possibility that the file won't get created all of the time and would end up in an endless loop, so I would like something with a bit more of a failsafe.
Title: Re: Running External Programs
Post by: framednlv on October 21, 2020, 07:43:16 PM
What happens if you use Start?
Title: Re: Running External Programs
Post by: MP on October 21, 2020, 08:07:17 PM
Use an instance of shell with the wait flag set to true (-1).
Bonus, set the visibility flag to 0 if you to hide execution.
The external program may override the latter.

e.g.

(progn
    (setq shell (vlax-create-object "WScript.Shell"))
    (vl-catch-all-apply 'vlax-invoke (list shell 'run "cmd.exe" 8 -1)))
    (alert "lol, there you are.")
    (vl-catch-all-apply 'vlax-release-object (list shell))
    (princ)
)
Title: Re: Running External Programs
Post by: cmwade77 on October 22, 2020, 02:25:05 PM
What happens if you use Start?
I tried that and it kept launching another session of AutoCAD, no idea why.
Title: Re: Running External Programs
Post by: cmwade77 on October 22, 2020, 05:09:04 PM
Use an instance of shell with the wait flag set to true (-1).
Bonus, set the visibility flag to 0 if you to hide execution.
The external program may override the latter.

e.g.

(progn
    (setq shell (vlax-create-object "WScript.Shell"))
    (vl-catch-all-apply 'vlax-invoke (list shell 'run "cmd.exe" 8 -1)))
    (alert "lol, there you are.")
    (vl-catch-all-apply 'vlax-release-object (list shell))
    (princ)
)


Thank you, that did the trick, I am actively getting there on my routine, I am quite surprised at how well this is working. I will eventually share the whole package, but there are a lot of pieces to it.
Title: Re: Running External Programs
Post by: MP on October 22, 2020, 05:40:14 PM
Thank you, that did the trick

you're most welcome 👍

I am quite surprised at how well this is working

oh ye of little faith 🙃
Title: Re: Running External Programs
Post by: cmwade77 on October 22, 2020, 07:45:11 PM
I am quite surprised at how well this is working

oh ye of little faith 🙃
Considering everywhere says what I am doing is literally impossible, I definitely will admit to having little faith on this one.

When it fully works, I will have an amazing way to make sheet indexes and keep them up to date, including revision numbers inside of blocks in a table.
Title: Re: Running External Programs
Post by: MP on October 22, 2020, 11:01:56 PM
everyone says what I am doing is literally impossible

summary of my career right there, lol :-D

When it fully works, I will have an amazing way to make sheet indexes and keep them up to date, including revision numbers inside of blocks in a table.

That's pretty awesome. I'm honoured I could contribute a little here, a little there.
Title: Re: Running External Programs
Post by: cmwade77 on October 23, 2020, 11:43:41 AM
everyone says what I am doing is literally impossible

summary of my career right there, lol :-D

When it fully works, I will have an amazing way to make sheet indexes and keep them up to date, including revision numbers inside of blocks in a table.

That's pretty awesome. I'm honoured I could contribute a little here, a little there.
It will be once all is said and done, there are a lot of moving pieces and unfortunately, using the actual Revision Number field in the sheet set manager doesn't seem to work well, there is something funky with that field. I will keep at it, as eventually I want to use that, but in the meanwhile I have a work around.
Title: Re: Running External Programs
Post by: cmwade77 on October 26, 2020, 07:32:46 PM
everyone says what I am doing is literally impossible

summary of my career right there, lol :-D

When it fully works, I will have an amazing way to make sheet indexes and keep them up to date, including revision numbers inside of blocks in a table.

That's pretty awesome. I'm honoured I could contribute a little here, a little there.
As promised, I have uploaded my routine, but it is slower than I would like when creating the sheet index using larger DST files. Smaller ones are ok, but larger are problematic, it has been posted to: https://www.theswamp.org/index.php?topic=56345.new#new

I am hoping to figure out why reading the resulting file and creating a table is so slow.
Title: Re: Running External Programs
Post by: Grrr1337 on October 27, 2020, 05:09:55 PM
I am hoping to figure out why reading the resulting file and creating a table is so slow.

I think that you have forgot something (https://www.theswamp.org/index.php?topic=54314.msg588922#msg588922).

 :whistling:
Title: Re: Running External Programs
Post by: cmwade77 on October 27, 2020, 05:14:13 PM
I am hoping to figure out why reading the resulting file and creating a table is so slow.

I think that you have forgot something (https://www.theswamp.org/index.php?topic=54314.msg588922#msg588922).

 :whistling:
Actually, I added that in as well and it still is slow.

I made some more changes and realized it wasn't working before, but now I get automation error when I use it.
Title: Re: Running External Programs
Post by: cmwade77 on October 27, 2020, 06:54:37 PM
It seems the slowness is in the reading of the text file, I have attached an updated version of the .LSP file and a sample copy of the fields file it needs to read in.