Creating a AcCoreConsole.exe .NET addin

Creating a AcCoreConsole.exe .NET addin

Anonymous
Not applicable
1,729 Views
8 Replies
Message 1 of 9

Creating a AcCoreConsole.exe .NET addin

Anonymous
Not applicable

Hi,

 

I'm attempting to create a .NET addin running in AcCoreConsole.exe. In this project I've removed the reference to AcMgd.dll and replaced it with AcCoreMgd.dll. Is it correct that i cannot use the AcMgd.dll if I am to run my .NET addin from within AcCoreConsole.exe?

 

If so, how do access the DocumentManager?

 

For instance:

DocumentCollection ^acDocMgr = Autodesk::AutoCAD::ApplicationServices::Application::DocumentManager;

gives the error:

error C2039: 'DocumentManager' : is not a member of 'Autodesk::AutoCAD::ApplicationServices'

 

Is there a replacement in the AcCoreMgd.dll for the DocumentManager?

 

 

Regards,

Bjørn Egil Jenssen

0 Likes
1,730 Views
8 Replies
Replies (8)
Message 2 of 9

augusto.goncalves
Alumni
Alumni

Try import this namespace

Autodesk.AutoCAD.ApplicationServices.Core

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 9

augusto.goncalves
Alumni
Alumni

And yes, you cannot include reference to AcMgd.dll if you plan to run the addin on AutoCAD Console.

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 4 of 9

Anonymous
Not applicable

Thanks, that did the trick 🙂

 

But what about extension methods?

 

DocumentExtension::CloseAndSave(acDoc, dwgfile);

Document ^acDoc = DocumentCollectionExtension::Add(acDocMgr, strTemplatePath);

 

How would I go about replacing the functionality of these two methods using only AcCoreMgd?

 

 

Reg,

Bjørn

0 Likes
Message 5 of 9

augusto.goncalves
Alumni
Alumni

Some commands will not apply to the console...

 

Ideally, you should open one console for each document passing the file you want to process. The main reason for that is to avoid memory fragmentation and process on hold.

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 6 of 9

Anonymous
Not applicable

I see. In my application I need to create new files (not open existing ones), and fill them with geometry. I've now been able to compile and run my application with all its functionality, except creating new files.

 

Is there any workaround to create a new DWG file from a template file using the AcCoreConsole.exe? Either through .NET code, or by using console commands?

 

 

Regards,

Bjørn

0 Likes
Message 7 of 9

augusto.goncalves
Alumni
Alumni

I would say that you can start the console, draw what you need with a .NET custom command, then call AutoCAD built-in SAVE command passing the file path.

 

Do you think that can work?

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 8 of 9

Anonymous
Not applicable

This works, however, my application needs to create several DWG's in one "go". So after calling the SAVE command, I need to create a new file, or close the recently saved file, on order to continue on to the next.

 

It would be possible to close the entire console and restart it to continue where I left of, but it would be more elegant if I could create mutiple files in one go.

 

I've tried the NEW command in the console, but it doesnt seem to do anything. 

 

Are there any ways to either close the "active" file, or create a new file from the AcCoreConsole.exe?

 

 

Reg.

Bjørn

0 Likes
Message 9 of 9

augusto.goncalves
Alumni
Alumni

Note that opening many drawings on the same session will cause memory fragmentation, and use one session for each drawing is one of the great advantages of the console.

 

That said, one you launch the console passing one file and one script, you can only get the result, and you're not able to interact with it on the fly....

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes