Jump to content

Recommended Posts

Posted (edited)

You can call powershell code using lisp. You make a BAT file with the call to the powershell. It in turn needs a ps1 file that actually has the script of powershell commands.

 

An example have Excel open, but be in CAD from lisp run a bat and you are taken automatically to Excel as current active window. Do something in Excel like select cells then it returns to CAD with that info. Without this go to window you have to manually select the Excel window to continue.

 

It is very powerful but is a helper for experienced coders. You can spend a lot of time converting an example to suit your needs.

Edited by BIGAL
Posted

Thank you for the advice .

seems this may offer me some help. 

Posted

I have a few issues trying to use the core console.

Firstly, there are varying suggestions for the set command in the batch file, I have seen a few examples that sate it should be use with the quotes after the equals

set AutoCADCoreConsole="C:\Program Files\Autodesk\AutoCAD 2026\accoreconsole.exe"

 

But other advice I have read that the quotes must include the whole path or the batch will assume the quotes are a part of the file name, ie:- 

 

set "AutoCADCoreConsole=C:\Program Files\Autodesk\AutoCAD 2026\accoreconsole.exe"

 

also the example above shows 

%AutoCADCoreConsole% /i "%%f" /s "%lispFile%" -r M2A

 

but the Autodesk website doesnt provide any details of an -r parameter, is -r correct?

  

AcCoreConsole.exe [/i <input dwg>] /s <script> [/product <product>] [/l <language>] [/isolate <userid> <userDataFolder>] [/readonly] [/p[rofile] <profile>] [/loadmodule <module>]

 

The Adesk example is :

accoreconsole.exe /i "Floor Plan.dwg" /s "cleanup.scr" /product ACAD /l en-US

 

when i try and run 

@echo off
setlocal
:: Set the path to the folder containing your DWG files
set "folderpath=C:\Users\my name\share point\Technical\ASSETS\DWG\3D\LIGHT"
:: Set the AutoCAD Core Console executable path
set "AutoCADCoreConsole=C:\Program Files\Autodesk\AutoCAD 2026\accoreconsole.exe"
:: Set the path to your LISP file
set "lispFile=C:\AutocadScripts\Setdrawing.lsp"

:: Loop through all DWG files in the folder
for %%f in ("%folderPath%\*.dwg") do (
    echo Processing: %%f
    "%AutoCADCoreConsole%" /i "%%f" /s "%lispFile%" /product ACAD /l en-UK
)

endlocal

 

I get an error that Setdrawing.lsp.scr cannot be found:-

image.png.8411519b1c1bddf32d8db23107af28c7.png

 

is it possible to run lsp files directly ? or do i have to create a script that then runs the lsp?

 

 

Posted

Is it in a Trusted Folder?

 

Yes, it does appear you run a script in the accoreconsole to call the LISP

save with .scr

(load "C:\\path\\to\\your\\lispfile.lsp")
(c:YourFunction)  ; Replace with your LISP function

 

and use this instead of the LISP line

 

:: Set the path to your script file
set scriptpath="C:\path\to\your\script.scr"

 

Posted

I’ll give it another go in the morning .

i tried numerous ways to load the app but console always returns an error .

the script path is in support files under options.

i would have thought as we are explicitly specifying the script location this would not be an issue but (load……) always returns a file cannot be found error , the filling call to the lisp is the reported as  on such function ..

 

Posted

Not Support File Search Path (that may need to be also), but Trusted Locations folder.

 

 

TLF.png

Posted

Great thank you .

i am planning to add into the startup folder and give a go but got distracted today .

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...