Get the Browser Folder containing a component occurrence or occurrence pattern?

Get the Browser Folder containing a component occurrence or occurrence pattern?

amitabhVA4SD
Advocate Advocate
1,081 Views
3 Replies
Message 1 of 4

Get the Browser Folder containing a component occurrence or occurrence pattern?

amitabhVA4SD
Advocate
Advocate

Hello,

 

Is there any direct API that fetches the Browser Folder containing a component occurrence or an occurrence pattern?

We can get the Browser Node from a component occurrence using the BrowserPane.GetBrowserNodeFromObject but I couldn't find an API to get to the containing folder from the browser node.

 

I also found out that the GetBrowserNodeFromObject may not be a good solution in the case of component patterns

https://adndevblog.typepad.com/manufacturing/2013/04/get-browsernode-of-an-occurrence.html

 

I need to let the user select a component occurrence and display the containing folder Name. What is the most optimized way to handle this using Inventor API?

 

Inventor API Team and Experts please help

@MjDeck @JelteDeJong @YuhanZhang 

 

Thanks,

Amitabh Mukherjee

 

 

0 Likes
Accepted solutions (1)
1,082 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Hopefully I am correct here, you will need to loop through the browser folders and look for the object to match that you have selected then retrieve the folder name when found. I don’t believe the occurrence objects have any knowledge of the container/folder they are inside.

https://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-A2D7CBA0-28F5-400E-94E3-FB51D8AD9C71

 

This post deals with patterns inside folders but with the folder name already determined.

https://adndevblog.typepad.com/manufacturing/2015/05/suppress-folder-in-assembly.html

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

amitabhVA4SD
Advocate
Advocate

Thank you, @A.Acheson!

That example explains clearly the Inventor API Object Model hierarchy related to the BrowserPane and BrowserNode

BrowserPane > TopNode > BrowserFolders > BrowserFolder > BrowserNode > BrowserNodes  > NativeObject

Let us wait to see if the Inventor API Internal team has a better approach to the problem.

 

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

This is a small sample how to extract folder name from occurrence and display it in PromptMessage during pick

 

Sub Main
	Dim activeDoc As Document = ThisDoc.Document
	Dim browser As BrowserPane = activeDoc.BrowserPanes.ActivePane

	Dim pick As Object
	Dim prompt = "Select pattern element"
	Do
		StartSelection :
		pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, prompt)
		Try
			Dim occ As ComponentOccurrence = pick
			Dim node = browser.GetBrowserNodeFromObject(occ)

			Dim parentNode As BrowserNode = node.Parent
			Do While parentNode IsNot Nothing
				If parentNode.NativeObject.Type = ObjectTypeEnum.kBrowserFolderObject Then
					prompt = parentNode.BrowserNodeDefinition.Label
					GoTo StartSelection
				End If
				parentNode = parentNode.Parent
			Loop

		Catch
			' Ignore
		End Try
	Loop While pick IsNot Nothing
End Sub