strange behavoir after running iLogic Rule... I'm Clueless

strange behavoir after running iLogic Rule... I'm Clueless

jpchaisson
Advocate Advocate
412 Views
2 Replies
Message 1 of 3

strange behavoir after running iLogic Rule... I'm Clueless

jpchaisson
Advocate
Advocate

This has me throwing my hands up, I cant figure this out...

 

So to recreate this behavior create a small sub-assembly with 2-3 positional Reps and place it in a new assembly. 

 

create a Rule in iLogic called "PosRepSelector" and copy this code to the rule and then run it from your assembly with the sub-assembly in it.

 

after running the rule and changing the Positional Rep, if you try and place from Vault its now greyed out. this only happens when the rule has been ran. can anyone explain why? 

 

oDoc = ThisDoc.ModelDocument

	If oDoc.DocumentType = kPartDocumentObject Then
		MessageBox.Show("This rule can only be ran in an Assembly file, exiting now.", "Message")
		Return
	End If

Dim oTargetOcc As ComponentOccurrence
	Do While True
		oTargetOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Assembly to Modify... Press ESC to Cancel")
		If Not oTargetOcc Is Nothing Then
			Exit Do
		Else
			Dim oResultMsg As MsgBoxResult = MsgBox("No Assembly Selected... Exit?", 36, "Message")
			If oResultMsg = vbYes Then
				Return
			Else
				Return 'DO NOTHING KEEP LOOPING...
			End If
		End If
	Loop

'set a reference to the assembly component definition.
'This assumes an assembly document is open.
Dim oCompDef As AssemblyComponentDefinition
	'oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
	oCompDef = oTargetOcc.Definition

'define pos rep 
Dim oPosRep As PositionalRepresentation
Dim sPosRep As String
Dim MyArrayList As New ArrayList

'record the active view rep name
Dim sActivePosRep As String
	sActivePosRep = oCompDef.RepresentationsManager.ActivePositionalRepresentation.Name

	For Each oPosRep In oCompDef.RepresentationsManager.PositionalRepresentations
		MyArrayList.Add(oPosRep.Name)
	Next
sPosRep = InputListBox("Select from the list:",MyArrayList, sActivePosRep, "iLogic", "Positional Reps")

oCompDef.RepresentationsManager.PositionalRepresentations.Item(sPosRep).Activate

oTargetOcc.ActivePositionalRepresentation = sPosRep

 

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

jpchaisson
Advocate
Advocate

So after posting this I figured out that after running the Rule if I double click on the sub-assembly making it active and then immediately returning back to my upper assembly Place from Vault is now active again. So im assuming I need something in my rule that quickly puts the sub-assembly in edit and the returns to the assembly. 

0 Likes
Message 3 of 3

jpchaisson
Advocate
Advocate
Accepted solution

So I found a solution to my own Bug. this doesn't happen often but wanted to share incase it can help anyone else.

 

I added these two lines of code to the end of my rule.

 

oTargetOcc.Edit

oTargetOcc.ExitEdit(kExitToParent)

 

If anyone has any other solutions  please share still.