I'm trying to set a custom property on several graphics.
After looking in the SDK manual I found this:
Dim gr as Graphic
Dim newProp as Property
Set gr = ActiveDrawing.Graphics.AddSquare 'any old graphic will do
Set newProp = gr.Properties.Add("Weight")
newProp.Value = 10#
Debug.Print "The name of the new property is " & newProp.Name
Debug.Print "The type of the new property is " & prop.Type
Debug.Print "The current value of the new property is " & prop.Value
So after playing around I managed to get this working, but only to a point:
Dim tcCircle, tcProperties As Object
tcCircle = tcApp.ActiveDrawing.Layers("0").AddCircleCenterAndPoint(0, 0, 0, 0, 0, 0)
tcProperties = tcCircle.Properties
.Item("BrushStyle").Value = "Solid"
.Item("BrushColor").Value = -3
.Item("BrushTransparency").Value = 100
.Item("PenStyle").Value = "Continuous"
.Item("PenColor").Value = -3
.Item("M_Radius").Value = 20
.Item("Info").Value = "TEST CIRCLE"
.Item("PlotID").Value = "AABBCC99"
However after running this piece of code to try and detect the value, I get an error:
For Each tcg As IMSIGX.Graphic In tcApp.ActiveDrawing.Graphics
For Each tcItem As Object In tcg.Properties
If tcItem.Name = "PlotID" Then
Catch ex As Exception
MsgBox(tcItem.Name & " - Error with value")
Its as if the property is being added, but not the value.
The manual also says:
Note that by setting the Value, the custom property system will automatically detect and set the Type property of the object. In the case above, the "Weight" property was assigned a Visual Basic double-precision number, so the Type property will return vbDouble.
This may be something to do with it I'm not sure.
I tried adding the property to the graphic non-programmatically through turbocad Right Click -> Properties -> Custom -> Define... -> Attach...
which worked fine, and then when I ran the Annotate Tool on the drawing the graphic has the property listed:
Name: PlotID; Type: 8; Value: AABBCC99
But when I create the property programatically and run the Annotate Tool on that it no longer appears in the list of properites.
Anybody know where I'm going wrong? any help with be gratefully appreciated.