iLogic to identify if component was created by Frame Generator

iLogic to identify if component was created by Frame Generator

J_Dumont
Advocate Advocate
2,876 Views
8 Replies
Message 1 of 9

iLogic to identify if component was created by Frame Generator

J_Dumont
Advocate
Advocate

Hello.

I am hoping someone can help with iLogic code to identify if a component was created by Frame Generator. I have a program that processes each file in an assembly and need to identify if a component was placed by FG. If I place a structural member using "Place from Content Center" it is seen by my code as created by FG. I need to filter members created by FG and other members that were just placed manually.

I have to believe there is some identifying feature because if I right-click on a manually placed member I can change size but if I right-click on an FG member the menu displays "Edit with FR".

 

0 Likes
Accepted solutions (2)
2,877 Views
8 Replies
Replies (8)
Message 2 of 9

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @J_Dumont 

Check if the document has interest "{AC211AE0-A7A5-4589-916D-81C529DA6D17}"

That means it's created by frame generator. Simple ilogic example:

 

Dim oDoc As Document = ThisDoc.Document
If oDoc.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") = True
MsgBox("Created by Frame Generator")
Else
MsgBox("Not created by Frame Generator")
End If

 

Here is an example I'm using to traverse all frame generator parts in an assembly and change their base unit to each.

Sub Main()
Dim oRun As DialogResult = MessageBox.Show("Vill du kontrollera basenhet för alla FG-komponenter?" & vbCrLf & "Detta måste göras före incheckning i vault!" _
, "Basenhet Frame Generator", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oRun = DialogResult.Yes
Dim asmDoc As AssemblyDocument = ThisDoc.Document
BU2Each(asmDoc)
End If
End Sub
Sub BU2Each(ByVal asm As AssemblyDocument)
Dim oOcc As ComponentOccurrence
For Each oOcc In asm.ComponentDefinition.Occurrences
	Try
		If Component.IsActive(oOcc.Name) Then
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		If oOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") = True _
		And oOcc.Name <> "Frame Reference Model" Then
		oOcc.Definition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)
		End If
		ElseIf oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			BU2Each(oOcc.ReferencedDocumentDescriptor.ReferencedDocument)
		End If
		End If
	Catch
	End Try
Next

End Sub

Hope it helps 🙂

Message 3 of 9

J_Dumont
Advocate
Advocate

Hi Jhoel ,

Thank you very much, the code works great!

I'm hoping you can help with some syntax. Your code updates the base quantity but I also need to update two properties with one being a custom property for each FG member.

0 Likes
Message 4 of 9

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @J_Dumont 

Here you can find a list of all names for property sets and properties:

https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

Use theese as in the example below. Let me know how it goes 🙂

 

Sub Main()
Dim oRun As DialogResult = MessageBox.Show("Vill du kontrollera basenhet för alla FG-komponenter?" & vbCrLf & "Detta måste göras före incheckning i vault!" _
, "Basenhet Frame Generator", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oRun = DialogResult.Yes
Dim asmDoc As AssemblyDocument = ThisDoc.Document
BU2Each(asmDoc)
End If
End Sub
Sub BU2Each(ByVal asm As AssemblyDocument)
Dim oOcc As ComponentOccurrence
For Each oOcc In asm.ComponentDefinition.Occurrences
	Try
		If Component.IsActive(oOcc.Name) Then
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		If oOcc.ReferencedDocumentDescriptor.ReferencedDocument.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") = True _
		And oOcc.Name <> "Frame Reference Model" Then
		'Set Base quantity
		oOcc.Definition.BOMQuantity.SetBaseQuantity(BOMQuantityTypeEnum.kEachBOMQuantity)
		'Set Properties
		Dim oPropSets As PropertySets = oOcc.Definition.Document.PropertySets
		Dim oCustomProps As PropertySet = oPropSets.Item("Inventor User Defined Properties")
		'If property exists set value else create it with value
		'In this example the custom property name is NameOfProperty
		'and its value is PropertyValue
		Try
		 oCustomProps.Item("NameOfProperty").Value = "PropertyValue"
		Catch
		oCustomProps.Add("PropertyValue", "NameOfProperty")
		End Try
		'The same goes for non custom properties aswell.
		'You just need to know the name of the property set and the property
		'I'll include a link to a list of property sets and values.
		'In this example I'll change the Title property:
		Dim oTitle As Inventor.Property = oPropSets.Item("Inventor Summary Information").Item("Title")
		oTitle.Value = "Test Title"
		
		End If
		ElseIf oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			BU2Each(oOcc.ReferencedDocumentDescriptor.ReferencedDocument)
		End If
		End If
	Catch
	End Try
Next

End Sub
Message 5 of 9

J_Dumont
Advocate
Advocate

Hi Jhoel,

Thank you for your help with the issue.

Your solution worked perfectly!!

 

Message 6 of 9

skotzur
Contributor
Contributor

Great info! Is there also a unique identifier for the endcaps? They don't seem to have the same HasInterest. Thanks in advance.

Message 7 of 9

JhoelForshav
Mentor
Mentor

Hi @skotzur 

I dont have the library for end caps installed right now, and since it's such a new feature there isn't much documentation about it online. When I get around to installing it I'll investigate to see if i can find a way to identify these parts 🙂

 

Since this thread is already marked as solved i think the question will get more attention if you start a new thread for it.

Message 8 of 9

J_Dumont
Advocate
Advocate

My suggestion on End Caps to use Content Center Editor and do a "Save Copy As to your own Read/Write library and add a column and map it to a custom property with a unique value that you can test for in your iLogic code.

 

J_Dumont_0-1588070766728.png

 

 

 

Message 9 of 9

skotzur
Contributor
Contributor
Jim, that's a great idea. The libraries created for EndCaps appear to be
used only for endcaps in weldments. I'll look into this solution. Thanks!