Get Attributes of source iFeature

<?xml encoding=”UTF-8″>By Adam Nagy

If you add an AttributeSet to the iFeature in the definition file (*.ide), that will not be transferred to the iFeature instance in the target part document. If the source file still exists then you can get the attributes from there like this:

Sub LookForAttributeSet()
Dim pd As PartDocument
Set pd = ThisApplication.ActiveDocument
' Select the iFeature instance in the Part document
Dim oif As iFeature
Set oif = pd.SelectSet(1)
Dim pd2 As PartDocument
Set pd2 = ThisApplication.Documents.Open( _
oif.iFeatureTemplateDescriptor.LastKnownSourceFileName, _
False)
Dim oif2 As iFeature
For Each oif2 In pd2.ComponentDefinition.Features.iFeatures
If oif2.iFeatureTemplateDescriptor.InternalName = _<br>    oif.iFeatureTemplateDescriptor.InternalName Then
MsgBox "First AttributeSet = " + oif2.AttributeSets(1).name
End If
Next
pd2.Close
End Sub

I assume the best way though to pass parameters from the iFeature definition to the iFeature instance might be to add parameters to the iFeature table in the definition file:

IFeature1

IFeature2

Then with this code you can get your parameter:

Sub GetIfeatureParams()
Dim pd As PartDocument
Set pd = ThisApplication.ActiveDocument
' Select the iFeature instance in the Part document
Dim oif As iFeature
Set oif = pd.SelectSet(1)
Dim c As iFeatureTableCell
For Each c In oif.iFeatureDefinition.ActiveTableRow
If c.Column.Heading = "MyParam" Then
Call MsgBox(c.Value)
Exit For
End If
Next
End Sub

 


Comments

4 responses to “Get Attributes of source iFeature”

  1. Hi Adam,
    Is this also working for punchtools?
    Regards, Marco

  2. Hi Marco,
    I have not checked, but I would imagine so.
    Give it a try :)
    Cheers,
    Adam

  3. Hi Adam,
    That was a very quick answer.
    I will give it a try and that leads me to another question, is there a simple way to replace an iFeature / Punchtool feature?
    Cheers, Marco

  4. I think you’d have to create a new iFeature. I don’t think you can just set an existing one to use a different ide file. It does not seem to be possible in the UI either.

Leave a Reply to MarcoCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading