Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 518

Get Attributes of source iFeature

$
0
0

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 = _
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

 


Viewing all articles
Browse latest Browse all 518

Trending Articles