Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unable to write parameter to linked file

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
GeertvanderHeide
207 Views, 5 Replies

unable to write parameter to linked file

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?

Tags (2)
Labels (1)
5 REPLIES 5
Message 2 of 6

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....

Message 3 of 6

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.

Message 4 of 6

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. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 6

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

 

Message 6 of 6

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report