Ilogic, referencing frame info

Ilogic, referencing frame info

Sandy3EG8M
Participant Participant
1,101 Views
4 Replies
Message 1 of 5

Ilogic, referencing frame info

Sandy3EG8M
Participant
Participant

Disclaimer, I'm not great at ilogic. I just have an idea of what questions to ask.

I've had to rethink the code I've got. What I'm trying to do now is reference the category, standard, family, size, material, and appearance of a frame member so that when all these are selected, it'll produce the description I need.

Sandy3EG8M_0-1667304335421.png

 

This is the code I have now. 

Sub Main()
Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(oAsm, "FG stock to part number")
For Each oDoc As Document In oAsm.AllReferencedDocuments
	If oDoc.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") _
		AndAlso oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oDoc.IsModifiable _
		AndAlso oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Count > 0
		
		Dim occName As String = oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Item(1).Name
		Dim oDesc As [Property] = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description")
		
		Try
		Select Case GetFamilyName(oDoc)
		Case "ANSI L (Equal angles)"
			oDesc.Value = "L" & Parameter(occName, "G_H") & " x " & Parameter(occName, "G_H") & " x " & RoundToFraction(Parameter(occName, "G_T"), 0.03125, RoundingMethod.Round) & " x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"
		Case "ANSI L (Unequal angles)" 'And "Angles"
			oDesc.Value = "L" & Parameter(occName, "G_W") & " x " & Parameter(occName, "G_H") & " x " & RoundToFraction(Parameter(occName, "G_T"), 0.03125, RoundingMethod.Round) & " x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"
		Case "ANSI ASTM"
			oDesc.Value = "ROUND ø" & Parameter(occName, "G_H") & " x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"
		Case "ANSI AISC HSS (Rectangular)"
			oDesc.Value = "HSS" & Parameter(occName, "G_H") & " x " & Parameter(occName, "G_H") & " x " & RoundToFraction(Parameter(occName, "G_T"), 0.03125, RoundingMethod.Round) & " x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"
		Case "ANSI AISC HSS (Square)"
			oDesc.Value = "HSS" & Parameter(occName, "G_W") & " x " & Parameter(occName, "G_H") & " x " & RoundToFraction(Parameter(occName, "G_T"), 0.03125, RoundingMethod.Round) & " x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"
			End Select
		Catch
		End Try
	End If
Next
oTransaction.End 'End the trasaction
End Sub

Function GetFamilyName(oDoc As PartDocument) As String
Try
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim propSet As PropertySet = oDef.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
Dim oContentCenter As ContentCenter = ThisApplication.ContentCenter
Return oContentCenter.GetContentObject("v3#" & propSet.Item("FamilyId").Value & "#").DisplayName
Catch
Return ""
End Try
End Function

 

0 Likes
1,102 Views
4 Replies
Replies (4)
Message 2 of 5

Preston_Reed
Advocate
Advocate

Hey @Sandy3EG8M , unfortunately this is not possible currently with Inventor.  There is not a way to control those selections with frame generators API.  

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/control-size-of-frame-generator-memb...

0 Likes
Message 3 of 5

Sandy3EG8M
Participant
Participant

I was afraid of that.

I got help here a few weeks ago that got me the family name, so I was hopeful.

There should be a way to at least get the material, though. Right?

 

I tried this, but obviously I'm doing something wrong.

Sub Main()

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(oAsm, "FG stock to part number") 
For Each oDoc As Document In oAsm.AllReferencedDocuments 'Traverse all referenced documents
	If oDoc.DocumentInterests.HasInterest("{AC211AE0-A7A5-4589-916D-81C529DA6D17}") _	
		AndAlso oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _'Part
		AndAlso oDoc.IsModifiable _	'Modifiable (not reference skeleton)
		AndAlso oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Count > 0 
		
		Dim occName As String = oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).Item(1).Name
		Dim oDesc As [Property] = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description")
	

