can't load assembly acmgd.dll

can't load assembly acmgd.dll

Anonymous
Not applicable
8,780 Views
10 Replies
Message 1 of 11

can't load assembly acmgd.dll

Anonymous
Not applicable

Hi

 

I have been trying to interface to AutoCAD from my VS 2010 project without luck. 

My environment is 64bit windows 7 environment. I installed on my computer AutoCad 2012 and ObjectARX 2012. 

 

I created a basic hello world project where I referenced the AcCui.dll AcDbMgd.dll AcMgd.dll but I keep getting errors when running it. 

 

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

Additional information: Could not load file or assembly 'Acmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.


I have tried it with "Copy Local" false (also with true), I have tried to reference the dlls from the ObjectARX directories as well as the AutoCAD installation folders without luck.

 

Any insight would be apprecaited.

 

Thank you,

Radek


 

 

0 Likes
Accepted solutions (1)
8,781 Views
10 Replies
Replies (10)
Message 2 of 11

norman.yuan
Mentor
Mentor
Accepted solution

How did you try "to interface to AutoCAD from VS2010 project"? Is your VS2010 project a windows class library (*.dll) and you loaded into AutoCAD with "NETLOAD" command, or is it an EXE project?

 

If it is latter, then you cannot use the said AutoCAD API assemblies iin an exe project.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 11

Anonymous
Not applicable

Hmmm

 

I'm afraid it is an exe.  We have a very old custom vb6 application that was able to lunch AutoCad with a specified dwg file, then it was able to capture clicks from the autocad gui capturing data from the clicked object, do some computations and create reports. 

 

We managed to compile it so far so it still somewhat runs with 2012, howerver, we need to migrate it to the VS 2010 C# envrionemnt. 

 

What is the most up to date way to achieve this type of functionality?

 

Thank you for your help,

Radek

0 Likes
Message 4 of 11

Anonymous
Not applicable

The issue is resolved, thank you for all your input. I was able to interface using COM importing librieries from the common folder.

0 Likes
Message 5 of 11

Anonymous
Not applicable

How? I'm sorry I could not understand. Please could you explain more detailed?

0 Likes
Message 6 of 11

norman.yuan
Mentor
Mentor

Obviously, you did not read or understand the posts correctly:

 

If you are to do a stand-alone EXE project (be it Win Form app or console app), you CAN NOT use AutoCAD .NET API assemblies (acdbmgd.dll, acmgd.dll). End of story.

 

The OP's solution is to add reference to COM API (in the "Add references" dialog box, go to "COM" tab and then set reference to AutoCAD Type library and/or Acad ObjectDBX Command type library.

 

In your case (by seeing your attached error picture, you need to remove reference to acdbmsg.dll/acmgd.dll fromo your project.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 7 of 11

Anonymous
Not applicable

Hi,

 

We were using VBA and trying to convert .net in the standalone application and getting difficulty to get the same functionality. 

 

In the VB code, the below code is implemented in the module “Rollover Module”.  Below is the screen shot of it,

 

testauto.jpg

 

The main aim of this code is to update the TITLE BLOCK data.  Below are the tittle block attributes of our drawings,

TITLE Block Name = KC-TITLE

Below are the few attributes in it which we update,

TITLE1; TITLE2; DRAWINGID; MNEMONIC; SHEET; DRAWN; DM; DD; DY;

 

We got the below code from internet for updating the TITLE BLOCK DATA as an alternative,

 

                    foreach (ObjectId objEntity in objPaperSpace)

                    {

 

                        BlockReference blkRef = (BlockReference)tr.GetObject(objEntity, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);

                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRef.BlockTableRecord, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);

 

                        Autodesk.AutoCAD.DatabaseServices.AttributeCollection attCol = blkRef.AttributeCollection;

 

                        foreach (ObjectId attId in attCol)

                        {

                            AttributeReference attRef = (AttributeReference)tr.GetObject(attId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);

 

                            string str =

                            ("\n  Attribute Tag: "

                            + attRef.Tag

                            + "\n    Attribute String: "

                            + attRef.TextString

                            );

                            //ed.WriteMessage(str);

                        }

                    }

                    tr.Commit();

 

But, we get many errors with this code because of removing the dll “acdbmgd.dll”.  If we add this we are not able to debug the code.  This dll issue is coming only during run time.  When we searched in net regarding this issue, we found that, as our Rollover application is an standalone application, we will not be able to use this dll.  This DLL cannot be used for standalone application.

 

