Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Invoke LSP inside of SCR

4 REPLIES 4
Reply
Message 1 of 5
tstorzuk
298 Views, 4 Replies

Invoke LSP inside of SCR

A little help please,

 

I'm trying to automate converting STP files a bit more from my last post;

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-for-batch-conversion-of-stp-f...

 

What I'd like to do is run a LISP routine at a certain point in the script file so that it runs and then the script file continues on. However it's not working out right. So I must be missing something, and I can't figure it out on my own.

 

Here's an example of the script file;

_Filedia 0
_QNEW

_IMPORT "C:\TEMP\CONVERT\316L-12-VCR-3-18MA-MIGH-SwagelokCompany-3D-05-24-2023.stp"
IMPORTTRANSLATIONRESULT
_SAVEAS

"C:\TEMP\CONVERT\316L-12-VCR-3-18MA-MIGH-SwagelokCompany-3D-05-24-2023.stp.dwg"
_QNEW

_IMPORT "C:\TEMP\CONVERT\316L-12-VCR-3-18MA-SC06-MIGH-SwagelokCompany-3D-05-24-2023.stp"
IMPORTTRANSLATIONRESULT
_SAVEAS

"C:\TEMP\CONVERT\316L-12-VCR-3-18MA-SC06-MIGH-SwagelokCompany-3D-05-24-2023.stp.dwg"
_Filedia 1

In between the save and the _QNEW, I'd like to invoke a LISP that is started at the command prompt by typing SAVE-01 (attached for reference). However every way I try and insert the command to invoke the LISP, the rest of the script doesn't function properly.

 

Can anyone see what I'm missing?

Tags (4)
4 REPLIES 4
Message 2 of 5
paullimapa
in reply to: tstorzuk

If you look at the end of the lisp file you'll see that it does a save and then closes out of the drawing.

If you don't want this behavior then you'll have to modify the lisp file by commenting out these lines:

paullimapa_0-1686800467544.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 5
tstorzuk
in reply to: paullimapa

@paullimapa 

 

That's exactly what the LISP is supposed to do.

 

I need a way to invoke (run) the LISP within the Script, and then have the Script continue.

 

What currently happens, is a batch of STP files are imported into AutoCAD, and left open. I then have to invoke the LISP command myself. The problem with this is that after about 200 files being opened, AutoCAD crashes. I have batches of more than a thousand STP files at a time. I'd rather not have to try splitting them up into groups of 150+ to get them all to run.

 

What I'd like to happen is one file imports, runs the LISP, closes and then the next file opens, etc....until all files have been imported, cleaned up by the LISP and closed.

Message 4 of 5
CADaSchtroumpf
in reply to: tstorzuk

@paullimapa 's answer makes sense because if you close your drawing in the lisp the script won't be able to continue...

See what your lisp should contain:

(defun C:SAVE-01 ( / )
  (command "_.explode" "_all" "")
  (command "_.setbylayer" "_all" "" "_y" "_y")
  (command "_.ucs" "_world")
  (command "_.-layer" "_th" "*" "_on" "*" "")
  (command "_snap" "_off")
  (command "_.grid" "_off")
  (command "_.-view" "_top")
  (command "_.-purge" "_B" "*" "_no")
  (command "_.-purge" "_DE" "*" "_no")
  (command "_.-purge" "_D" "*" "_no")
  (command "_.-purge" "_G" "*" "_no")
  (command "_.-purge" "_LA" "*" "_no")
  (command "_.-purge" "_LT" "*" "_no")
  (command "_.-purge" "_MA" "*" "_no")
  (command "_.-purge" "_MU" "*" "_no")
  (command "_.-purge" "_P" "*" "_no")
  (command "_.-purge" "_SH" "*" "_no")
  (command "_.-purge" "_ST" "*" "_no")
  (command "_.-purge" "_M" "*" "_no")
  (command "_.-purge" "_SE" "*" "_no")
  (command "_.-purge" "_T" "*" "_no")
  (command "_.-purge" "_V" "*" "_no")
  (command "_.-purge" "_R" "*" "_no")
  (command "_.-purge" "_Z")
  (command "_.-purge" "_E")
  (command "_.-purge" "_O")
)


And your script for example

_Filedia 0
_QNEW

_IMPORT "C:\TEMP\CONVERT\316L-12-VCR-3-18MA-MIGH-SwagelokCompany-3D-05-24-2023.stp"
IMPORTTRANSLATIONRESULT
(C:SAVE-01)
_SAVEAS

"C:\TEMP\CONVERT\316L-12-VCR-3-18MA-MIGH-SwagelokCompany-3D-05-24-2023.stp.dwg"
_QNEW

_IMPORT "C:\TEMP\CONVERT\316L-12-VCR-3-18MA-SC06-MIGH-SwagelokCompany-3D-05-24-2023.stp"
IMPORTTRANSLATIONRESULT
(C:SAVE-01)
_SAVEAS

"C:\TEMP\CONVERT\316L-12-VCR-3-18MA-SC06-MIGH-SwagelokCompany-3D-05-24-2023.stp.dwg"
_Filedia 1

This if the SAVE-01 lisp is automatically loaded
I can't test this answer, but it should work

Message 5 of 5
paullimapa
in reply to: tstorzuk

another option is to make sure only 1 dwg is opened & then add at top of script file line:

SDI 1

then at end of script file add line:

SDI 0

Now when you run the script file & the lisp file it should only allow a single dwg to open, run operations, save & then open the next dwg while closing the current dwg and so on...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report