'Descriptions:
		Try
		GetFamilyName(oDoc)

		If "ANSI ASTM" AndAlso iProperties.Material Is "ASTM A1085" Then
			oDesc.Value = "HSS" & Parameter(occName, "G_H") & " x " & Parameter(occName, "G_T") & "x" & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"

		ElseIf "ANSI ASTM" AndAlso iProperties.Material Is "ASTM A53 GR. B" Then
			oDesc.Value = "ø" & Parameter(occName, "G_H") & " PIPE SCH. 40 x " & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"

		ElseIf "ANSI ASTM" AndAlso iProperties.Material Is "ASTM A519 (SEAMLESS)" Then
			oDesc.Value = "TUBE ø" & Parameter(occName, "G_H") & " x " & Parameter(occName, "G_T") & Round((Parameter(occName, "B_L") * 25.4), 2) & " mm"			
			
		End If
		Catch
		End Try
	End If
	
	
Next
oTransaction.End 'End the trasaction
End Sub

Function GetFamilyName(oDoc As PartDocument) As String
Try
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim propSet As PropertySet = oDef.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
Dim oContentCenter As ContentCenter = ThisApplication.ContentCenter
'MessageBox.Show(oContentCenter.GetContentObject("v3#" & propSet.Item("FamilyId").Value & "#").DisplayName) 'Message displays the family name for each item
Return oContentCenter.GetContentObject("v3#" & propSet.Item("FamilyId").Value & "#").DisplayName
Catch
Return ""
End Try
End Function

 

0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor

You should be able to retrieve the material via the material alias column in CC by copying and changing the function in the original code. And if that failed you could likely also retrieve the material from the part document directly. 

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

A.Acheson
Mentor
Mentor

Here is a rule that will look at the available information in the CC part. The sub routine PropSetsInvestigation is the source for the Property and PropertySets information contained in the document. 

 

The category name is the most difficult name to retrieve as it is not held in the part properties themselves. It is the folder name in CC so to get to this it was necessary to loop through all the families in the CC, checking by family name until we reached the family of the part. As a result it could be slow depending on your CC size. You might be able to retrieve this name from elsewhere like the filename or build it into a customization column of the CC library.

Sub Main
	'[Retrieve Property sets from this part.
	'Use this list to target future iproperties 
	Dim oDoc As PartDocument = ThisDoc.Document
	Dim iproplist As New List(Of String)
	
	'  Call to find out what porperty sets are in this document hidden or visible
	PropSetsInvestigation(oDoc)
	
	Try
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim CCpropSet As PropertySet = oDef.Document.PropertySets.Item("Content Library Component Properties")'"{B9600981-DEE8-4547-8D7C-E525B3A1727A}"
	Dim ProjpropSet As PropertySet = oDef.Document.PropertySets.Item("Design Tracking Properties")

	iproplist.Add("Standard: " & ProjpropSet.Item("Standard").Value)

	FamilyName = CCpropSet.Item("Family").Value
    
	'Find out which category the family belongs too
	ReadContentCenter(ThisApplication.ContentCenter.TreeViewTopNode)
   
	iproplist.Add("Category : " & Category)
	iproplist.Add("Family : " & FamilyName)
	iproplist.Add("Size Designation: " & ProjpropSet.Item("Size Designation").Value)
	iproplist.Add("Material: " & ProjpropSet.Item("Material").Value)
	iproplist.Add("Appearance: " & ProjpropSet.Item("Appearance").Value)
	Catch
	End Try
	d0 = InputListBox("Prompt", iproplist, d0, Title := "Title", ListName := "List")
End Sub

Dim Category As String
Dim FamilyName As String

Private Sub ReadContentCenter(ByVal Node As ContentTreeViewNode)
	    For Each oNode As ContentTreeViewNode In Node.ChildNodes
	        If oNode.Families.Count > 0 Then
	            For Each oFamily As ContentFamily In oNode.Families
					If oFamily.DisplayName = FamilyName Then ' Export only one member to test column headers, comment if not required
						 Category  = oNode.DisplayName 
						 'Logger.Info(oNode.DisplayName)
						Exit For
					End If
				Next
	            If oNode.ChildNodes.Count > 0 Then
	                ReadContentCenter (oNode)
	            End If
			End If
	    Next
 End Sub

Sub PropSetsInvestigation(oDoc As Document)
	  For Each ps As PropertySet In oDoc.PropertySets
		  Logger.Info(ps.Name + " / " + ps.InternalName)
		  For Each p As [Property] In ps
	      	Logger.Info("  " + p.Name + " /" + Str(p.PropId))
		  Next
	  Next
End Sub
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes