How to access elements of .iam file in sheet view?

How to access elements of .iam file in sheet view?

Henryk_Konczylo
Explorer Explorer
414 Views
2 Replies
Message 1 of 3

How to access elements of .iam file in sheet view?

Henryk_Konczylo
Explorer
Explorer

Hello,

 

Is there a way to access underlined element, using iLogic?

What I want to do, is to count every underlined element, and then return somethink like this:

0002 -> 1

1001 -> 5

HenrykKonczylo_0-1631018293431.png

 

 

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

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Henryk_Konczylo 

How about something like this? 🙂

Run this rule in the drawing. The rule will prompt you to pick a view and then return a list as described by you 🙂

 

Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Pick view")
If oView Is Nothing Then Exit Sub
Dim sumString As String = "Components in view " & oView.Name & ":" & vbCrLf
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	For Each oRefDoc As Document In oDoc.AllReferencedDocuments
		Dim oCount As Integer = oDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count
		If oCount > 0 Then
			sumString = sumString & vbCrLf & IO.Path.GetFileNameWithoutExtension(oRefDoc.DisplayName) & " -> " & oCount
		End If
	Next
Else
	MsgBox("view doesn't reference an assembly")
	Exit Sub
End If
MessageBox.Show(sumString, "Occurrence count")
Message 3 of 3

Henryk_Konczylo
Explorer
Explorer

Many thanks,

Your code helped me a lot 🙂

 

I changed it a little 🙂

 

Dim oSheets As Sheets = ThisDoc.Document.Sheets
Dim oSheet As Sheet

For Each oSheet In oSheets
	oView = oSheet.DrawingViews.Item(1).Name
	
	Dim sumString As String = ""
	Dim oDoc As Document = oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

	If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		For Each oRefDoc As Document In oDoc.AllReferencedDocuments
			Dim oCount As Integer = oDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count
			If oCount > 0 Then
				sumString = sumString & vbCrLf & IO.Path.GetFileNameWithoutExtension(oRefDoc.DisplayName) & " -> " & oCount
			End If
		Next
	Else
		Logger.Info("view doesn't reference an assembly")

	End If
	Logger.Info(sumString)
Next

 

HenrykKonczylo_0-1631023244572.png

 

0 Likes