PDA

View Full Version : Create Custom Drawing Properties that keep the case of the string given?



bweir
2007-05-10, 08:46 PM
How can I create Custom Drawing Properties that keep the case of the string given?

I have a function that modifies the custom properties of a drawing to add a new property with a given value. My problem is that when the property is added the name is always created using lower case. This is a problem because I have another routine that creates text to show the values of the drawing properties and the field codes are expecting case sensitive names.

Here's a snippet of my code to create the custom property.

Dim Builder As New AcadDb.DatabaseSummaryInfoBuilder(Dwg.Database.SummaryInfo)
Dim Name as String = "My Prop"
Builder.CustomProperties.Add(Name, Value)

When I look in the Custom Properties "My Prop" has changed to "my prop". What's going on?

bweir
2007-05-11, 08:06 PM
OK, the problem is bigger then I thought. When I use the ToDatabaseSummaryInfo method from Builder to update the drawing, all of the Custom Property keys are changed to lower case. This wreaks havoc across my drawing as any fields now show the #### as they are looking for the Cased Key Names.

Here's my complete function.

Public Function SetCustomProperty(ByVal Dwg As Autodesk.AutoCAD.ApplicationServices.Document, ByVal Name As String, ByVal Value As String) As Boolean
Dim Builder As AcadDb.DatabaseSummaryInfoBuilder

Builder = New AcadDb.DatabaseSummaryInfoBuilder(Dwg.Database.SummaryInfo)

Try
If Builder.CustomProperties.ContainsKey(Name) Then
Builder.CustomProperties.Item(Name) = Value
Else
Builder.CustomProperties.Add(Name, Value)
End If

Dwg.Database.SummaryInfo = Builder.ToDatabaseSummaryInfo
Catch
Return False
End Try

Return True
End Function

Suggestions please!