.NET

Reply
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-12-2005
Post 1 of 7

Summary Info

281 Views, 6 Replies
06-08-2005 12:11 PM
I have captured the "before save" event and created a routine to increment a version property in the document properties.

It appears to work, but the ToDatabaseSummaryInfo does not update the current summary info (I assume that is what the method does)

Am I grossly mislead?

Public Sub IncrementVersionCounter(ByVal o As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.DatabaseIOEventArgs)
Dim intVersion As Integer
Dim strVersion As String
Dim oOldAcadSummaryInfo As DatabaseSummaryInfo
Dim oNewAcadSummaryInfo As DatabaseSummaryInfo
Dim oAcadDB As Database = Application.DocumentManager.MdiActiveDocument.Database
oOldAcadSummaryInfo = oAcadDB.SummaryInfo
strVersion = oOldAcadSummaryInfo.RevisionNumber
Try
If strVersion = "" Then strVersion = "0"
intVersion = CInt(strVersion)
Catch ex As Exception
intVersion = 0
Finally
Try
intVersion = intVersion + 1
strVersion = CStr(intVersion)
Dim oAcadSumBuilder As New Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfoBuilder
oAcadSumBuilder.Author = oOldAcadSummaryInfo.Author
oAcadSumBuilder.Comments = oOldAcadSummaryInfo.Comments
oAcadSumBuilder.HyperlinkBase = oOldAcadSummaryInfo.HyperlinkBase
oAcadSumBuilder.LastSavedBy = oOldAcadSummaryInfo.LastSavedBy
oAcadSumBuilder.Keywords = oOldAcadSummaryInfo.Author
oAcadSumBuilder.Subject = oOldAcadSummaryInfo.Subject
oAcadSumBuilder.Title = oOldAcadSummaryInfo.Title
oAcadSumBuilder.RevisionNumber = strVersion
oNewAcadSummaryInfo = oAcadSumBuilder.ToDatabaseSummaryInfo()
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbNewLine + "Version Property Incremented to : " & strVersion + vbNewLine)
Catch
End Try
oOldAcadSummaryInfo = Nothing
oNewAcadSummaryInfo = Nothing
oAcadDB = Nothing
intVersion = Nothing
strVersion = Nothing

End Try

End Sub
*Albert Szilvasy
Post 2 of 7

Re: Summary Info

06-08-2005 12:51 PM in reply to: Chris Ludtke
You never assign the new summary info to the database.
Instead of
oNewAcadSummaryInfo =
oAcadSumBuilder.ToDatabaseSummaryInfo()
you should write:
oAcadDB.SummaryInfo =
oAcadSumBuilder.ToDatabaseSummaryInfo()

Albert
wrote in message news:4869136@discussion.autodesk.com...
I have captured the "before save" event and created a routine to increment a
version property in the document properties.

It appears to work, but the ToDatabaseSummaryInfo does not update the
current summary info (I assume that is what the method does)

Am I grossly mislead?

Public Sub IncrementVersionCounter(ByVal o As Object, ByVal e As
Autodesk.AutoCAD.DatabaseServices.DatabaseIOEventArgs)
Dim intVersion As Integer
Dim strVersion As String
Dim oOldAcadSummaryInfo As DatabaseSummaryInfo
Dim oNewAcadSummaryInfo As DatabaseSummaryInfo
Dim oAcadDB As Database =
Application.DocumentManager.MdiActiveDocument.Database
oOldAcadSummaryInfo = oAcadDB.SummaryInfo
strVersion = oOldAcadSummaryInfo.RevisionNumber
Try
If strVersion = "" Then strVersion = "0"
intVersion = CInt(strVersion)
Catch ex As Exception
intVersion = 0
Finally
Try
intVersion = intVersion + 1
strVersion = CStr(intVersion)
Dim oAcadSumBuilder As New
Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfoBuilder
oAcadSumBuilder.Author = oOldAcadSummaryInfo.Author
oAcadSumBuilder.Comments = oOldAcadSummaryInfo.Comments
oAcadSumBuilder.HyperlinkBase =
oOldAcadSummaryInfo.HyperlinkBase
oAcadSumBuilder.LastSavedBy =
oOldAcadSummaryInfo.LastSavedBy
oAcadSumBuilder.Keywords = oOldAcadSummaryInfo.Author
oAcadSumBuilder.Subject = oOldAcadSummaryInfo.Subject
oAcadSumBuilder.Title = oOldAcadSummaryInfo.Title
oAcadSumBuilder.RevisionNumber = strVersion
oNewAcadSummaryInfo =
oAcadSumBuilder.ToDatabaseSummaryInfo()
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(vbNewLine
+ "Version Property Incremented to : " & strVersion + vbNewLine)
Catch
End Try
oOldAcadSummaryInfo = Nothing
oNewAcadSummaryInfo = Nothing
oAcadDB = Nothing
intVersion = Nothing
strVersion = Nothing