So, we need to get some help to update TITLE BLOCK data in stand alone application. Please let me know, if you need more details.

 

Thanks,

Bhuvana

0 Likes
Message 8 of 11

_gile
Consultant
Consultant

Hi,

 

A standalone application cannot use the AutoCAD .NET API which is design to run in-process, it have to use the COM API (the same as with VBA). Have a look to this topic from the AutoCAD .NET Developer's Guide.

 

The only way to use .NET from a standalone application is to wrap the .NET code in a command (CommandMethod), then netload the .NET dll and run the command from the standalone application with the SendCommand() method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 9 of 11

dgorsman
Consultant
Consultant

Question: since VBA cannot run independently, is your legacy VBA function running inside inside AutoCAD, Excel, or another application?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 10 of 11

Anonymous
Not applicable

We have developed a C# .Net code and it is a standalone application. As it is a standalone application, we came to know that we will not be able to use the DLL’s (acdbmgd.dll & acmgd.dll). So we are using AutoCAD Type library and Acad ObjectDBX Command type library in our code.

Now, we face issue in updating TITLE BLOCK attributes.

 

Below is the code snippet that we use to update TITLE BLOCK data,

Title_block.png

 

But here in the first foreach loop, we do not get any value for the entity “ent”. It is NULL.

Please help us to get an alternative way to achieve this and to update TITLE BLOCK attributes.

 

Secondly, we face issue in saving the drawing file. Below is the code that we use,

SaveAS.png

 

The above code will save the file in AUTOCAD 2000 version. But we need to save the file in 2013 version.

Please help us on how to save in 2013 version.

Thanks in advance!

 

0 Likes
Message 11 of 11

norman.yuan
Mentor
Mentor

I do not have time to look into the first question of yours. But for the second question (about "SaveAs()"), here is the information from AutoCAD's VBA documentation:

 

<QUOTE>

 

VBA:

object.SaveAs FileName [, FileType] [, SecurityParams]object


Type: Document

The object this method applies to.

 

FileName
Access: Input-only

Type: String

The full path and file name, or valid URL address, for the file. The active document takes on the new name.

 

FileType
Access: Input-only; optional

Type: AcSaveAsType enum

 

acR12_dxf: AutoCAD R12 DXF (*.dxf)
acR14_dwg: AutoCAD R14 DWG (*.dwg)
ac2000_dwg: AutoCAD 2000 DWG (*.dwg)
ac2000_dxf: AutoCAD 2000 DXF (*.dxf)
ac2000_Template: AutoCAD 2000 Drawing Template File (*.dwt)
ac2004_dwg: AutoCAD 2004 DWG (*.dwg)
ac2004_dxf: AutoCAD 2004 DXF (*.dxf)
ac2004_Template: AutoCAD 2004 Drawing Template File (*.dwt)
ac2007_dwg: AutoCAD 2007 DWG (*.dwg)
ac2007_dxf: AutoCAD 2007 DXF (*.dxf)
ac2007_Template: AutoCAD 2007 Drawing Template File (*.dwt)
ac2010_dwg: AutoCAD 2010 DWG (*.dwg)
ac2010_dxf: AutoCAD 2010 DXF (*.dxf)
ac2010_Template: AutoCAD 2010 Drawing Template File (*.dwt)
ac2013_dwg: AutoCAD 2013 DWG (*.dwg)
ac2013_dxf: AutoCAD 2013 DXF (*.dxf)
ac2013_Template: AutoCAD 2013 Drawing Template File (*.dwt)
acNative: A synonym for the latest drawing release. In this release, this value equals ac2013_dwg.


SecurityParams
Access: Input-only; optional

Type: Variant (a SecurityParams object)

Security settings used to specify a digital signature for the drawing.

 

Note: Starting with AutoCAD-2016 based products, the ability to password protect a drawing file has been discontinued. Trying to password protect a drawing file in an AutoCAD-2016 based product results in an error. The security parameters related to password protection must be removed to save a drawing file.

 

</QUOTE>

 

As you can see, the FileType parameter is a enum type, NOT A string type. So, your code would not do "SaveAs()" at all, because the call to SaveAs() would result in an exception (does the code even compile, I am wondering?), and if "catch..." clause is empty, you may not even notice the drawing is not saved at all.

 

Of course, the running AutoCAD must be cad2013 or later version if you want to save drawing to Acad2013 format. To make things simple, you can set Acad to always save it to particular drawing format, so you do not have to supplie the second optional parameter in the SaveAs() call, unless you want save only particular drawing to different drawing format.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes