LSP running as script works in Script pro when running Acad.EXE but fails when running in the accoreconsole

LSP running as script works in Script pro when running Acad.EXE but fails when running in the accoreconsole

gv6823otG42ZL
Enthusiast Enthusiast
1,215 Views
17 Replies
Message 1 of 18

LSP running as script works in Script pro when running Acad.EXE but fails when running in the accoreconsole

gv6823otG42ZL
Enthusiast
Enthusiast

Hi Community! I recently was given a LSP program that runs a variety of commands. Long story short, when I run the LSP command individually, it works awesome. When I run this LSP in a script under Script PRO using ACAD.exe as the application version, this also runs the LSP perfectly fine. When I try to run this as a batch file through the accoreconsole.exe, it provides me with this error. My goal is to be able to run this batch file and have it run through the folder of drawings and apply the script without opening autoCAD each time and instead, run it in the background. I have included a snip of the error as well as the section of code where it is failing at. Any suggestions? Has this been heard of before. Any input would help a lot, as I am very new to LSP programming.

 

gv6823otG42ZL_0-1692804976685.png

 

0 Likes
Accepted solutions (1)
1,216 Views
17 Replies
Replies (17)
Message 2 of 18

paullimapa
Mentor
Mentor

could be that's not supported in accoreconsole.exe

try replacing the two functions that uses that with this:

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lsp-running-as-script-works-in-script-pro-when-running-acad-exe/m-p/12191511#M453752
;=== This function retrieves the value of the specified attribue on a block ===================================
(defun GetTagVal (ent tag / get val)
 ;; ent = Block entity name with Attribute
 ;; tag = Attribute Tag name
   (while (/= (cdr (assoc 0 (setq get (entget (setq ent (entnext ent)))))) "SEQEND")
     (if (= (cdr (assoc 2 get)) tag) (setq val(cdr (assoc 1 get))))
   )
 val
)
;=== This function fills in the value of the specified attribue on a block ===================================
(defun SetTagVal (ent tag val / get)
 ;; ent = Block entity name with Attribute
 ;; tag = Attribute Tag name
 ;; val = New Attribute Value
   (while (/= (cdr (assoc 0 (setq get (entget (setq ent (entnext ent)))))) "SEQEND")
     (if (= (cdr (assoc 2 get)) tag) (entupd(entmod (subst (cons 1 val) (assoc 1 get) get))))
   )
)

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

now I am getting this ??

gv6823otG42ZL_1-1692820919327.png

 

 

0 Likes
Message 4 of 18

paullimapa
Mentor
Mentor

your lisp might be calling for that some where else.

how's about posting the entire lisp function for us to take a look at?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

I have attached the LSP program. Any help would be great!

0 Likes
Message 6 of 18

paullimapa
Mentor
Mentor

So I see several places where that function is called in your lisp code.

But doing further search on-line for "autolisp getPropertyValue accoreconsole" I came across this thread:

Solved: Re: Equivalent to getpropertyvalue in accoreconsole - Autodesk Community - AutoCAD

Perhaps the missing link may be just a matter of adding this line in your script before running your lisp:

(command "_.arx" "Load" "acapp.arx")

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

WE ARE GETTING SOMEWHERE!!. Its now running but for some reason it isn't saving the changes. I have included my script as well as the batch file I am running. The batch text is listed below:

 

rem test.bat
@Anonymous off
cls
echo
echo
echo
echo
pause

:: AutoCAD Console path (change according to AutoCAD version)
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2022\accoreconsole.exe"

:: Path of the folder containg the files (to change)
set "source=Z:\u7626\TEST SCRIPT"

:: Path of the script to run(to change)
set script="C:\Users\u7626\OneDrive\GRE LSP ROUTINE\newloader.scr"

FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%

:: Comment the following line to autmatically close the console
pause

 

 

 

 

the script is listed below:

(command "_.arx" "Load" "acapp.arx")
(LOAD "C:/Users/u7626/OneDrive/GRE LSP ROUTINE/GRE1_as_run.lsp")
(gre1)
save

0 Likes
Message 8 of 18

paullimapa
Mentor
Mentor

replace 

save

with 

_.qsave

and make sure there's another empty line below to represent a return executing the previous line


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

I tried that and it still isn't saving. See below to what the cmmd promt is doing now.

 

 

ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
Press any key to continue . . .
Redirect stdout (file: C:\Users\u7626\AppData\Local\Temp\accc197922).
AcCoreConsole: StdOutConsoleMode: processed-output: enabled,auto
AutoCAD Core Engine Console - Copyright 2021 Autodesk, Inc. All rights reserved. (S.173.0.0)

Execution Path:
C:\Program Files\Autodesk\AutoCAD 2022\accoreconsole.exe
Current Directory: C:\Users\u7626\OneDrive\GRE LSP ROUTINE

Version Number: S.173.0.0 (UNICODE)
LogFilePath has been set to the working folder.
Loading AEC Base...
Loading AEC Base Extended...
Loading AEC Core...
Loading AEC Project Base...
Loading AEC Architectural Base...
Loading AEC Schedule...
Regenerating model. may not plot
Press ENTER to continue:
**** System Variable Changed ****
1 of the monitored system variables has changed from the preferred value. Use SYSVARMONITOR command to view changes.


AutoCAD menu utilities loaded.
Command:
Command:

Command:
Command: (command "_.arx" "Load" "acapp.arx")
_.arx
Enter an option [?/Load/Unload/Commands/Options]: Load
Enter ARX/DBX file name to load: acapp.arx
Command: nil

Command: (LOAD "C:/Users/u7626/OneDrive/GRE LSP ROUTINE/GRE1_as_run.lsp")
REVS

Command: (gre1)
Redirect stdout (file: C:\Users\u7626\AppData\Local\Temp\accc142082).
AcCoreConsole: StdOutConsoleMode: processed-output: enabled,auto
AutoCAD Core Engine Console - Copyright 2021 Autodesk, Inc. All rights reserved. (S.173.0.0)

Execution Path:
C:\Program Files\Autodesk\AutoCAD 2022\accoreconsole.exe
Current Directory: C:\Users\u7626\OneDrive\GRE LSP ROUTINE

Version Number: S.173.0.0 (UNICODE)
LogFilePath has been set to the working folder.
Loading AEC Base...
Loading AEC Base Extended...
Loading AEC Core...
Loading AEC Project Base...
Loading AEC Architectural Base...
Loading AEC Schedule...
Regenerating model.
Press ENTER to continue:
**** System Variable Changed ****
1 of the monitored system variables has changed from the preferred value. Use SYSVARMONITOR command to view changes.


AutoCAD menu utilities loaded.
Command:
Command:

Command:
Command: (command "_.arx" "Load" "acapp.arx")
_.arx
Enter an option [?/Load/Unload/Commands/Options]: Load
Enter ARX/DBX file name to load: acapp.arx
Command: nil

Command: (LOAD "C:/Users/u7626/OneDrive/GRE LSP ROUTINE/GRE1_as_run.lsp")
REVS

Command: (gre1)
Press any key to continue . . .

0 Likes
Message 10 of 18

paullimapa
Mentor
Mentor

Looking at the result maybe it never goes beyond this step:

Command: (gre1)

Looking inside the lisp code, I see a number of additional lisp functions that require loading.

 

   ;== This section converts text from exploded RevAttr block back in to RevAttr block. ==
   (if (= rev_spot_1_contents "TEXT")
      (load "SPT1.lsp" nil)
   )
   (if (= rev_spot_2_contents "TEXT")
      (load "SPT2.lsp" nil)
   )
   (if (= rev_spot_3_contents "TEXT")
      (load "SPT3.lsp" nil)
   )
   (if (= rev_spot_4_contents "TEXT")
      (load "SPT4.lsp" nil)
   )
   (if (= rev_spot_5_contents "TEXT")
      (load "SPT5.lsp" nil)
   )
   (if (= rev_spot_6_contents "TEXT")
      (load "SPT6.lsp" nil)
   )
..................
   ;===== This section does the same function as the AUTOMOD Routine previously used =====
   (setq cur_rev (getAttribValue enx "rev")) ; Gets the current rev level setting in Titleblock
 
   (load "revdata.lsp" nil) ; Loads REVDATA.LSP file

 

Are all of these lisp files located in folders where they've been set under Options>Files>Trusted Locations

Perhaps test a very simple lisp function first like:

 

(defun drawr ()(command"_.Rectang""0,0""1,1")) 

 

Saved this as drawr.lsp

Then use this as your script file:

 

(command "_.arx" "Load" "acapp.arx")
(LOAD "drawr")
(drawr)
_.qsave

 

This should confirm that your Script is finishing properly


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

Okay, so I have verified that my support file search patch, my working file support path and trusted locations are all up to date with the file location of the script and LSP. I tried running your simple LSP and scr file as a batch and this is what I am getting.

 

ECHO is off.
ECHO is off.
ECHO is off.
ECHO is off.
Press any key to continue . . .
Redirect stdout (file: C:\Users\u7626\AppData\Local\Temp\accc153882).
AcCoreConsole: StdOutConsoleMode: processed-output: enabled,auto
AutoCAD Core Engine Console - Copyright 2021 Autodesk, Inc. All rights reserved. (S.173.0.0)

Execution Path:
C:\Program Files\Autodesk\AutoCAD 2022\accoreconsole.exe
Current Directory: C:\Users\u7626\OneDrive - Great River Energy\Documents\GRE LSP ROUTINE

Version Number: S.173.0.0 (UNICODE)
LogFilePath has been set to the working folder.
Loading AEC Base...
Loading AEC Base Extended...
Loading AEC Core...
Loading AEC Project Base...
Loading AEC Architectural Base...
Loading AEC Schedule...
Regenerating model. may not plot
Press ENTER to continue:
**** System Variable Changed ****
1 of the monitored system variables has changed from the preferred value. Use SYSVARMONITOR command to view changes.


AutoCAD menu utilities loaded.
Command:
Command:

Command:
Command: (command "_.arx" "Load" "acapp.arx")
_.arx
Enter an option [?/Load/Unload/Commands/Options]: Load
Enter ARX/DBX file name to load: acapp.arx
Command: nil

Command: (LOAD "drawr")
DRAWR

Command: (drawr)
_.Rectang
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: 0,0
Specify other corner point or [Area/Dimensions/Rotation]: 1,1
Command: nil

Command: _.qsaveRedirect stdout (file: C:\Users\u7626\AppData\Local\Temp\accc194002).
AcCoreConsole: StdOutConsoleMode: processed-output: enabled,auto
AutoCAD Core Engine Console - Copyright 2021 Autodesk, Inc. All rights reserved. (S.173.0.0)

Execution Path:
C:\Program Files\Autodesk\AutoCAD 2022\accoreconsole.exe
Current Directory: C:\Users\u7626\OneDrive - Great River Energy\Documents\GRE LSP ROUTINE

Version Number: S.173.0.0 (UNICODE)
LogFilePath has been set to the working folder.
Loading AEC Base...
Loading AEC Base Extended...
Loading AEC Core...
Loading AEC Project Base...
Loading AEC Architectural Base...
Loading AEC Schedule...
Regenerating model.
Press ENTER to continue:
**** System Variable Changed ****
1 of the monitored system variables has changed from the preferred value. Use SYSVARMONITOR command to view changes.


AutoCAD menu utilities loaded.
Command:
Command:

Command:
Command: (command "_.arx" "Load" "acapp.arx")
_.arx
Enter an option [?/Load/Unload/Commands/Options]: Load
Enter ARX/DBX file name to load: acapp.arx
Command: nil

Command: (LOAD "drawr")
DRAWR

Command: (drawr)
_.Rectang
Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: 0,0
Specify other corner point or [Area/Dimensions/Rotation]: 1,1
Command: nil

Command: _.qsavePress any key to continue . . .

0 Likes
Message 12 of 18

paullimapa
Mentor
Mentor

Now the Qsave shows up with my simple lisp routine. Did you check if the dwgs actually saved showing a rectangle drawn at those coordinates in the dwg?

If the Qsave successfully executed as shown in your post then that means something’s still causing your more complicated lisp function to stall the accorconsole or at least keeping it from continuing to run the Qsave command after completing the lisp. So that means to simplify the lisp as a way to further troubleshoot to see exactly where it stalls 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 13 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

So i went and checked, and it didn't draw the rectangle as well as didn't save the drawing. I am guessing there is something going on that is more complicated then what the accoreconsole is trying to do?

0 Likes
Message 14 of 18

paullimapa
Mentor
Mentor

Copy everything from the onedrive folder and create a separate folder directory under c drive like c:\test

place all  lisp, script and batch file here and 

modify everything to work under this new local folder including adding c:\test to acad support search and trusted location 

run batch again and see if dwg are saved this time. Again make sure script file has extra blank line after the Qsave line to represent a return 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 15 of 18

paullimapa
Mentor
Mentor

btw, I discovered a flaw in your test.bat. I higlighted the section. The quote is in the wrong location:

paullimapa_0-1693424163937.png

It should be like this:

:: Path of the folder containg the files (to change)
set source="Z:\u7626\TEST SCRIPT"

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 16 of 18

paullimapa
Mentor
Mentor
Accepted solution

If that previous correction still fails then I would replace this line the Test.bat:

FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%

with this line:

FOR %%f IN (%source%"\*.dwg") DO %accoreexe% /i "%%f" /s %script% /l en-US

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 17 of 18

gv6823otG42ZL
Enthusiast
Enthusiast

Thanks for all the help. I ended up recently finding AutoScript which is the newer version of script pro. I ran a set of drawings on autoscript and it runs with no issues and is 10x faster then script pro. Highly recommend 

0 Likes
Message 18 of 18

paullimapa
Mentor
Mentor

Yes I use that as well. But since it’s an arx file the developers may need to issue an update with each newer AutoCAD versions. But so far the same arx file has worked for AutoCAD 2020 through 2024.  


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