Issue
Why does editing more than one parameter of an iFeature errors out ?
iFeatureDefinition and all the connected iFeatureInput objects are snapshots and hence are valid for only one transaction. Since modifying a parameter constitutes a transaction, you would have to re-initialize the definition each time in the loop
Here is the VBA sample for iFeature parameters editing in a loop.
Sub Edit_iFeature_Paraemters_Sample()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
‘reference to the first iFeature object
Dim oiFeature As iFeature
Set oiFeature = oDoc.ComponentDefinition _
.Features.iFeatures.Item(1)
‘reference to the definition
Dim iDef As iFeatureDefinition
Set iDef = oiFeature.iFeatureDefinition
‘inputs collection
Dim oInputs As iFeatureInputs
Set oInputs = iDef.iFeatureInputs
‘root name
Dim iName As String
iName = oiFeature.Name & ":"
‘iterate inputs collection
Dim oInput As iFeatureInput
For Each oInput In oInputs
‘Debug.Print oInput.Name
If oInput.Type = kiFeatureParameterInputObject Then
Dim oParInput As iFeatureParameterInput
Set oParInput = oInput
Dim oPar As Parameter
Set oPar = oParInput.Parameter
Select Case UCase(oParInput.Name)
Case UCase(iName + "Diameter")
oPar.Expression = "0.6 in"
Case UCase(iName + "Depth")
oPar.Expression = "0.6 in"
End Select
End If
Next
oDoc.Update
Beep
<
p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNormal”>End Sub

Leave a Reply