
v3.0
このユーザデータマップのユーザデータテンプレートを CustomProperty として戻したり、設定したりします(テンプレートがない場合は NULL)。ユーザデータマップは、ユーザデータマップ内部のデータのテンプレートとして機能するカスタムプロパティに関連付けることができます。
このため、明示的に型指定されたデータを各コンポーネントに保存できます。テンプレートはデータの形式を定義します。ただし、データの値は各コンポーネントに別個に保存されます。
たとえば、ポリゴン クラスタ上のユーザ データ マップには、整数パラメータの X および浮動小数パラメータの Y が備わっています。このことは、各ポリゴンが X と Y の値を独自に保存できることを意味します。
関連カスタムプロパティと個別のコンポーネント間でのデータの転送は UserDataItem.Value および CustomProperty.BinaryData を使用して実行されます。
// get accessor CustomProperty rtn = UserDataMap.Template; // set accessor UserDataMap.Template = CustomProperty; |
dim oRoot, oObj, oCluster, oPropSet1, oPropSet2, oUserDataMap
'Create all the objects
set oRoot = Application.ActiveProject.ActiveScene.Root
set oObj = oRoot.AddGeometry("Grid","MeshSurface")
set oCluster = oObj.ActivePrimitive.Geometry.AddCluster( siPolygonCluster,"PolyCluster" )
set oPropSet1 = oCluster.AddProperty( "Custom_parameter_list",, "PSet1" )
set oUserDataMap = oCluster.AddProperty( "UserDataMap", false, "DataOnPoints" )
'Add some parameters to the PSet
dim oParam
set oParam = oPropSet1.AddParameter( "Str", siString )
oParam.Value = "Test"
oPropSet1.AddParameter "X", siDouble, , , _
"X short", "X Long", , _
9.87, 0.01, 11.14
oPropSet1.AddParameter "UByte", siUByte, siClassifMetaData , siPersistable, _
, , , _
64, 0, 128
set oUserDataMap.Template = oPropSet1
'Change a parameter value via the User Data Map
set oParam = oUserDataMap.Template.Parameters( "X" )
oParam.Value = 3.23
'So far none of the polygons actually have any user data stored on them.
'We can save the current values of the template custom property onto polygon 5
'using the following:
oUserDataMap.Item( 5 ).Value = oUserDataMap.Template.BinaryData
'Change our minds and remove the association. (This doesn't
'erase the user data we stored on polygon 5)
set oUserDataMap.Template = Nothing |