Author Topic: DatabaseSummaryInfoBuilder.CustomProperties  (Read 7669 times)

0 Members and 1 Guest are viewing this topic.

HD

  • Guest
DatabaseSummaryInfoBuilder.CustomProperties
« on: January 09, 2008, 10:05:12 AM »
Hi -

I am having issues after populating an AutoCAD drawing Custom Property Sheet. These issues pertain to the "Name" field of the Custom Property Sheet.

I would like to point out that my operating environment is: Windows XP, Visual Studio 2005 Professional, and AutoCAD 2006.

Here are the issues:

Issue #1
By design, the "Name" field entries are mixed case. After populating the Custom Property Sheet, all "Name" fields are in lowercase.

Issue #2
When viewing the Custom Property Sheet, using the dwgprops command or Windows Explorer, the "Name" field entries are not populated in the order that they were added to the DatabaseSummaryInfoBuilder object variable.

Below are snippets from my method:
Code: [Select]
DatabaseSummaryInfo info;
DatabaseSummaryInfoBuilder infobuilder = new DatabaseSummaryInfoBuilder();

infobuilder.CustomProperties.Add("MXACADTNRV", mxTypeNameRevision);
infobuilder.CustomProperties.Add("Application Version", "AutoCAD 2006");
infobuilder.CustomProperties.Add("Export Control", "Yes");
infobuilder.CustomProperties.Add("City", attRef.TextString);
infobuilder.CustomProperties.Add("State Region", attRef.TextString);
infobuilder.CustomProperties.Add("Machine", attRef.TextString);

info = infobuilder.ToDatabaseSummaryInfo();
mfDb.SummaryInfo = info;
mfDb.SaveAs(modelName, DwgVersion.Current);

See attached .jpg file which depicts the Custom Property Sheet based on the above snippets.

Any suggestions / feedback is greatly appreciated.

Thanks
« Last Edit: January 15, 2008, 08:24:22 AM by Nick Schuckert »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #1 on: January 09, 2008, 03:06:15 PM »
I have the same problem Nick.  I haven't worked enough with custom properties to help, as I have looked into the documentation and seen nothing that would help so far.  If I find something I will post back.

Here is the code I used to test it.
Code: [Select]
[CommandMethod( "TestSummaryInfo" )]
public void TestSummaryInfo () {
Document Doc = acadApp.DocumentManager.MdiActiveDocument;
Database Db = Doc.Database;
DatabaseSummaryInfoBuilder DbSib = new DatabaseSummaryInfoBuilder();
DbSib.CustomProperties.Add( "1", "Testing1" );
DbSib.CustomProperties.Add( "2", "Testing2" );
DbSib.CustomProperties.Add( "3", "Testing3" );
DbSib.CustomProperties.Add( "4", "Testing4" );
DbSib.CustomProperties.Add( "5", "Testing5" );
DbSib.CustomProperties.Add( "6", "Testing6" );
Db.SummaryInfo = DbSib.ToDatabaseSummaryInfo();
}
My results were
4
5
6
1
2
3
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8723
  • AKA Daniel
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #2 on: January 15, 2008, 08:57:35 AM »
Something you might want to check. I think it was ActiveX that allowed you to enter duplicate keys, kind of messed things up.
I remember having to verify if the key existed, if it did exist, update the value, else add the new key/value.

Dan

Edit: ps thanks for sharing the solution
« Last Edit: January 15, 2008, 09:25:07 AM by Daniel »

Fatty

  • Guest
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #3 on: January 15, 2008, 05:53:00 PM »
In addition to code above if this
would be interesting for somebody here
is a simple code to read custom info:

Code: [Select]
public void ReadIt()
{
Database db = HostApplicationServices.WorkingDatabase();
DatabaseSummaryInfo info = db.SummaryInfo;
System.Collections.IDictionaryEnumerator cust = info.CustomProperties;
while (cust.MoveNext) {
object itm = cust.Current;
string key = itm.key;
string vl = itm.Value;
MsgBox("Key: " + key + ControlChars.CrLf + "Value: " + vl);
}
}

~'J'~

artisteroi

  • Guest
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #4 on: June 30, 2008, 12:46:02 PM »
In addition to code above if this
would be interesting for somebody here
is a simple code to read custom info:

Code: [Select]
public void ReadIt()
{
Database db = HostApplicationServices.WorkingDatabase();
DatabaseSummaryInfo info = db.SummaryInfo;
System.Collections.IDictionaryEnumerator cust = info.CustomProperties;
while (cust.MoveNext) {
object itm = cust.Current;
string key = itm.key;
string vl = itm.Value;
MsgBox("Key: " + key + ControlChars.CrLf + "Value: " + vl);
}
}

~'J'~

could I use a modification of this code to write new values to the summary page?

fixo

  • Guest
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #5 on: June 30, 2008, 02:59:17 PM »
No, this one is for reading only
Here is what you need on VB.NET
(not mine though)

Code: [Select]
#Region " ImportLibraries "
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Windows
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
#End Region
Namespace SummaryInfoUtils
    Module Module3
        Public Sub main()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim docklock As DocumentLock = doc.LockDocument
            Using db As Database = doc.Database
                Using trans As Transaction = db.TransactionManager.StartTransaction
                    Dim dbinfo As DatabaseSummaryInfo = New DatabaseSummaryInfo
                    Dim sumbldr As DatabaseSummaryInfoBuilder = New DatabaseSummaryInfoBuilder()
                    With sumbldr
                        .Author = "Your login name goes here"
                        .Comments = "Add comments here"
                        .HyperlinkBase = "http://www.theswamp.org/index.php?topic=20812.0"
                        .Keywords = "Keywords goes here"
                        .LastSavedBy = Convert.ToString(db.Tduupdate)
                        .RevisionNumber = "Revision Number goes here"
                        .Subject = "Subject goes here"
                        .Title = "Title goes here"
                        With .CustomProperties
                            .Add("Some custom property #1", "Value #1")
                            .Add("Some custom property #2", "Value #2")
                            .Add("Some custom property #3", "Value #3") 'etc
                        End With
                    End With
                    dbinfo = sumbldr.ToDatabaseSummaryInfo()
                    db.SummaryInfo = dbinfo
                    Dim intDb As Autodesk.AutoCAD.Interop.Common.AcadDatabase = db.AcadDatabase
                    Dim suminfo As AcadSummaryInfo = intDb.SummaryInfo
                    Dim infokeys As ArrayList = New ArrayList()
                    Dim infovalues As ArrayList = New ArrayList()

                    infokeys.Add("Custom Key #1")
                    infokeys.Add("Custom Key #2")
                    infokeys.Add("Custom Key #3")
                    infokeys.Add("Custom Key #4") 'etc

                    infovalues.Add("Custom Value #1")
                    infovalues.Add("Custom Value #2")
                    infovalues.Add("Custom Value #3")
                    infovalues.Add("Custom Value #4") 'etc

                    While suminfo.NumCustomInfo > 0
                        suminfo.RemoveCustomByIndex(0)
                    End While
                    Dim i As Integer

                    For i = 0 To infokeys.Count - 1 Step i + 1
                        Dim rowdata As String = infokeys(i)
                        Dim rowvalue As String = infovalues(i)
                        suminfo.AddCustomInfo(rowdata, rowvalue)
                    Next

                    ed.Regen()
                    db.SaveAs(doc.Name, DwgVersion.Current)
                    trans.Commit()

                End Using
            End Using
            docklock.Dispose()
        End Sub
    End Module
End Namespace

~'J'~

artisteroi

  • Guest
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #6 on: July 01, 2008, 10:18:48 AM »
Thanks. I'll give this a shot. Actually I will pass it on to my programming guru. :-)

artisteroi

  • Guest
Re: DatabaseSummaryInfoBuilder.CustomProperties
« Reply #7 on: July 01, 2008, 11:08:28 AM »
man I just can not please that programmer.
The great guru wants to know if this code "adds feilds and values" or if it "reads current feilds and updates existing values", which is what we are actually trying to do. I'm sorry to keep bugging you on this, but you are way more experienced on .net than I am. If you ever need any good old fasion drawings let me know and I will try to hook you up. :kewl:
-S