Nifty Attributes

Many of you are familiar with the Attribute Helper add-in that I wrote many years ago to help with some programs I was writing that used attributes.  Autodesk is now including it as one of the programs delivered with the Developer Tools installer in the SDK that’s installed when you install Inventor.  I’ve been working on some programs recently that heavily use attributes and encountered a couple of bugs in my old version and also wished I had a couple of additional features.  I went ahead and upgraded the program and to differentiate it from the other one still being delivered have changed the name to “Nifty Attributes”.

To download the installer, click the button below.

 

Introduction

Working with attributes can sometimes be a bit frustrating because the only access you have to attributes is through the API.  You can’t quickly create, edit, or view an attribute without writing a program to do it.  Because of this, I was frustrated when working on my first program that made extensive use of attributes.  For the program to function correctly the attributes it was using all had to be correct and it was difficult to debug problems to determine if the problem was my program or the attributes it was trying to access.

For my own sanity I wrote a little utility that would let me view all of the attributes in a document.  That helped a lot but I never felt it was finished because it only allowed me to view existing attributes and I still couldn’t easily create or edit an existing attribute without writing code. This app is my solution to that.

The app is an add-in and to use it download and install it using the button below.  If Inventor is running, you’ll need to restart it to allow Inventor to refresh it’s available add-in list.  When installed, the Nifty Attributes command is added to the Tools tab, in the Part, Assembly, Drawing, Presentation, and iFeatures ribbons, as shown below.

CommandLocation

Running the Nifty Attributes command displays the dialog below.

The dialog lists all the entities that have any attributes associated with them.  In the example above there aren’t any attributes in the part so the dialog is empty.

Adding and Editing Attributes

You can use the Nifty Attributes utility to add an attribute set to any entity that supports attributes.  To add an attribute, run the Nifty Attributes command, and while the Nifty Attributes dialog is displayed, select, and then right-click the entity you want to add the attribute set to.  The context menu shown in the picture below will be displayed.  You can select an entity in the graphics window or the browser.  In the example below, a face was selected and then right-clicked to display the context menu and access the Add Attribute Set command.  Running the Add Attribute Set command displays the dialog shown on the right below where you can specify the name of the set.

Once the attribute set is added, the dialog is updated to show the entity and the associated attribute set, as shown below.  Clicking on the entity (“Face” in this case) will highlight the associated entity in the graphics window.

You can edit the name of an attribute set, delete it, or add attributes to it using the context menu on the attribute set node, as shown below.

When you create an attribute, the dialog shown below is displayed where you specify the name, type, and value.  The value of a Byte Array type of attribute is set using the syntax shown below; comma delimited numbers where the values can be any number from 0 to 255.

You can double-click on an attribute node to edit it or use the context menu to edit or delete the attribute.

For string types of attributes, the add-in checks to see if the value is an XML or JSON formatted string and if it is an additional “View Formatted” button is displayed, as shown below.  Clicking this button will open another dialog and display the data in a formatted display, as shown on the right. The formatted display is only for viewing, editing can only be done in the “Create Attribute” dialog.

Finding Attributes

All of the attributes that exist in the document are displayed in the dialog when you run the Nifty Attributes command. However, if you’re writing a program that makes extensive use of attributes it can be difficult to match the item in the list with the entity in the graphics window. Clicking on a node in the list will highlight the corresponding entity in the graphics window but that can be tedious if the list is large. Instead, you can use the “Find Object in Dialog” functionality available in the context menu of the entity.  Select and right-click on any entity in the graphics window or browser. If that entity has attributes associated with it, the “Find Object in Dialog” option will be shown in the context menu, as illustrated below. Selecting that option will select the entity in the dialog, allowing you to easily find it.

Context

When you run the Nifty Attributes command, it displays all the attributes in the active document. For example, if you run it with an assembly open, it will display the attributes that exist directly in the assembly. It will not display attributes that might exist in any of the sub-assemblies or parts that are in the assembly.  To see the attributes that exist in those documents, you can in-place activate the part or assembly so it’s the active document and then run Nifty Attributes again.  Nifty Attributes takes into account the activated document and will display the attributes that exist in the active part or assembly.

If the top-level assembly is active and you select an entity that is in a sub-assembly.  For example, you select a face of a part and add an attribute, that attribute will be on the proxy of the face and will only exist in the top-level assembly. The ability to add attributes to proxies or the native object is powerful, but you need to be aware of which document is active is when you create attributes because that’s where the attribute information will be saved.

Copying Attributes

You can copy an attribute set from one entity to another. To do this, run the Nifty Attributes command and find the attribute set you want to copy.  Right-click on the attribute set node and select the “Copy attribute set” option in the context menu.  Next, select and right-click on the entity you want to copy the attribute set to and select the “Paste Attribute Set” command as shown in the picture below, on the right.  This will copy the attribute set and all of its attributes to the new entity.  The attribute set and the attributes are new and independent of the original attribute set.  You can now modify the copied attribute set in any way without affecting the original attribute set.

Other Features

The buttons along the bottom of the Nifty Attributes dialog will expand or collapse all of the nodes in the tree.  The help button will display a PDF file with the same content as this page.  The last icon will open a web browser to a PayPal donation page.  Nifty Attributes is a completely free program to use.  However, if you find it useful and it saves you a lot of time and headache I would appreciate a little donation to partially cover the work that goes into it.

The program is compatible with Inventor 2016 and later.

To download the installer, click the button below.