Find frame generator assembly from frame gen part

Find frame generator assembly from frame gen part

Rich-T
Advocate Advocate
901 Views
6 Replies
Message 1 of 7

Find frame generator assembly from frame gen part

Rich-T
Advocate
Advocate

Hi.

I'm trying to write an iLogic rule to find a frame generator assembly from one if its sub parts.

 

The user selects a part in the assembly and if it is flagged as a frame generator part by an iproperty value then I want to get the part number/filename of the frame generator assembly.

 

Is this possible? See existing code below 

 

Sub main()

	Dim oPart As ComponentOccurrence
	Dim Prop As String
	Dim oDoc As Document

	oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component")

	If oPart Is Nothing Then
		Exit Sub
	Else
		oDoc = oPart.Definition.Document
		'MessageBox.Show(oDoc.DisplayName, "Document Name")
		'MessageBox.Show(oDoc.FullFileName, "FullFileName")
	End If

	If TypeOf oOccurrence Is ComponentOccurrenceProxy Then
    		Prop = iProperties.Value(oDoc.NativeObject.Name, "Summary", "Title")
		Else 
    		Prop = iProperties.Value(oDoc.DisplayName, "Summary", "Title")
	End If

	If Prop = "Frame Generator" Then 
		'MessageBox.Show(Prop, "iProperty Value")
	
	'***   FIND THE FRAME GENERATOR ASSEMBLY PART NUMBER HERE ***
	End If

End Sub

 

0 Likes
Accepted solutions (1)
902 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Have a read of this post. It uses the has interest so you can specifically target the frame generator addin components.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Rich-T 

 

Here's an iLogic example of one way to tackle this problem. It checks if the selected occurrence is a frame member, then looks at its occurrencepath to find the frame document in there 🙂

 

Dim oOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component")
If oOcc IsNot Nothing Then
	Dim oDoc As Document = oOcc.Definition.Document
	If oDoc.DocumentInterests.HasInterest("FrameMemberDoc") Then
		Dim FrameAsm As ComponentOccurrence = oOcc.OccurrencePath.Cast(Of ComponentOccurrence).FirstOrDefault(Function(x As ComponentOccurrence) _
		x.Definition.Document.DocumentInterests.HasInterest("FrameDoc"))
		If FrameAsm IsNot Nothing Then
			Dim FrameAsmDoc As AssemblyDocument = FrameAsm.Definition.Document
			MsgBox("Frame assembly part number: " &
			FrameAsmDoc.PropertySets("Design Tracking Properties")("Part Number").Value _
			& vbCrLf & "Frame assembly displayname: " & FrameAsmDoc.DisplayName)
		End If
	Else
		MsgBox("that's not a frame member")
	End If
End If
0 Likes
Message 4 of 7

Rich-T
Advocate
Advocate

That's excellent, thanks Jhoel

0 Likes
Message 5 of 7

Rich-T
Advocate
Advocate
Can you look up one more level - to the assembly containing the "FrameDoc" and return the assembly fullpath and filename ?
0 Likes
Message 6 of 7

JhoelForshav
Mentor
Mentor

Hi @Rich-T 

Something like this? 🙂

Dim oOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component")
If oOcc IsNot Nothing Then
	Dim oDoc As Document = oOcc.Definition.Document
	If oDoc.DocumentInterests.HasInterest("FrameMemberDoc") Then
		Dim FrameDocParent As AssemblyDocument
		For i = oOcc.OccurrencePath.Count - 1 To 1 Step -1
			If oOcc.OccurrencePath(i).Definition.Document.DocumentInterests.HasInterest("FrameDoc")
				FrameDocParent = If (i = 1, ThisDoc.Document, oOcc.OccurrencePath(i - 1).Definition.Document)
				Exit For
			End If
		Next
		MsgBox("FrameDoc Parent Assembly: " & FrameDocParent.FullFileName)
	Else
		MsgBox("that's not a frame member")
	End If
End If
0 Likes
Message 7 of 7

Rich-T
Advocate
Advocate

VERY NICE.

THANKS JHOEL

0 Likes