Wednesday, July 25, 2012

Autodesk Inventor Template for Shapeways

So, if your not familiar with Shapeways. They are a 3D printing company.
Most of their available materials are priced by volume in cm^3. Except ceramics, ceramics are by surface area in cm^2. Since Inventor keeps track of these two properties (volume and area). We can leverage them to get an estimated cost of our model without having to upload it to shapeways for a quote.

For the purposes of this tutorial, i'm going to assume we are not using Vault.

So, assuming you're not using Vault, It's essentially three steps.

1) Create or open a template file.
2) Create a rule to set the iproperties
3) Define triggers to run that rule when a particular event occurs..


Step 1... Create or Edit a Template
Creating a template file is easy. Just make a new file, do whatever you need to do (Step 2 & 3), and then save it to your templates directory. But, not just yet. leave it open for now. If you don't know where the templates directory is, just run a search on your hard drive for one of the template file names, like "Standard (in).ipt".
Editing your existing templates can be more difficult. In order to edit a template, you need to set your project "workspace" or working directory to the templates folder. If you are going to edit your templates, i suggest making a project file specifically for this purpose so that you don't acidentally destroy your existing templates thinking. If you're not familiar with creating projects watch this video. If you're going to use inventor you're going to want to know what projects are and how to work with them.

Anyway, now that you have your template editing project set up, open up the template file you want to add this functionality to. probably the standard part and standard assembly templates.
I'll be editing my "Standard (in).ipt" file.

Step 2... Add a Rule
Whatever path you took in Step 1, you should have a file open read to by edited.
If not, something went wrong, and you may want to jump back up and re-read Step 1 .
So, we're going to be using ilogic rules to populate some custom iproperties. What we need to do is add a new iLogic rule. So, in the ribbon menu, hop on over to the "Manage" tab and choose "Add Rule".

iLogic - Add Rule


Enter a name for the new rule in the dialog, and click okay. (I named mine "CalcCost").

For the actual logic of the rule, copy and paste the code below into the editor window and hit okay.
IMPORTANT! If you're NOT using the standard inch template, the two lines below in bold may require modification. The end goal here is that variables cmvol and cmarea hold the value in cm's.
If you're base unit is something other than inches, you will need to adjust the forumula for the proper conversion to take place. Maybe some day soon i'll update this to auto detect the base unit and adjust accordingly, but for now, just be careful and adjust accordingly.

Dim cmvol As Double 
Dim cmarea As Double 

cmvol = iProperties.Volume * 16.387064
cmarea = iProperties.Area * 6.5416

iProperties.Value("Custom", "CeramicWhite") = (cmarea * .18) 
iProperties.Value("Custom", "CeramicBlack") = (cmarea * .19) 
iProperties.Value("Custom", "CeramicColor") = (cmarea * .20) 

iProperties.Value("Custom", "WSF")         = (cmvol * 1.40) + 1.50 
iProperties.Value("Custom", "WSFPolished") = (cmvol * 1.75) + 1.50 

iProperties.Value("Custom", "Stainless")       = (cmvol * 8.00) + 6.00 
iProperties.Value("Custom", "StainlessBronze") = (cmvol * 8.00) + 7.50 
iProperties.Value("Custom", "StainlessGold")   = (cmvol * 8.00) + 9.00

iProperties.Value("Custom", "Silver")         = (cmvol * 20.00) + 30.00 
iProperties.Value("Custom", "SilverPolished") = (cmvol * 20.00) + 35.00 

iProperties.Value("Custom", "BlackElastomer") = (cmvol * 2.00) + 3.00

If everything went according to plan, there was no error message, and we are ready for the next step.



Step 3...Set your Triggers
This is the last and arguably the easiest step.
An event trigger is just a way of associating our rule with some mundane action that we perform so that our rule runs without us having to run it manually. For example, if we want it to run every time we save the document we link the "Document Save" Trigger to our new rule. Now every time we save our document our Shapeways estimate is updated. So, without any further delay, click "Event Triggers" (it should be next to "Add Rule" which you clicked earlier.). What you're presented with is a list of events to choose from.

iLogic - Event Triggers
Highlight and event in the list, and click the "Select Rules..." button at the lower left of the dialog.
Check off the new rule you just created and hit okay. Repeat that for any of the other events listed, and you're rule will run any time that event occurs. Time to Save the template, because we're all done.


Now, go right click on your part in the browser and check out your new custom iproperties!!


I hope you enjoyed this and will find it useful.
I know i do (find it useful)!!
Oh btw, check out my Shapeways store!


No comments:

Post a Comment