Hide/Remove Model Tree Items Using iLogic?? Is it possible?

munderwood4GRE6
Enthusiast
Enthusiast

Hide/Remove Model Tree Items Using iLogic?? Is it possible?

munderwood4GRE6
Enthusiast
Enthusiast

Hi all,

 

I'm developing some inventor part files to publish as Factory Assets. I'm looking for a way to remove features from the model tree like extrusions and such using iLogic so that all the Factory Asset shows in the model tree @ the assembly level is just the planes needed to land the part. I'm trying to make the Factory Assets simpler to use for end users who are using them to build systems and save them time from having to sift through all the features used to make the .ipt

 

Any ideas?

 

 

0 Likes
Reply
Accepted solutions (2)
886 Views
7 Replies
Replies (7)

WCrihfield
Mentor
Mentor

I don't think you can remove features from the model browser tree without deleting those features.  However, it sounds like you might benefit from either a simplified or derived model file representing that model, instead of the original model file.  In those files only one item remains on the model browser tree (other than the default folders like Origin), and no feature nodes (or other modeling history nodes) remain.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

SometimesInventorMakesMeAngry
Advocate
Advocate
Accepted solution

You can hide browser nodes with BrowserNode.Visibility = False. Not sure if it'll carry over into parent assemblies. Keep in mind that this is API functionality, but it can be done in an iLogic rule.

Good point!  I thought that might be possible, but had not messed with it before.

So, I just created a very simple iLogic rule to test/prove that it would work.  This was tested in a Part document (the part document was open and active on the screen at the time).  As soon as you run the rule, it will ask you to select a part feature.  Then it checks to make sure something was selected.  Then makes sure it is the right type of object, just to be sure.  Then it goes though a few simple steps to get the browser node of that selected feature.  Then 'toggles' its Visibility property.  I set this little routine up as a loop, so you can do it as many times as you want.  If you selected a feature that you didn't mean to turn off, just select it again, and it will be turned back on.

Repeat :
oFeat = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "Select a Feature.")
If IsNothing(oFeat) Then Exit Sub
If TypeOf oFeat Is PartFeature Then
	Dim oFeature As PartFeature = oFeat
	Dim oDoc As Document = oFeature.Parent.Document
	oPane = oDoc.BrowserPanes.Item("Model")
	oNode = oPane.GetBrowserNodeFromObject(oFeature)
	oNode.Visible = Not oNode.Visible
End If
If MsgBox("Repeat?", vbYesNo + vbQuestion, "") = vbYes Then GoTo Repeat

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

munderwood4GRE6
Enthusiast
Enthusiast

This worked great! Unfortunately, it did not carry over to the published factory asset and asset parts created in a Factory assembly 😞

 

My next question is could you do the same for planes in the Browser? When I run the rule they aren't available for selection like the features.

 

Also, would you be willing to share a rule that would turn all the hidden features in the model tree back to on?

0 Likes

WCrihfield
Mentor
Mentor
Accepted solution

I'm not sure how you may want these other variations of code all laid out, so I tried to incorporate all 3 functionalities into one iLogic rule for you.  This may not be the best order of operations.  Since we are dealing with three different tasks here, but all have similarities, I decided to put code for each into a Sub routine of its own.  There is one for resetting all 'invisible' browser nodes to 'visible'.  One for selecting a part feature, then toggling its browser node.  And one for selecting a WorkPlane, then toggling its browser node.  Theoretically, you could just change the 'filter' of the Pick function to something like "kAllEntitiesFilter", then use some Try...Catch blocks around portions of the code after that point, to help when dealing with other types of select-able objects, but that did not seem efficient, because most types of select-able objects do not have their own browser node.

Here is the new rule code:

 

