- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
My question has to do with the addition of Model States in Inventor. I want to control parameters from iLogic according to Model State from an assembly. Sure I can set manually or from excel, different values for parameters in the part, but in the assembly some of those, in my case, are often changing according to the use of the part and the customer's order.
Until 2021 I was connecting the parameters of an assembly via ilogic, with parameters inside the parts that belong to this assembly. So by changing the parameter in the assembly, all the parts with an ilogic connection to it, were changing accordingly.
With model states, how can I specify which exact parameter i want to change to the exact model state?
To clarify I will give an example:
- I have Part1 that has a parameter called "Length". This parameter changes according to 3 model states.
Model State1 => Length = 1000 mm
Model State2 => Length = 2000 mm
Model State3 => Length = 3000 mm
- In an assembly I have 3 parameters called "Length_1", "Length_2", and "Length_3".
Now in the assemply I will add Part1 with 3 model states, and I would like to connect it with the bellow logic:
Parameter("Part1:1" , "Length") = Length_1 '(Model State1)
Parameter("Part1:2" , "Length") = Length_2 '(Model State2)
Parameter("Part1:3" , "Length") = Length_3 '(Model State3)
With a colleague we managed to find a solution that seems to be working:
Dim AssDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim Occ As Inventor.ComponentOccurrence
Dim partcomp As PartComponentDefinition
Dim partdoc As Inventor.PartDocument
Occ = AssDoc.ComponentDefinition.Occurrences.ItemByName("Part1:1")
partdoc = Occ.Definition.Document
Occ.ActiveModelState = "Model State1"
partdoc.ComponentDefinition.Parameters.UserParameters.Item("Length").Value = Length_1
AssDoc.Update2
AssDoc.Save2
Occ = AssDoc.ComponentDefinition.Occurrences.ItemByName("Part1:2")
partdoc = Occ.Definition.Document
Occ.ActiveModelState = "Model State2"
partdoc.ComponentDefinition.Parameters.UserParameters.Item("Length").Value = Length_2
AssDoc.Update2
AssDoc.Save2
Is there a simpler way or better way to do that?
Solved! Go to Solution.