.NET

Reply
New Member
gbstsma
Posts: 1
Registered: ‎07-20-2012
Message 1 of 2 (818 Views)

writing tool to add custom drawing properties

818 Views, 1 Replies
07-20-2012 06:55 AM

Hi,

 

I have installed the autocad ObjectARX 2011 and .Net wizzard to start writing a .Net application for adding custom drawing parameters to all our acad drawings.  I have found two issues detailed below.  This is my first attempt at using c# with autocad so any pointers on what I am doing wrong will be well received.

 

1.  If add the AcDbMgd.dll and AcMgd.dll references and set copy local to false as the documentation advises then I get a FileNotFoundException, could not load file or assembly 'acdbmgd'.  If I set the copy local to true then the error goes away.

 

2.  I tried using the code below to add a paramater but I get an exception on the first line System.TypeLoadException: Method 'CopyTo'.

 

Autodesk.AutoCAD.DatabaseServices.Databasedatabase = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;

 

//Users builder to edit the summary info (file properties) of the drawing

Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfoBuilder infoBuilder = new Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfoBuilder(database.SummaryInfo);

 

string key = "test";

string value = "testvalue";

 

infoBuilder.CustomPropertyTable.Add(key, value);

database.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();

 

 

Active Member
MarcioCartacho
Posts: 9
Registered: ‎04-18-2012
Message 2 of 2 (779 Views)

Re: writing tool to add custom drawing properties

07-23-2012 12:27 PM in reply to: gbstsma

Hello, gbstsma

 

Take a look at the way I do.

I Hope that this example helps you.

 

My references AcDbMgd and AcMgd Path: C:\ObjectARX 2010\inc-win32

(Copy Local = False)

 

 

Create Material

 

 

using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

privatevoid TransferirDadostoolStripButton_Click(object sender, EventArgs e)

        {
            ClearSummaryCustom();
            PopulaCustomComuns();
        }
   

publicvoid PopulaCustomComuns()

        {      
AcadDocument doc = (AcadDocument)AcadApp.DocumentManager.MdiActiveDocument.AcadDocument;
            doc.SummaryInfo.AddCustomInfo(textBoxD_Number.Tag.ToString(), textBoxD_Number.Text);
            doc.SummaryInfo.AddCustomInfo(textBoxRev.Tag.ToString(), textBoxRev.Text);
            doc.SummaryInfo.AddCustomInfo(textBoxLab.Tag.ToString(), tratamentoStrings(textBoxLab.Text));
            doc.SummaryInfo.AddCustomInfo(textBoxProduct_Group.Tag.ToString(), tratamentoStrings(textBoxProduct_Group.Text));
            doc.SummaryInfo.AddCustomInfo(textBoxProduct_Type.Tag.ToString(), tratamentoStrings(textBoxProduct_Type.Text));
            doc.SummaryInfo.AddCustomInfo(textBoxUnidade.Tag.ToString(), tratamentoStrings(textBoxUnidade.Text));
            doc.Save();
        } 

 

Metso Minerals

Márcio Lourenço Cartacho
C.A.D application Developer
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!