I wrote a program several months ago that I was reminded of when writing the post about exporting an assembly structure to Excel. This program does somewhat the opposite. It creates an assembly based on the structure defined by an input file. All parts and subassemblies are created by the program and assembled as defined by the input file. The parts are empty parts created using the default template file. You can optionally specify iProperty values for each assembly and part. You can then create the geometry for each of the parts to complete the assembly.
I’m not sure how many people will find this useful but thought I would make it available in case it can benefit someone.
I chose to use XML as the way of defining the assembly structure since it provides a better way to define structure than Excel. However, it would be fairly easy to convert this to use Excel or to write an Excel macro that would write out an Excel sheet into the required XML format.
Using the Program
To use the program execute BuildAssemblyStructure.exe, (typically by double-clicking on the program in Explorer). The dialog below is displayed. In the top field specify the xml file that defines the structure of the assembly you want to create. The lower field defines the path where the parts and assemblies will be created. Once the two fields are defined, click the Create Assembly button to start the creation of the assembly. Inventor must already be running.
After the program has completed running the defined assembly will be open in Inventor. None of the files will have been saved to disk yet. Saving the assembly will prompt you to save all of the related files too. Closing the assembly without saving will result in no files being created.
XML Format
If you’ve never used XML before, don’t worry about having to learn a new complicated language. It’s an ASCII file with a .xml extension that you can create using Notepad or any other ASCII editor you’re familiar with and is just a standardized way of structuring data. Here’s a quick overview of XML.
An XML document contains one or more elements. Below is an example of an element.
This is some text within the ElementName element.
The element consists of two tags, an opening tag which is the element name conntained within the less than (<) and greater-than (>) signs and a closing tag which is the same except there is a forward slash (/) in front of the element name. All elements must have an opening and closing tag. A common mistake is to forget the closing tag.
Elements can also have attributes, as shown in the example below:
The attribute is specified within the opening tag and in his example is called “Filename”. It has a value of “Assembly.iam” which is contained within single or double quotes.
Elements can also be nested as in the example below.
<Assembly Filename=’SubAssembly.iam’>
</Assembly>
</Assembly>
The nesting is defined by the fact that the second Assembly element is within the first Assembly element. The indenting of the lines doesn’t define the nesting but makes it easier for humans to read and edit.
That’s about all you need to know about XML to create a file to use with this program. Here’s an example of the format expected by this program. It describes the structure of the XML to create parts and assembly and also define any iProperties.
Designer Spock DeliveryDate 12/18/08 Date Designer Capt. Kirk DeliveryDate 12/18/08 Date DeliveryDate 12/18/08 Date
The first line defines the opening tag of an Assembly element. This will be the top-level assembly document. There is a closing tag for the element at the bottom of the file.
The second line begins a Property element. This will define the values for any properties of the assembly. In this case there are two nested elements that will set the property called “Designer” to the value “Spock”. There is a closing tag for the property. Each property value defined is contained within its own Property element. This is demonstrated by the next set of lines that begins another Property element and sets the property named “DeliveryDate” to have a value of Dec. 18, 2008.
The second property, Delivery
Date, has a Type element whereas the first property does not. This is because the first property set, “Designer”, is a standard property and its type is defined by Inventor. The second property “DeliverDate” is not a standard property so the program will create a custom property for it and set its type to be whatever is specified by this element. If the custom property already exists, the type value is ignored and the value is set using the specified value. The names of the standard iProperties are listed below.
The next element is another Assembly element. This will result in the creation of a subassembly. Within this Assembly element there is a Property element that will set a property value for this subassembly. There is also a Part element that will create a part within this assembly. The part also has a Property element to set a property within it.
Finally, there is another Part element that defines a part within the top-level assembly. There is no limit to number of the parts or assemblies that can be defined or the number of levels of subassemblies.
Standard Properties
The following are the names and types of the standard iProperties that can be set. If you specify any other name besides these a custom property will be created.
Title, String
Subject, String
Author, String
Keywords, String
Comments, String
Revision Number, String
Category, String
Manager, String
Company, String
Creation Time, String
Part Number, String
Project, String
Cost Center, String
Checked By, String
Date Checked, String
Engr Approved By, String
Engr Date Approved, Date
User Status, String
Catalog Web Link, String
Description, String
Vendor, String
Mfg Approved By, String
Mfg Date Approved, Date
Cost, Currency
Designer, String
Engineer, String
Authority, String
Standard Revision, String
Stock Number, String
You can download the program and source code here. Feel free to use and modify it to fit your specific needs. It was written using Visual Basic 2008 Express and is compatible with Inventor 2009 and later.


Leave a Reply to Erwin LindeboomCancel reply