hallo waldi,
guck mal im 5.3er Verzeichnis InventorSDK/APIDOCS/*.chm
Dann unter sample ist bei
DYNAMIC ATTRIBUTE
folgendes Prog.
Gruß
Seher
This sample demonstrates the basic concept of dynamic attributes. For a selected entity, it creates an attribute set and an attribute. If the selected entity already has the attribute set, it allows you to edit the value of the attribute.
To use this sample select an entity and run the program.
Public Sub SetAndGetAttribute()
' Check to make sure a single item is in the select set.
If ThisApplication.ActiveDocument.SelectSet.Count <> 1 Then
MsgBox "A single entity must be selected."
Exit Sub
End If
' Get the item from the select set.
Dim oSelectedObject As Object
Set oSelectedObject = ThisApplication.ActiveDocument.SelectSet.Item(1)
' Make sure the selected object supports attributes.
Dim oAttribSets As AttributeSets
On Error Resume Next
Set oAttribSets = oSelectedObject.AttributeSets
If Err Then
MsgBox "The selected object does not support attributes."
Exit Sub
End If
On Error GoTo 0
Dim sNewValue As String
Dim oAttribSet As AttributeSet
Dim oAttrib As Inventor.Attribute
' Check to see if the object already has an attribute set named "AttribTest".
If oAttribSets.NameIsUsed("AttribTest") Then
' Get a reference to the existing attribute set.
Set oAttribSet = oAttribSets.Item("AttribTest")
' Get a reference to the existing attribute.
Set oAttrib = oAttribSet.Item("Attrib")
' Display te current value and allow the user to specify a new value.
sNewValue = InputBox("Edit existing value", "Modify Existing Attribute", _
oAttrib.Value)
' If the value's different, change the value of the attribute.
If sNewValue <> "" And sNewValue <> oAttrib.Value Then
oAttrib.Value = sNewValue
End If
Else
' Get the value to assign to the attribute.
sNewValue = InputBox("Specify attribute value", "Create Attribute")
' If a value was entered, create a new attribute set and attribute.
If sNewValue <> "" Then
' Create a new attribute set with the name "AttribTest".
Set oAttribSet = oAttribSets.Add("AttribTest")
' Create a new attribute named "Attrib" and assign the value.
Set oAttrib = oAttribSet.Add("Attrib", kStringType, sNewValue)
End If
End If
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP