.NET

.NET

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

writing tool to add custom drawing properties

848 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 (809 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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.