Message 1 of 4
Model states - More then 1 parameter to controll it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So im trying to figure out how to creat model states based on 3 paramteres on the part.
I have found/made a iLogic rule to make this, but i can only seem to get it to work with 1 parameter.
Sub Main Dim doc As AssemblyDocument = ThisDoc.Document 'Manage Lenght SetModelState(doc.ComponentDefinition.Occurrences.ItemByName("Bjelke:1"), BjelkeLengde) InventorVb.DocumentUpdate() End Sub Private Sub SetModelState(bracketOcc As ComponentOccurrence, Lengde As String) Dim bracketCompDef As PartComponentDefinition = bracketOcc.Definition.Document.ComponentDefinition 'This factory document is new! Dim bracketFacDoc As PartDocument = bracketCompDef.FactoryDocument Dim bracketModelStates As ModelStates = bracketFacDoc.ComponentDefinition.ModelStates 'Check if the model state exists already by looking at names Dim stateToSet As ModelState = (From foundModelState As ModelState In bracketModelStates Where foundModelState.Name = Lengde).FirstOrDefault If stateToSet IsNot Nothing Then bracketOcc.ActiveModelState = stateToSet.Name Else 'Create a new model state stateToSet = bracketModelStates.Add(Lengde) 'Activate the new model state before we update the user parameter as this is different per state stateToSet.Activate 'Find the "Length" user parameter Dim foundParameter As UserParameter = (From param As UserParameter In bracketFacDoc.ComponentDefinition.Parameters.UserParameters Where param.Name = "Lengde").FirstOrDefault foundParameter.Expression = Lengde 'Finally set this new model state as active for the bracket occurrence we were given bracketOcc.ActiveModelState = stateToSet.Name End If End Sub
This is the code im using so far. This is working fin and is changing the model and creating new model states if the paramter chosen do not match.
The model i want to creat model states in has 3 properties that can be changed. (Lenght/width/height)
Is it posibal and can someone guide me into the right directions on how i can use 3 diferent paramteres to creat 1 uniqe model state?
I want to set all 3 paramteres and then check it the modell states exist or should be createt.