End Try

End Sub
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-12-2005
Post 3 of 7

Re: Summary Info

06-08-2005 01:19 PM in reply to: Chris Ludtke
Thanks Albert,

I made the following changes

...........

oAcadDB.SummaryInfo = oAcadSumBuilder.ToDatabaseSummaryInfo()

An exception is thrown when attempting to execute this line.
*Albert Szilvasy
Post 4 of 7

Re: Summary Info

06-08-2005 05:31 PM in reply to: Chris Ludtke
What is the exception?

Albert
wrote in message news:4869203@discussion.autodesk.com...
Thanks Albert,

I made the following changes

...........

oAcadDB.SummaryInfo = oAcadSumBuilder.ToDatabaseSummaryInfo()

An exception is thrown when attempting to execute this line.
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-12-2005
Post 5 of 7

Re: Summary Info

06-09-2005 08:28 AM in reply to: Chris Ludtke
The exception is as follows

"Object reference not set to an instance of an object."

Stack :

StackTrace " at Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfo.CopyToUnmanagedObject(IntPtr unmanagedPointer)
at Autodesk.AutoCAD.DatabaseServices.Database.set_SummaryInfo(DatabaseSummaryInfo value)
at BallAcadPlot.PlotFormats.InitializationCommands.IncrementVersionCounter(Object o, DatabaseIOEventArgs e) in C:\CSLUDTKE\Visual Basic\AcadPlot\AutoCADPlot\PlotFormats.vb:line 196" String

Thanks
*Albert Szilvasy
Post 6 of 7

Re: Summary Info

06-09-2005 10:02 AM in reply to: Chris Ludtke
You are running into a bug. Fortunately, there's an easy workaround:
Add the following line before oAcadDB.SummaryInfo =
oAcadSumBuilder.ToDatabaseSummaryInfo()

'dummy call to the CustomProperties property to avoid bug in property setter
of Database.SummaryInfo
Dim dummy As Integer = oAcadSumBuilder.CustomProperties.Count

Albert

wrote in message news:4870227@discussion.autodesk.com...
The exception is as follows

"Object reference not set to an instance of an object."

Stack :

StackTrace " at
Autodesk.AutoCAD.DatabaseServices.DatabaseSummaryInfo.CopyToUnmanagedObject(IntPtr
unmanagedPointer)
at
Autodesk.AutoCAD.DatabaseServices.Database.set_SummaryInfo(DatabaseSummaryInfo
value)
at
BallAcadPlot.PlotFormats.InitializationCommands.IncrementVersionCounter(Object
o, DatabaseIOEventArgs e) in C:\CSLUDTKE\Visual
Basic\AcadPlot\AutoCADPlot\PlotFormats.vb:line 196" String

Thanks
Active Contributor
44 Posts
0 Kudos
Registered: ‎04-12-2005
Post 7 of 7

Re: Summary Info

06-09-2005 01:56 PM in reply to: Chris Ludtke
Thanks Albert !!!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post