Frame Generator Copy Design Browser Node Issues

Frame Generator Copy Design Browser Node Issues

ethanfL67BY
Enthusiast Enthusiast
202 Views
2 Replies
Message 1 of 3

Frame Generator Copy Design Browser Node Issues

ethanfL67BY
Enthusiast
Enthusiast

https://forums.autodesk.com/t5/inventor-forum/frame-generator-copy-design-browser-node-issues/td-p/1... This is my issue and I need some help with this ilogic code. I tried to use Chat Gpt on this but I can't get it to work. I would like to hop on a teams call with a developer and trouble shoot this. Thank you!

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ethanfL67BY.  After reviewing that other, older forum topic, I think I may be able to help some with a code-based solution for that.  I honestly rarely use the frame generator add-in for Inventor, and never use the 'copy design' type process, so purely helping with the code aspect of things here.  Below is another iLogic rule that you can try out.  It expects an assembly to be the 'active' document when it gets ran, otherwise it will not do anything.  When ran, it will first prompt you to enter the name of the folder you want to change using a simple InputBox, then will prompt you the same way to enter the new name for that folder.  If nothing is entered either time, the code will exit.  After that point, it gets the browser pane, and its nodes, then passes that collection off to a 'recursive' Sub routine, with instructions to process each node using another custom Sub routine.  When that process encounters a node labeled with the existing folder's name, it checks if it is a BrowserFolder, and if so, sets it to allow renaming, then renames it to the new name.  I am using a 'recursive' routine for this, since I don't know which index or level it will be found at.

I have not tested this yet myself, so be cautious.

Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oADoc As AssemblyDocument = TryCast(ThisDoc.FactoryDocument, Inventor.AssemblyDocument)
	If oADoc Is Nothing Then Return
	
	'these two String variables are declared after this routine, but before others
	sCurrentName = InputBox("Enter Current Folder Name", "Current Folder Name", "")
	If sCurrentName = "" Then Return
	
	sNewName = InputBox("Enter New Folder Name", "New Folder Name", "")
	If sNewName = "" Then Return
	
	'using its 'internal name', specifically for assemblies, which is language independent
	Dim oModelPane As Inventor.BrowserPane = oADoc.BrowserPanes.Item("AmBrowserArrangement")
	Dim oTopLevelNodes As BrowserNodesEnumerator = oModelPane.TopNode.BrowserNodes
	'call recursive Sub routine to process this collection
	RecurseBrowserNodes(oTopLevelNodes, AddressOf ProcessBrowserNode)
	oADoc.Update2(True)
End Sub

'declared between routines, to make the accessible by all routines
Dim sCurrentName, sNewName As String
Dim bStop As Boolean 'False by default

Sub RecurseBrowserNodes(Nodes As Inventor.BrowserNodesEnumerator, Predicate As Action(Of Inventor.BrowserNode))
	If (Nodes Is Nothing) OrElse (Nodes.Count = 0) Then Exit Sub
	For Each Node As Inventor.BrowserNode In Nodes
		If bStop Then Return 'exit iterations & recursion, of end task has been accomplished
		Predicate(Node) 'calls other specified Method (Sub or Function) to process this BrowserNode
		If Node.BrowserNodes.Count > 0 Then RecurseBrowserNodes(Node.BrowserNodes, Predicate)
	Next 'Node
End Sub

Sub ProcessBrowserNode(Node As Inventor.BrowserNode)
	If Node.BrowserNodeDefinition.Label = sCurrentName Then
		Dim oNObj As Object = Nothing
		'accessing this property's value can throw an exception
		Try : oNObj = Node.NativeObject : Catch : End Try
		If (oNObj IsNot Nothing) AndAlso (TypeOf oNObj Is Inventor.BrowserFolder) Then
			Dim oFolder As Inventor.BrowserFolder = oNObj
			oFolder.AllowRename = True
			oFolder.Name = sNewName
			bStop = True
		End If
	End If
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

ethanfL67BY
Enthusiast
Enthusiast

@WCrihfield
This code worked great and was exactly what I was looking for! Thank you so much for your help! I appreciate the very quick responce! 

0 Likes