Using AcCoreConsole with dll to batch process

Using AcCoreConsole with dll to batch process

Ed__Jobe
Mentor Mentor
685 Views
6 Replies
Message 1 of 7

Using AcCoreConsole with dll to batch process

Ed__Jobe
Mentor
Mentor

I have a question regarding using a dll with the console app. I know you can load a dll with the /loadmodule switch, but can the dll autorun a command or do you also need to use the /s switch to load a script to run the command?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Accepted solutions (1)
686 Views
6 Replies
Replies (6)
Message 2 of 7

BlackBox_
Advisor
Advisor

It likely depends on the load sequence and the code within your .NET assembly.

 

If the target drawing is already open in Core Console when the assembly is loaded, then you can presumably include a call to SendStringToExecute() just fine (I haven't tried). 

 

Most of my code where I want it to auto-run on load for this scenario simply calls the Method associate with the CommandMethod attribute. 

 

If you load the assembly before the target drawing is loaded (or Core Console NETLOADs before opening the DWG via command switches), then it will obviously not have the desired result without the need for a Script to then call same (post-DWG open), or your assembly needs to also handle Document events to do so internally.

 

HTH


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 3 of 7

Ed__Jobe
Mentor
Mentor

Thanks @BlackBox_ Can you enlighten me on other methods that you are referring to which runs AcCoreConsole? I just know how to start it with a command line in a bat file. Where are you calling the command method? How are you loading the assembly before the dwg?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 7

BlackBox_
Advisor
Advisor
Accepted solution

@Ed__Jobe wrote:

Thanks @BlackBox_ Can you enlighten me on other methods that you are referring to which runs AcCoreConsole? I just know how to start it with a command line in a bat file. Where are you calling the command method? How are you loading the assembly before the dwg?


Enlighten? Probably not. Haha

 

I appreciate that Civil 3D team provides the standalone batch utility for batch processing via Core Console, but always found it cumbersome that I had to quit acad.exe, so I rolled my own LISP to do similar for a selection of drawings in parallel:

 

https://forums.augi.com/showthread.php?172630-Assign-Layer-State-to-Viewport&p=1339054&viewfull=1#po...

 

I also have a few tasks that I've grown accustom to running outside of CAD, using File Explorer shell menu; here's one of them: 

 

https://www.theswamp.org/index.php?topic=51181.msg563128#msg563128

 

Don't forget that you can also load AutoCAD's ARX to do things in Core Console not possible by default, like call (layoutlist) in LISP/Script:

 

https://www.theswamp.org/index.php?topic=57471.msg609440#msg609440

 

As for .NET, here's a quick Sample, which calls a method on load (if active document is valid), and on subsequent documents opened (works in full AutoCAD or Core Console). Rather than revise the code to instead call CommandMethod, I'd simply NETLOAD the assembly and use Script to invoke the Command:

 

 

namespace Sample
{
    class Events : IExtensionApplication
    {
        private static DocumentCollection acDocs = acApp.DocumentManager;

        public void Initialize()
        {
            acApp.Idle += onIdle;
        }
        public void Terminate()
        {
        }
        [CommandMethod("FOO", "DoSomethingUseful", CommandFlags.Session)]
        public static void DoSomethingUseful()
        {  
            //<-- do something useful
        }
        public static void onIdle(object sender, EventArgs e)
        {
            acApp.Idle -= onIdle;

            Settings.Load();

            acDocs.DocumentCreated += onDocumentCreated;

            Document doc = acDocs.MdiActiveDocument;

            if (doc != null)
            {
                doc.CommandWillStart += onCommandWillStart;

                doc.Editor.WriteMessage("\nCore Console tools loaded. \n");

                DoSomethingUseful();
            }
        }
        private static void onDocumentCreated(object sender, DocumentCollectionEventArgs e)
        {
            if (e.Document != null && !e.Document.IsReadOnly)
            {
                e.Document.CommandWillStart += onCommandWillStart;

                DoSomethingUseful();
            }
        }
        //<snip>
    }
}

 

 

HTH

 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

Message 5 of 7

Ed__Jobe
Mentor
Mentor

Thanks for the info. I'll check it out.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 6 of 7

soonhui
Advisor
Advisor

@BlackBox_ , this looks interesting. But how to apply it to accoreconsole, when I have a scr file, and which I will need to pass in a drawing full file path in the scr file? 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 7 of 7

BlackBox_
Advisor
Advisor

@soonhui wrote:

@BlackBox_ , this looks interesting. But how to apply it to accoreconsole, when I have a scr file, and which I will need to pass in a drawing full file path in the scr file? 


Hi @soonhui - this may help.


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps