.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

interop open dwg but do not display it

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
kbarnettza
1180 Views, 2 Replies

interop open dwg but do not display it

Greetings,

I apologise if this question has been asked and answered previoiusly, if so, please provide a link to the thread.

 

Using interop, running autocad from another custom application, is it possible to somehow use the core - to process data in the DWG without displaying the DWG?

 

Thx,

 

Kevin.

 

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: kbarnettza

By "somehow use the core", if you mean accoreconsole.exe, then you cannot automate it via COM API: it does not support COM API.

 

You can use your app to manipulate an AutoCAD script file and then use Process.Start to start accoreconsole.exe with proper arguments. so that drawing can be processed with accoreconsole.exe by the instruction of the AutoCAD script.

 

If you want to use COM API interop to process drawing without opening it in AutoCAD editor, you can use ObjectDBX.AxDbDocument instead of AcadDocument. Opening ObjectDBX.AxDbDocument is to read the dwg file into AutoCAD's memory, not in AutoCAD's editor. However, you need an running AutoCAD instance. Something like:

 

// Start an AutoCAD instance

AcadApplication acad=new AcadApplicationClass()

MessageBox.Show("AutoCAD started!");

 

//Open an AxDbDocument

object obj=acad.getInterfaceObject("ObjectDBX.AxDbDocument.20"); //Acad2015

AxDbDocument doc=obj as AxDbDocument

 

if (doc==null)

{

    MessageBox.Show("Cannot open AxDbDocument for some reason!");

    return;

}

 

//Get drawing information

MessageBox.Show("Entities in ModelSpace: " + doc.ModelSpace.Count);

 

//You can make changes to the entities in AxDbDocument and save the changes back to the drawing file.

 

doc.Save();

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
kbarnettza
in reply to: norman.yuan

Superb code Norman.. Thank you.. you have opened up a whole new adventure for me  ... wishing you all the best ...

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost