In the first of this week's posts on the new, developer-oriented features in AutoCAD 2013, we're going to take a look at the AutoCAD Core Console. I predict that this one feature alone is going to be worth its weight in gold to many customers and developers.

Picture this: a stripped down version of AutoCAD – but only from a UI perspective – that can be executed from a standard Command Prompt. We're talking about a version with almost all the capabilities of full AutoCAD – with the ability to load certain applications and execute scripts – but launches in a couple of seconds (if you have a slow machine 🙂 and is absolutely perfect for batch operations.

[Note: you can only run this executable on systems that have AutoCAD 2013 (or one of its verticals) installed – you shouldn't expect to be able to run it elsewhere.]

AutoCAD 2013 Core Console

Regarding batch operations: the version of ScriptPro currently on Autodesk Labs has been pre-enabled to work with the Core Console: all you have to do is specify the path to the executable in the settings.

And as well as being good at performing a set of sequential operations, the Core Console is a great way to get process-level parallelism (that harnesses all those spare cores many of us now have): you can launch multiple instances of the executable to run concurrently (or – for that matter – simply launch one to implement a "background" version of a command that would otherwise hog the editor during a time-consuming operation).

Before we get into what it means to be able to load "certain" applications, let's talk a little about the background to this tool. It was made possible by a multi-year architectural project known internally as The Big Split: to make AutoCAD truly – and sustainably – cross-platform, we needed a core component that could be compiled for multiple (for now that means two) platforms. The majority of AutoCAD's capabilities – including the drawing canvas and graphics sub-system – would be contained "inside" (if you think about it in logical – rather than physical – terms) this component.

This component is AcCore.dll on the Windows platform. If you take a look at acad.exe for AutoCAD 2013, for instance, you'll see it is now about 5.7 MB, with AcCore.dll weighing in at 13.4 MB. Compare this with AutoCAD 2012, where we had a monolithic acad.exe of 17.5 MB.

Subsetting out this core functionality means we can share a common codebase for this OS-independent set of functionality, and expose an appropriate UI to it for whichever platform we're targetting. For AutoCAD for Windows, this means using some MFC, some WPF, etc., while for AutoCAD for Mac this means using Cocoa.

And for the simplest possible, command-line only UI, we have the 24 KB AcCoreConsole.exe.

So what kinds of application can be loaded into the Core Console? It can certainly load DBX modules – which are coded against ObjectDBX/RealDWG, which is a subset of the "core" capabilities – but it can also load CRX modules and .NET DLLs that have been coded against the new AcCoreMgd.dll (rather than AcMgd.dll).

You can think of CRX modules as ARX modules developed to run against the core functionality: many of your commands – especially if using the command-line and jigs for their user-input – can be ported to CRX modules (or their .NET equivalent). Ideally you'd then have the GUI integration alone in your ARX modules (or .NET DLLs using AcMgd.dll) which then call into the "core" implementations.

This would allow them to be loaded into the Core Console and even in other environments, moving forwards (watch this space for more on that :-).

You can also load AutoLISP files into the Core Console – just as you can execute scripts – you just need to be aware that certain (mostly GUI-oriented) capabilities will not be available to you.

Let's now take a look at a very concrete use for this tool, along with some code to drive it.

A very common requirement is for some kind of server-resident process publishing DWFs or PDFs from DWGs. Balaji Ramamoorthy, from DevTech India, wrote an elegant batch script that can sit on a server and use the Core Console to generate PDFs from DWGs (actually it's a couple of batch files and an AutoCAD script, but anyway).

The main batch file sits and watches a particular "in" folder (which would ideally be network-accessible to be of much use). If it's empty, the batch file waits for 10 seconds before checking again (to avoid unnecessary thrashing). If there's something in the folder, the main batch file calls a secondary batch file (GenPDF.bat) to process the file(s) and create the results in the "out" folder.

Here's the main batch file:

:: AccoreConsoleDemo for AutoCAD 2013

 

::Make changes to these parameters as per requirement

SET ACCOREEXEPATH="C:\Program Files\Autodesk\AutoCAD 2013 - English\accoreconsole.exe"

SET DWGINDIR="C:\Temp\IN"

SET DWGOUTDIR="C:\Temp\OUT"

SET POLLINGTIME=10

 

echo off

 

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

IF NOT EXIST %DWGINDIR% MD %DWGINDIR%

IF NOT EXIST %DWGOUTDIR% MD %DWGOUTDIR%

cls

:LoopStart

 

SET PDFGENBATFILEPATH="%~dp0"

set PDFGENBATFILEPATH=%PDFGENBATFILEPATH:~1,-1%GenPDF.bat

 

for /f "delims=" %%a IN ('dir %DWGINDIR% /b *.dwg') do call "%PDFGENBATFILEPATH%" %ACCOREEXEPATH% %DWGINDIR% %DWGOUTDIR% "%%a"

timeout /t %POLLINGTIME% /NOBREAK

goto LoopStart

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

:End

Here's the secondary batch file, GenPDF.bat:

SET ACCOREEXEPATH=%1

IF NOT EXIST "%ACCOREEXEPATH%" goto ACCOREEXENOTFOUND

 

SET DWGINPATH=%2

SET DWGOUTPATH=%3

SET DWGFILENAME=%4

 

set DWGFILENAME=%DWGFILENAME:~1,-1%

set DWGINPATH=%DWGINPATH:~1,-1%\%DWGFILENAME%

set DWGOUTPATH=%DWGOUTPATH:~1,-1%\%DWGFILENAME%

 

:: Create the PDF file path

SET PDFINPATH=%DWGINPATH:dwg=pdf%

SET PDFOUTPATH=%DWGOUTPATH:dwg=pdf%

 

:: Get the script file path

SET SCRIPTFILEPATH="%~dp0"

set SCRIPTFILEPATH=%SCRIPTFILEPATH:~1,-1%SamplePDFGenScript.scr

 

::Generate the PDF file

%ACCOREEXEPATH% /i "%DWGINPATH%" /s "%SCRIPTFILEPATH%" /l en-US

move "%DWGINPATH%" "%DWGOUTPATH%"

move "%PDFINPATH%" "%PDFOUTPATH%"

goto END

 

:ACCOREEXENOTFOUND

echo %ACCOREEXEPATH%

echo "Accoreconsole.exe path is incorrect."

goto END

 

:DRAWINGNOTFOUND

echo %DWGINPATH%

echo "Drawing file not found."

goto END

 

:END

Which in turn needs an AutoCAD script file, SamplePDFGenScript.scr:

(setq CurrDwgName (getvar "dwgname"))

(setq Fname (substr CurrDwgName 1 (- (strlen CurrDwgName) 4)))

(setq name (strcat (getvar "DWGPREFIX") Fname ".pdf"))

;Command:

FILEDIA

;Enter new value for FILEDIA <1>:

0

;Command:

-PLOT

;Detailed plot configuration? [Yes/No] <No>:

Yes

;Enter a layout name or [?] <Model>:

Model

;Enter an output device name or [?] <None>:

DWG To PDF.pc3

;Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>:

ANSI A (11.00 x 8.50 Inches)

;Enter paper units [Inches/Millimeters] <Inches>:

Inches

;Enter drawing orientation [Portrait/Landscape] <Portrait>:

Landscape

;Plot upside down? [Yes/No] <No>:

No

;Enter plot area [Display/Extents/Limits/View/Window] <Display>:

Extents

;Enter plot scale (Plotted Inches=Drawing Units) or [Fit] <Fit>:

Fit

;Enter plot offset (x,y) or [Center] <0.00,0.00>:

 

;Plot with plot styles? [Yes/No] <Yes>:

Yes

;Enter plot style table name or [?] (enter . for none) <>:

.

;Plot with lineweights? [Yes/No] <Yes>:

Yes

;Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visualstyles/Rendered] <As displayed>:

 

;Enter file name <C:\Work\solids-Model.pdf>:

!name

;Save changes to page setup? Or set shade plot quality? [Yes/No/Quality] <N>:

No

;Proceed with plot [Yes/No] <Y>:

Yes

;Command:

FILEDIA

;;;Enter new value for FILEDIA <1>:

1

In the next post we'll take a look at another very interesting capability of AutoCAD 2013, Dynamic .NET.

  1. The type of server based application you describe here has not been allowed by the AutoCAD EULA in previous versions. Does AutoCAD 2013 change anything in that respect?

  2. I had understood that since our support for Citrix, etc., that the EULA had been made more forgiving of this kind of usage. But I'm not familiar with the specifics - the best would be to check the EULA and/or contact ADN.

    Kean

  3. [ruminates]
    .. wonders what the documentation is like ..
    [/ruminates]

  4. If you're looking for integrated F1 help, you're probably out of luck. 🙂

    I'm interested by what kind of documentation you'd be looking for...

    Kean

  5. >>>> I'm interested by what kind of documentation you'd be looking for...

    I don't know yet ... but I'd be comforted by the thought that it IS documented when we do come to use it.

    Regards,
    Kerry

  6. Interesting...I remember doing this in MicroStation 20-25 years ago, it was called EdG...glad to see something like this is coming back.

  7. WOW, this looks really promising!
    Can't wait to play with it more.

  8. So in theory, am I understanding that we can finally truly publish a set of drawings in the background?

  9. Steve Johnson Avatar

    If this works properly and is adequately documented, this is potentially worth more than all of the other new-to-2013 features put together.

  10. Kean Walmsley Avatar

    Correct (although some coding/script generation will be needed to automate the process).

    Kean

  11. Nirantar Vidyarthee Avatar
    Nirantar Vidyarthee

    Will SendCommand work without loading 'AcCoreConsole.exe'?

  12. Kean Walmsley Avatar

    Sorry - I'm not sure I understand the question.

    Kean

  13. I don't need integrated F1 help, but a simple CHM help file would be great.

    At bare minimum a list of all valid commands, variables and LISP functions (sorted and categorized with descriptions of what they do) would work.

    Just so we don't have to use trial and error to figure out what works and what doesn't.

  14. Sorry for a little off-topic, but your RSS feed seems broken. Or is it a problem on my side?

  15. It seems to be working for me (in Google Reader).

    Kean

  16. Kean, this is absolutely awesome! The thought of running this as a background thread is very very tempting...

  17. Kean,
    Your link to ScriptPro 2.0 on the labs site was written in Nov 2010. I tried a simple script that worked on a folder of drawing changing all objects to color of bylayer and it crashed (hung, became non-responsive) every time. I tested the accoreconsole.exe with the same script in the cmd window and with a batch file and all went well. Any idea what could be causing the hang?

  18. Kean Walmsley Avatar

    I'll ask the tool's author to look into it.

    Kean

  19. Virupaksha Aithal Avatar
    Virupaksha Aithal

    Thanks for the comments.

    Can you please try with updated ScriptPro (ScriptPro 2.0.2, published on Jan 16th 2012). Refer labs.blogs.com/its_alive_in_the_lab/2012/01/updated-scriptpro-202-adn-plugin-of-the-month-now-available.html

    Let us know (labs.plugins@autodesk.com) if you still face the problem.

  20. Thanks Kean and Virupaksha,

    There are no links on the labs site for ScriptPro 2.0.2. The only link is marked ScriptPro 2.0 dated Nov 2010. I downloaded that version yesterday (Apr 2) and it did not work. Your link points to a blog which links to the website which lists the old version.

  21. Virupaksha sent me this link which had a version that worked.
    usa.autodesk.com/adsk/servlet/item?siteID=123112&id=4091678&linkID=9240618

    Thanks

  22. Darrin Maidlow Avatar
    Darrin Maidlow

    This is one of those "<slap forehead=""> why didn't they do this a decade ago!" addons 🙂 I remember batch processing massive data sets back in the day and jumping through all kinds of hoops to try and never display the actual entities on screen. Ahh those were the days - 700MB+ drawing files, 512Mb-1GB ram and processes that would run for weeks hah!

    A great addition to the toolbox. Thanks!

  23. I am looking forward to getting to grips with this!

  24. I think that this subject should be begun with such information: theswamp.org/index.php?topic=41918.msg470406#msg470406

  25. Thanks for the information.

    I tried it, ans found that ole objects are not printing.
    Is there a way to fix it.

    Thank you.

  26. Hi Philippe,

    Please post this issue via ADN (if you're a member) or to the AutoCAD .NET Discussion Group (someone there should pick it up and be able to confirm the problem).

    Regards,

    Kean

  27. Hello Kean,

    I have a problem with 'accoreconsole' and 'acedEvaluateLisp'
    My project call lisp function but it is not working.

    It's a bug?
    Can you help me?
    forums.autodesk.com/t5/NET/AutoCAD-2013-AccoreConsole-acadEvaluateLisp/mp/3695768

  28. Hello Olivier,

    The Core Console has only been tested with a few specific scenarios in mind (it's used for a few features inside AutoCAD, but has not been tested extensively for general capabilities). P/Invoking acedEvaluateLisp() is likely not to have been tested - although from my brief look at the forum post I can't say whether the issue is with your code or due to an internal implementation issue.

    Hopefully someone on the ADN team will be monitoring the discussion group and can comment.

    Regards,

    Kean

  29. Hi Olivier,

    I am working on it and will post a reply to your forum post based on what I find.

    Cheers,

    Balaji

    Developer Technical Services
    ADN

  30. gennady.khokhorin@intergraph.c Avatar
    gennady.khokhorin@intergraph.c

    for some reason SamplePDFGenScript.scr from article is hanging on -PLOT command. Looks like it skips 2 responses:
    Command: -PLOT
    Detailed plot configuration? [Yes/No] <no>:
    Enter a layout name or [?] <model>:
    Enter a page setup name <>: Yes (this one is a response for Detailed plot above)
    Any ideas how to fix it?
    Gennady

  31. Is it possible you've got some unwanted whitespace (spaces or blank lines) in the script file? That would seem to the be the most likely candidate for this.

    I recommend copying & pasting from Chrome - that does a better job of stripping out unwanted whitespace.

    Kean

  32. Yep, removing empty lines (2 are required) fixed the problem (daaa..).
    Thank you!

  33. i wana draw 3d earthwork profile. can somebody help me out of how to input data in 3 dimensions like northig/easting/elevation?

  34. This isn't the best place to get help on this kind of topic: I suggest trying one of our online discussion forums.

    Kean

  35. we noticed that to and opened a case in adn... no answers for now ...

  36. Michael Leslie Avatar

    I am very excited about this new tool. Since it just appeared and is barely documented, I hope they don't pull this in the next version. I am seriously considering changing the old ActiveX drawing utilities I have written over to this scheme as it seems fast and reliable and the performance of ActiveX stuff has degraded badly since moving to 64 bit.

    I wanted to write a batch wrapper for this Core Console, so I could just pass it a script and a file or directory to work on and not worry about some of the syntax details all of the time. I am not an expert in batch, but I tried to make it fairly robust, if anyone has any improvements, please share.

    I submit:

    RunCoreConsole.bat

    @ECHO OFF
    SET AcadConsole="C:\Program Files\Autodesk\AutoCAD 2013\accoreconsole.exe"

    IF (%1)==() GOTO NoParams
    IF (%2)==() GOTO TwoParamsError

    IF NOT EXIST %1 GOTO FileError
    IF /i NOT (%~x1)==(.scr) GOTO FileError
    IF NOT EXIST %2\* GOTO TryIfFile ELSE RunAsDirectory

    :RunAsDirectory
    FOR /R %2 %%f IN (*.dwg) DO %AcadConsole% /i "%%f" /s %1 /l en-US
    EXIT /B 0

    :TryIfFile
    IF NOT EXIST %2 GOTO DirectoryError
    IF /i NOT (%~x2)==(.dwg) GOTO DirectoryError
    %AcadConsole% /i %2 /s %1 /l en-us
    EXIT /B 0

    :NoParams
    ECHO Usage:
    ECHO RunCoreConsole.bat ScriptFile DirectoryName
    EXIT /B 0

    :TwoParamsError
    ECHO Error: Both a script file and directory name are required.
    EXIT /B 1

    :FileError
    ECHO Error: %1 is not a valid script file.
    EXIT /B 1

    :DirectoryError
    ECHO Error: %2 is not a valid directory or file.
    EXIT /B 1

    I like to launch this from a .lnk shortcut that contains:

    C:\Windows\System32\cmd.exe /k "Set Folders and Script.bat"

    The "Set Folders and Script.bat" contains:

    @ECHO OFF

    SET FolderToProcess="I:\----\----"
    SET ScriptFile="I:\----\----\PurgeAll.scr"

    RunCoreConsole %FolderToProcess% %ScriptFile%

    Using the .lnk file lets me keep the window open so I can see error messages.

    Using the "Set Folders and Script.bat" lets me conveniently set what I want to work on, and keeps me from changing the main "RunCoreConsole.bat" all of the time.

    Any comments?

  37. Sorry for the delay - this ended up in my spam folder, for some unknown reason.

    It's been a long time since I've done anything serious with batch files, but this looks good to me!

    Might also be worth seeing how it works from PowerShell, at some point.

    Kean

  38. "I'm interested by what kind of documentation you'd be looking for..."

    Well, for my immediate needs I'm looking at using it rebuild the office DocumentControl app(read: batch plotter, really. it does more though.).

    Seems a good way to access, print and modify drawings. But I'm curious if we can access it from a vb.console app and run it all with code, if we need dlls compiled in there running on script only, etc. the more we can run it externally with code the better I think.

  39. You can NETLOAD VB.NET DLLs that define commands (as long as they only have references to acdbmgd.dll and accoremgd.dll - none to acmgd.dll) and these commands can be called from scripts. The same commands will also work in full AutoCAD, of course, so that's the way I'd approach this requirement.

    Kean

  40. Hi Kean!
    How can I "auto answer" yes when opening read-only files at accoreconsole?

    1. Hi Caverna,

      Have you tried making the response part of a provided script?

      I have to admit I haven't yet had to do this myself.

      Regards,

      Kean

      1. Thank you for answering Kean.
        The script seems to be executed only after the file finishes opening.
        I did try to put "Y" at beginning of script, with no success.

        1. What version are you using? With AutoCAD 2015 I see the Core Console auto-answer yes:

          >>>
          C:\Program Files\Autodesk\AutoCAD 2015>accoreconsole.exe /i c:\temp\test.dwg
          AutoCAD Core Engine Console - Copyright Autodesk, Inc 2009-2013.
          ************************MessageBox****************************
          AutoCAD Alert
          C:\temp\test.dwg is currently in use or is read-only.
          Would you like to open the file read-only?
          >>>Responding: Yes.
          **************************************************************
          Regenerating model.
          Command:
          <<<

          Kean

          1. 2013 🙁
            Upgrades will be only next year... 🙁
            Thank you for your attention

  41. Mike Hutchinson Avatar
    Mike Hutchinson

    I've been trying to load appropriate file within Accoreconsole to 'enable' AutoCAD MEP objects, but I am not finding any success at all. What am I missing?... the ones I would have thought would work, like "C:\Program Files\Autodesk\AutoCAD 2014\AecbBldSrv.dbx" and "C:\Program Files\Autodesk\AutoCAD 2014\AecArchBase.dbx" will pop an error..."No entry for AecBaseEx70 was found." for instance.

    1. Kean Walmsley Avatar

      Have you tried loading the reported dependencies (e.g. AecBaseEx70.dbx) first?

      Kean

  42. Hi Kean,
    I have been working with the accoreconsole for nearly a month. I think I have hit a wall. I have a few questions that could not be addressed through the .net forum. I have a bit of code that loads points into a dwg file, similar to a point cloud, but not a recap point cloud (from a csv file). I have successfully loaded up to about 1 million points relatively fast. Questions: - Is there a limit on the number of objects that can be loaded into a drawing? Will .net convert the points to a recap point cloud? (I ask, because I have loaded point clouds greater than 10 Million recap point clouds into Autocad).

    Thanks for your help.

    Orso

    1. Hi Orso,

      If you're talking about individual point entities... yes, you'll for sure hit a wall with those. Not sure where, but you'll hit it. There's simply way too much overhead for each drawing object to store a simple x,y,z coordinate.

      AutoCAD won't aggregate those into a point cloud for you, unfortunately. In earlier releases - any that have the POINTCLOUDINDEX command - you could create a TXT file (a .xyz file, typically) and index that into a PCG you could attach. Now that AutoCAD only supports .RCS and .RCP this is no longer possible.

      I suggesting checking whether you can use POINTCLOUDINDEX and taking it from there (although if you need to support versions that don't have it, it'll be a problem).

      Kean

  43. Hello Kean

    Would you know where folks can get some good documentation on this stuff (ie AccoreConsole or Core Console) and this scriptpro program? I cannot seem to find much. documentation e.g. . how it works etc. that would be very handy.

    rgds

    Ben

    1. Hi Ben,

      As far as I recall you can point ScriptPro at the accoreconsole.exe executable and it should work. If the ScriptPro docs don't help, I suggest pinging the ADN team (directly or via the AutoCAD .NET discussion group).

      The Core Console itself is largely undocumented - you'll find info on this blog and the ADN DevBlog (for instance: adndevblog.typepad.com/autocad/, but that's about it.

      Regards,

      Kean

      1. Wiebe van der Worp Avatar
        Wiebe van der Worp

        That link should be adndevblog.typepad.com/autocad/ and in the mean time I wrote a more general entry on wiki.nedcad.nl/Bulk_... where I mentioned this post. Thanks for your well written article.

  44. is there any way to plot all the layouts in a drawing via script? i have tried loading a lisp routine that works in the gui for plotting all layouts, but it doesn't do anything with the coreconsole.

    1. I'm pretty sure this is possible: it's one of the main purposed for AutoCAD I/O (now part of the Design Automation API on Forge) which is driven by the Core Console.

      You'll need to work out how to switch layouts, etc. but it should be possible. People on the forums should help, in case.

      Kean

  45. Hi Kean, will this work with AEC commands. Trying to batch purge styles and purgestyles isn't a recognized command.

    1. Hi Craig,

      It probably depends on the command (much as it does with AutoCAD). You should check with ADN on the support that's available for specific AEC commands...

      Regards,

      Kean

  46. Juan Manuel Lopez Avatar
    Juan Manuel Lopez

    Hi any option to call this Core Console from Excel VBA, I am using Autocad 2016, I want to perform actions for a batch of files ( extract text and copy in my excel file).

    Thanks

    1. I'm sure you can find a way: you'd just be executing a Windows process.

      Kean

  47. Thanks for the post.

    I tried use hebrew file names, ans found that not working.
    Is there a way to fix it.

    "D:\Program Files\Autodesk\AutoCAD 2017\AcCoreConsole.exe" /i "H:\Projects_2012\TadorWetInfrastructure\bugs\dwf\IN\בדיקה עברית 1.dwg" /s "H:\Projects_2012\TadorWetInfrastructure\bugs\dwf\IN\בדיקה עברית 1.scr" /l he-IL

    Thank you.

  48. Now here's a shot in the dark.. hope some one is reading, mostly hoping for @keanw:disqus .

    Does anyone know if there is a global variable or some other way to tell
    from inside an .lsp file, if the running environment is
    AutoCAD with GUI OR AutoCAD Core Console.

    I would like to make single lisp-files that account for what environment they are run in
    in order to make the lisp-files work in both with minor adjustments regarding functuality.

    For instance: I have a script that redefines some blocks.
    If this script is run in "GUI-mode" I want it to perform an Attsync
    but no Attsync should be performed if the same script is run in AutoCAD Core Console.

    Heeelp =)

    1. I had a quick look, and couldn't see a sysvar that showed this. You could use the process to get the executable name using the Windows API, but there's probably a better way I don't know (or recall).

      The best would be to ask via the forums, as I'm sure someone there will have a better answer.

      Kean

Leave a Reply to Owen Wengerd Cancel reply

Your email address will not be published. Required fields are marked *