i am trying to write a value to a part that is linked in the paramters.
the code seems to work, but the value i want to change stays the same.
Dim oDoc As Document = ThisDoc.Document
Dim oCompDef As ComponentDefinition = oDoc.componentdefinition
Dim ParamDocName As String = oCompDef.Parameters.DerivedParameterTables.item(1).Referenceddocumentdescriptor.fulldocumentname
Dim ParamDoc As Document = ThisApplication.Documents.Open(ParamDocName, False)
Dim Lround As Double = Ceil(Ltot/10)*10
Logger.Info("old value: " & ParamDoc.PropertySets.Item("User Defined Properties").Item("luitLuik").Value)
'ParamDoc.PropertySets.Item("User Defined Properties").Item("luitLuik").Value = Lround
ParamDoc.PropertySets.Item("User Defined Properties").Item("luitLuik").Expression = Lround.ToString
Logger.Info("new value: " & ParamDoc.PropertySets.Item("User Defined Properties").Item("luitLuik").Value)
in the logger the new value is shown as is should be. but when i check the linked file the value is not changed.
the code doesn't give any errors, so i have no idea where to look for.
anyone know what could be wrong?
Solved! Go to Solution.
Solved by GeertvanderHeide. Go to Solution.
for now i have fixed it with running an external rule and passing a namevaluemap with the rule.
iLogicVb.Automation.RunRuleWithArguments(ParamDoc, "rulename", map)
guess that modifying the user defined property doesn't change the parameter that is used to make that custom property....
still no one that has any idea why this is not possible?
i can acces the properties and parameters in a linked file, but when i cange values it only changes them in the custom properties window (under iproperties) and not in the parameter window. after a save the custom properties get overwritten with the values of the exported parameters.
When directly changing the values of user parameters nothing happens.
i know it should be possible with parameter.param("OccName") but the file i am trying to edit is not an occurrence of my assembly, it is only linked by the parameter table, so the best i can get is a document object.
Is it parameters your trying to change or iproperties? I see no mention of parameters in your code. You will need to perform updates if you have linked parts. Please attached a screen shot of the workflow your looking to use.
i posted a code of both methods i used to try and modify the parameters. Both methods don't work for chaning the value of the parameters. i guess iproperties are just copies from exported parameters, so i can understand why that would not work.
ps. in the code all values are just set to 5, but stay 0. is also have a filter to not change all parameters, but removed the array from the example 😉
Dim oDoc As Document = ThisDoc.Document
Dim CompDef As ComponentDefinition = oDoc.ComponentDefinition
Dim ParamDoc As Document = CompDef.Parameters.DerivedParameterTables.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
Dim PropSet As PropertySet = ParamDoc.PropertySets.Item(4)
Dim oProp As [Property]
Dim oParams As UserParameters = CompDef.parameters.UserParameters
Dim UParam As UserParameter
For Each oProp In PropSet
' If oProp.Name = ParameterArray(a, 0) Then
' oProp.Value = 5
' RuleParametersOutput()
' Exit For
' End If
' Next
For Each uParam In oParams
If UParam.Name = ParameterArray(a, 0) Then
oProp.Expression = 5
RuleParametersOutput()
Exit For
End If
Next
oke, so i found the solution, and appearantly is was not writing to the parameter file...
sub Main()
Dim maincomp As ComponentDefinition = thisdoc.document.componentdefinition
Dim mainparamname As String = maincomp.parameters.derivedparameterTables.item(1).Referenceddocumentdescriptor.fulldocumentname
Dim mainparamdoc As Document = ThisApplication.Documents.Open(mainparamname , False)
WriteToParamFile(mainparamdoc)
End Sub
Sub WriteToParamFile(odoc As Document)
Dim CompDef As ComponentDefinition = odoc.ComponentDefinition
Dim oUserParams As UserParameters = CompDef.parameters.userparameters
Dim UParam As UserParameter
For a = 0 To ParamCount
For Each UParam In oUserParams
If UParam.Name = ParameterArray(a, 0) Then
UParam.Expression = ParameterArray(a, 1)
End If
Next
Next
RuleParametersOutput()
odoc.Save
End Sub
ps. ParameterArray is defined in a class