Author Topic: DatabaseSummaryInfoBuilder  (Read 2720 times)

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
DatabaseSummaryInfoBuilder
« on: February 08, 2013, 02:57:05 PM »
This link shows how to set dwg properties using .net.

In a way this is destructive code because it appears to overwrite all information unless you specifically set it before rewriting the SummaryInfo back to the database.  Is there a way to do this besides reading all of the information first and writing all information back to the database plus the specific information that you changed?  For instance, if I use this code.

Code - C#: [Select]
  1.     [CommandMethod("RevisionNumber")]
  2.     public void Command_Version()
  3.     {
  4.  
  5.         Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
  6.         Document doc = Application.DocumentManager.MdiActiveDocument;
  7.         Database db = doc.Database;
  8.  
  9.         ed.WriteMessage("Previous Version Number: " + db.SummaryInfo.RevisionNumber);
  10.  
  11.         DatabaseSummaryInfoBuilder infobuilder = new DatabaseSummaryInfoBuilder();
  12.  
  13.         infobuilder.RevisionNumber = "5.1";
  14.         DatabaseSummaryInfo info = infobuilder.ToDatabaseSummaryInfo();
  15.         db.SummaryInfo = info;
  16.         ed.WriteMessage("New Version Number: " + db.SummaryInfo.RevisionNumber);
  17.    }

Then all information is blanked out and only the version number remains.  Is there a way around this?
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

n.yuan

  • Bull Frog
  • Posts: 348
Re: DatabaseSummaryInfoBuilder
« Reply #1 on: February 08, 2013, 03:06:48 PM »
Use the DatabaseSummaryInfoBuilder's overloaded Contructor that takes DatabaseSummaryInfo as input parameter, instead of the Contructor without input. This way, the DatabaseSummaryInfoBuilder is created with all drawing custom properties initialized. Then you change properties you want to, and finally all the custom properties, changed or not changed, are sent back to a database's SummaryInfo property.

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: DatabaseSummaryInfoBuilder
« Reply #2 on: February 08, 2013, 03:21:57 PM »
Thank you Norman.  That was exactly what I was looking for.  It would be nice if the intellisense just said that instead of being blank.  It did show the overload but didnt explain what it did.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: DatabaseSummaryInfoBuilder
« Reply #3 on: February 08, 2013, 03:54:40 PM »
I do have one more question though regarding infobuilder.LastSavedBy.  Is there any way to use this property and set the lastSavedBy without it getting overwritten when you save the drawing?

What I am trying to do is create a command that will allow the dwgprops to be set via the command line.  I then wanted to use ScriptPro from Autodesk to automate changing of some of the drawing properties.  LastSavedBy is not a deal breaker but it would be nice to change this to a company name instead of my personal login.  As a last result i could just create a new user and run ScriptPro on that account but was hoping it was possible with .net.

Will creating my own save command and not use qsave or save solve this problem?
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

TheMaster

  • Guest
Re: DatabaseSummaryInfoBuilder
« Reply #4 on: February 08, 2013, 09:15:13 PM »
I do have one more question though regarding infobuilder.LastSavedBy.  Is there any way to use this property and set the lastSavedBy without it getting overwritten when you save the drawing?

What I am trying to do is create a command that will allow the dwgprops to be set via the command line.  I then wanted to use ScriptPro from Autodesk to automate changing of some of the drawing properties.  LastSavedBy is not a deal breaker but it would be nice to change this to a company name instead of my personal login.  As a last result i could just create a new user and run ScriptPro on that account but was hoping it was possible with .net.

Will creating my own save command and not use qsave or save solve this problem?

I don't know of any way to alter LastSavedBy, and I'm pretty sure AutoCAD sets it when the file is saved.

Why not just write a command that uses the API to change drawing properties, and invoke it from the script?

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: DatabaseSummaryInfoBuilder
« Reply #5 on: February 09, 2013, 08:02:19 AM »
That's what I am trying to do.   Its pretty simple to change everything but .LastSavedBy.  It continually gets overwritten when you save and close the drawing file.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Jeff H

  • Needs a day job
  • Posts: 6144
Re: DatabaseSummaryInfoBuilder
« Reply #6 on: February 09, 2013, 04:43:01 PM »
They say there is a dictionary called DWGPROPS that you have to manipulate directly but I never seen it.




Keith Brown

  • Swamp Rat
  • Posts: 601
Re: DatabaseSummaryInfoBuilder
« Reply #7 on: February 09, 2013, 05:35:52 PM »
I just bit the bullet and went ahead and made a new user.  Even if i found the dictionary you mention and made the changes I would still have to save the database which would overwrite the .lastsavedby.  I went ahead and made a test save command and it overwrote the property also.  It is not that big of a deal so I am not going to sweat it anymore.  I was able to change the other properties with .net which was what I was after in the first place.

Thanks for all the help.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013