Un suppress and Suppress components in an assembly in a specific model state.

Un suppress and Suppress components in an assembly in a specific model state.

arnold.ogalo
Contributor Contributor
332 Views
3 Replies
Message 1 of 4

Un suppress and Suppress components in an assembly in a specific model state.

arnold.ogalo
Contributor
Contributor

Hey Community, 

I am trying to write an assembly ilogic rule that will:

1) Imports components based on selections of parts

2) Creates constraints between the components

3) Changes the active model states of components based on the chosen model state of the assembly. 

 

I have completed tasks 1 and 2. 

However, I have run into a problem where, changing to a different model state in the assembly suppresses the components in the assembly and at times suppresses the constraints too. 

 

Please advise.

Thank you.

 

0 Likes
333 Views
3 Replies
Replies (3)
Message 2 of 4

dalton98
Collaborator
Collaborator

I would need more specific information for the problem you are having (pictures and files).

 

A quick thought: from steps one and two it sounds like you are using ilogic to place and constrain parts, but in step three you are suppressing those same constraints and components?

 

I could be misunderstanding your situation, but if thats the case you would be better off using "Manage groups". If parts/ constraints are inside a manage they are dependent of that managed group so you wont have to create new components/ constraints every time you change your assembly. Heres an example:

ThisAssembly.BeginManage("Group 1")		‘no delete Function reqd.’
If BitType = "Flat"
Dim componentB = Components.Add("Flat", "screwdriver_bit_Flat.ipt")
ElseIf BitType = "Robertson"
Dim componentB = Components.Add("Robertson", "screwdriver_bit_Robertson.ipt")
ElseIf BitType = "TorxSmall"
Dim componentB = Components.Add("Torx Small", "screwdriver_bit_TorxSmall.ipt")
ElseIf BitType = "TorxStandard"
Dim componentB = Components.Add("Torx Standard", "screwdriver_bit_TorxStandard.ipt")
End If
Constraints.AddFlush("Flush1", "Part1:1", "Work Plane1", "Part2:1", "Work Plane1", offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)
ThisAssembly.EndManage("Group 1")
iProperties.InstanceValue("Part1:1", "PropertyName_Text") = "5" Constraints.AddFlush("Flush1", "Part1:1", "Work Plane1", "Part2:1", "Work Plane1", offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing) Constraints.AddRotate("Rotate1", "Part1:1", "Work Plane1", "Part2:1", "Work Plane1", ratio := 0.0, forwardDirection := False, asRotateTranslate := False, biasPoint1 := Nothing, biasPoint2 := Nothing)
0 Likes
Message 3 of 4

arnold.ogalo
Contributor
Contributor

I have attached a simple assembly to the inquiry that should clarify my question. 

When the Box Assembly is opened. There exists an ilogic code that imports the Part1.ipt and the Box.ipt. 

The code will also mate the 2 parts together. 

 

My inquiry is that when I switch from the master model state to the model state 1, both components are suppressed.  Which I don't want to happen.

1) Is there a way to control the component suppression with ilogic within a specific model state?

2) Am I able to control constraint dimensions within a specific model state using ilogic

 

I hope this inquiry is clear.

Thanks

0 Likes
Message 4 of 4

dalton98
Collaborator
Collaborator

Ok that makes more sense. How I would go about doing this is changing the assembly model state excel sheet, but this requires using vba. The other way of doing this would be to: make the model state active, make changes, repeat. If you are dealing with a lot of model states this would require many lines of code and may make the rule run slower. Anyways heres how it would look:

ThisApplication.ScreenUpdating = False
'Imports the Counter Pressure Plate
Dim componentA = Components.Add("Box:1", "Box.ipt", position := Nothing, grounded := True, visible := True, appearance := Nothing)
Dim componentB = Components.Add("Part1:1", "Part1.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

Constraints.AddFlush("Flush1", "Part1:1", "XZ Plane", "Box:1", "XZ Plane",
                     offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)
Constraints.AddFlush("Flush2", "Part1:1", "XY Plane", "Box:1", "XY Plane",
                     offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)
Constraints.AddFlush("Flush3", "Part1:1", "YZ Plane", "Box:1", "YZ Plane",
                     offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)


Dim oMS As String = ThisDoc.ActiveModelState

ThisDoc.ActiveModelState = "Master"
Component.IsActive(componentA.Name) = True
Component.IsActive(componentB.Name) = True
componentA.Occurrence.ActiveModelState = "Master"
componentB.Occurrence.ActiveModelState = "Master"

ThisDoc.ActiveModelState = "Model State1"
Component.IsActive(componentA.Name) = True
Component.IsActive(componentB.Name) = True
componentA.Occurrence.ActiveModelState = "Model State1"
componentB.Occurrence.ActiveModelState = "Model State1"

ThisDoc.ActiveModelState = oMS
iLogicVb.UpdateWhenDone = True
ThisApplication.ScreenUpdating = True

 

0 Likes