Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: Maxim-CADman77

Hi @Maxim-CADman77.  I like the general idea you are pointing out here.  That route would be pretty safe for getting the 'Origin' folder, since there will always be those original work features in every 'model' document.  When going that route, would likely want to include a check to make sure this is a mode document (part or assembly, not a drawing) before attempting to dig into its ComponentDefinition to access features.  And with the other folders inquired about here, we would most likely want to check the Count of each SketchBlocks, SurfaceBodys, DesignViewRepresentations, and ModelAnnotations type collections to make sure there is at least one, then attempt to get the first item of that type, then use that item to get its browser node, then get that node's parent node.  The Blocks & Annotations folders do not even show up until we include some of those types of objects in the document.  And there seems to be some sort of limitation when it comes to getting either the BrowserNode or the NativeBrowserNodeDefinition for the first SurfaceBody object, because it usually fails for me, and throws an 'Unspecified Error' type exception (COMException - EFail).  Also had problems going that route to get the DesignViewRepresentations folder node (no error/exception, just did not work).

 

(I attached a text file containing some modified iLogic rule code I quickly threw together for testing purposes, to do this forum topic task (expand multiple specific browser folders) from a bottom > up approach (get node, then get parent, then expand it).  It seems to work OK for expanding the 'Blocks', 'Annotations', and 'Origin' nodes, but is not working for 'Solid Bodies' or 'View' nodes so far.

 

I agree that 'professional' code should not rely on an unstable aspect of an object to find it, such as its name when that name is user changeable and changes with language, but I was not really developing a 'professional' code (like for a standalone Windows App I was planning on selling) at that time, just a working iLogic rule solution to a forum user request, which was posted within 30 minutes of the request.

 

Plus, I did not realize at the time that the 'Origin' folder could be renamed.  It seems to me like this was not always possible, but in all the years I have been using Inventor, I have never wanted or needed to rename that folder, and have never seen anyone else want or need to rename it.  I did check within the 'What's New' documentation for the last few major releases of Inventor, but did not see any mention of this specific ability changing, so I do not know when it became available.  If someone is using an installation of Inventor other than English, but they understand English enough to read this post, and want to copy and use my code from above, it should be fairly clear that they could change the "Origin" text (and others) to some other text within the Sub Main area.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)