Sub Main
	Dim oActiveDoc As Document = ThisApplication.ActiveDocument
	oPane = oActiveDoc.BrowserPanes.Item("Model")
	
	'run our Sub routine to reset visibility of every BrowserNode
	ResetAllNodeVisibility(oPane.TopNode)
	'could put a message here, just to pause the code, so you can check the browser pane
	
	'un-comment next line to run our Sub routine to toggle the visibility of a Feature we select
	'ToggleSelectedFeatureVisibility(oPane)
	
	'un-comment next line to run our Sub routine to toggle the visibility of a WorkPlane we select
	'ToggleSelectedWorkPlaneVisibility(oPane)
End Sub

Sub ResetAllNodeVisibility(oStartNode As BrowserNode)
	If oStartNode.BrowserNodes.Count > 0 Then
		For Each oNode As BrowserNode In oStartNode.BrowserNodes
			If Not oNode.Visible Then oNode.Visible = True
			ResetAllNodeVisibility(oNode)
		Next
	End If
End Sub

Sub ToggleSelectedFeatureVisibility(oModelPane As BrowserPane)
	oSel = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "Select a Feature.")
	If IsNothing(oSel) Then Exit Sub
	If TypeOf oSel Is PartFeature Then
		Dim oFeature As PartFeature = oSel
		oNode = oModelPane.GetBrowserNodeFromObject(oFeature)
		oNode.Visible = Not oNode.Visible
	End If
End Sub

Sub ToggleSelectedWorkPlaneVisibility(oModelPane As BrowserPane)
	oSel = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select a Work Plane.")
	If IsNothing(oSel) Then Exit Sub
	If TypeOf oSel Is WorkPlane Then
		Dim oWPlane As WorkPlane = oSel
		oNode = oModelPane.GetBrowserNodeFromObject(oWPlane)
		oNode.Visible = Not oNode.Visible
	End If
End Sub

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

munderwood4GRE6
Enthusiast
Enthusiast

This is very helpful.  Thanks so much for your response!!  Do you have any recommendations for documentation or resources for learning more advanced coding / iLogic that can be used in Inventor either through iLogic or API?

0 Likes

WCrihfield
Mentor
Mentor

That is a burning question for a great many people, and doesn't really have a great answer.  The main code language used by (and expected within) the iLogic add-in's rule editor dialog is VB.NET.  You can find tons of info on learning that coding language online (general searches), but most of it is geared towards you using Visual Studio when you are interacting with vb.net code, which is not the case here.  There are lots of what we call 'iLogic Snippets' (bits of code for Inventor specific purposes, and interact with Inventor specific objects) that only exist within the iLogic add-in, and you won't find them out in the general internet searches under vb.net though.

 

There are a few main places to find the bulk of what documentation & information is available about Inventor's API / iLogic /VBA.  One such place is a section of Inventor's online help.  On that main page you will see several main categories of information along the left side.  The ones called "Programming Interface", "iLogic", & "iLogic API" are the ones you will want to focus on.

WCrihfield_0-1638210759981.png

Then for a better understanding of what (Methods, Properties, & Events) are available under each type of Inventor object, you can explore under the "Programming Interface" > "Inventor API Reference Manual" > "Objects" area.  Within that area is a long scrolling list of Objects.  These are 'most' of the Inventor specific types of things you can access and/or interact with by code using Inventor's (API/iLogic/VBA).

 

Then the next best place to find lots of information about Inventor's (API/iLogic/VBA) is here on this forum (Inventor iLogic, API & VBA Forum).  It's not as organized, so you will have to do a lot of searching and reading, but there are tons of code examples you can review.  And if you can't find what you are looking for, you can always ask us here on the forums, because that's what it is all about.  Many of the forum members may also have their own blogs or websites too that may host related instructional content.  If the company you work for buys its Autodesk software from a large enough provider, that provider may also offer lots of great resources and instructional webcasts and/or documentation that will help you learn these kinds of things.  I learned through all these means, like most folks, the normal processes of trial & error experience, reading online help about things I'm unfamiliar with, reading through forum posts related to the task at hand, and asking other folks with more experience than myself (though any means necessary).

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)