Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have an assembly, and am trying to set parameters in a sub assembly using iLogic. I have the following subroutine:
Sub SetUserParameters(oParentDoc As Document, oChildDoc As Document, oParameterName As String)
Dim oChildParams As Parameters = oChildDoc.ComponentDefinition.Parameters
Dim oParentParams As Parameters = oParentDoc.ComponentDefinition.Parameters
MsgBox(oParentDoc.DisplayName & ": " & oParentParams.Item(oParameterName).Name & " = " & oParentParams.Item(oParameterName).Value & vbNewLine & oChildDoc.DisplayName & ": " & oChildParams.Item(oParameterName).Name & " = " & oChildParams.Item(oParameterName).Value)
'try to set parameter of child equal to parent
Try
oChildParams.Item(oParameterName).Value = oParentParams.Item(oParameterName).Value
Catch
Try
'create Parameter And Set
oChildParams.UserParameters.AddByExpression(oParentParams.Item(oParameterName).Name, oParentParams.Item(oParameterName).Value, oParentParams.Item(oParameterName).Units)
Catch
MsgBox("Couldn't set parameter " & oParameterName & " in file " & oChildDoc.DisplayName)
End Try
End Try
End Sub
The code should set the value in the child file, and make a parameter if required, but falls through to the last catch statement implying it was unable to set the parameter. I have tested separately both setting and adding the parameter, and I can't get either to work. What am I doing wrong?
Solved! Go to Solution.