Use form to choose model state.

Use form to choose model state.

henrikubbe4438
Advocate Advocate
722 Views
3 Replies
Message 1 of 4

Use form to choose model state.

henrikubbe4438
Advocate
Advocate

Short question:

Is it possible to get a dynamic list of all model states?

 

Usercase:

I would like to be able to choose between model states when placing a part or assembly file in an assembly.

My solution as it is now is this:

a user parameter, pState, which is a multivalue parameter with all the model state names.

a Form with a radio box, showing pState, This is shown when placing component in an assembly.

a rule containing only:

ThisDoc.ActiveModelState = pState

All is fine and dandy until I or a collegue make a new model state, or renames an existing. 

 

EDIT: Just now it stopped working when I try placing the component in an assembly. It works fine when I'm in the file, though. Gotta try and find what I broke...

 

Now I have to update the user parameter list to correspond with the list of model states. This I want to automate.

 

Is it possible to extract a list of all model states to update pState:

MultiValue.SetList("pState", "All", "Different", "Model", "States", "...")

 

Am I making sense? Is there an better solution to obtain this?

 

PS: I have a rule containg 

pState = ThisDoc.ActiveModelState 

 which triggers if someone changes model state from the model state list, just to keep functionality. 

0 Likes
Accepted solutions (1)
723 Views
3 Replies
Replies (3)
Message 2 of 4

dalton98
Collaborator
Collaborator
Accepted solution

Try this

Dim oDoc As PartDocument = ThisDoc.Document
Dim oList As New ArrayList
Dim oModelState As ModelState
For Each oModelState In oDoc.ComponentDefinition.ModelStates
	oList.Add(oModelState.Name)
Next

MultiValue.SetList("pState", oList.ToArray)  

 

Message 3 of 4

henrikubbe4438
Advocate
Advocate

Thank you! This does the trick with the choosing.

 

Still got error when placing in an assembly, but that might be related to something else. 

Hmm, does "ThisDoc" point to the assembly file or the part file activated from a form in the part file?

 

This is my new rule, I added some error handling for flavour:

If you renamed a model state and then tried to choose the old name from the form list it crasched.

Dim oDoc As PartDocument = ThisDoc.Document
Dim oList As New ArrayList
Dim oModelState As ModelState
For Each oModelState In oDoc.ComponentDefinition.ModelStates
	oList.Add(oModelState.Name)
Next
MultiValue.SetList("pState", oList.ToArray)

Try
	ThisDoc.ActiveModelState = pState
Catch
	ThisDoc.ActiveModelState = "Master"
End Try

 

0 Likes
Message 4 of 4

snguyenSWVMS
Advocate
Advocate

Dalton98

I have a top assy. with couple MS model State and a 10 to 15 sub asemblies and they all have few MS.

Right now I am manual seleted the MS and save the top assembly.

I use the iLOgic form to fill out the model iproperty and they work very well.

I wonder if the form idea and use in this top assembly and select the MS option.

I am thinking about when open the assembly all part/assy are suppress (blank assy.) then pull up the form and pick the opetion (MS) and the part/ assy get unsuppress.

Is that possible? Is there a line of code you can help me?

I jsut need a line of code as an example for one sub assembly this top assembly. I am not sure how you would do this iLogic but if you can help to start I can follow to do the rest.

See the attached picture for the assembly.

I will created the iLogic form how I pull down and pick the option from the top assu to all the sub assembly in it.

Thanks

0 Likes