Tuesday, July 16, 2013

SaveAs through Inventor ilogic...

I use Inventor ilogic whenever possible, but one thing that has caused me problems is the fact that I couldn't save out a modified ilogic assembly without screwing up other drawings that were attached to that assembly...that is until now...
With the help from another blog; I was able to create a rule in ilogic that would perform a saveas off the assembly and then in turn would also run the rule under each part to create a brand new assembly and brand new parts within the assembly so that if you were to modify the main assembly this would not be affected by those changes.

Below is the code required for the saveas of an assembly:

'define the active document
oDoc = ThisDoc.Document
'create a file dialog box
Dim oFileDlg As inventor.FileDialog = Nothing

'check file type and set dialog filter
If oDoc.DocumentType = kPartDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
Else If oDoc.DocumentType = kAssemblyDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
Else If oDoc.DocumentType = kDrawingDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
End If

'set the directory to open the dialog at
oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
'set the file name string to use in the input box
oFileDlg.FileName = iProperties.Value("Project", "Project") & "_" & iProperties.Value("Summary", "Title")

'work with an error created by the user backing out of the save
oFileDlg.CancelError = True
On Error Resume Next
'specify the file dialog as a save dialog (rather than a open dialog)

'catch an empty string in the imput
If Err.Number <> 0 Then
MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
ElseIf oFileDlg.FileName <> "" Then
MyFile = oFileDlg.FileName
'save the file
oDoc.SaveAs(MyFile, True) 'True = Save As Copy & False = Save As
End If

Now in my example; I have created a custom naming convention of the assembly that is controlled by the Project value, and the Title value within the iproperties. (shown below)

oFileDlg.FileName = iProperties.Value("Project", "Project") & "_" & iProperties.Value("Summary", "Title")

Now, to cause the parents under the assembly to saveas with predetermined values run the part rule within the assembly. (shown below)

iLogicVb.RunRule("2x4tube_1:1", "saveas")

When you run the rule it will automatically open a SaveAs dialog box for the assembly and once you hit save it will start running the SaveAs dialog for all the parts in the assembly that you call for the "RunRule".

Monday, July 15, 2013

Using ilogic in Inventor to control beam sizes in an assembly

Today I want to give an example of iLogic and one of the many ways that it can make designing easier.
First, is controlling Beam or frame sizes with the click of a button.
Here we have a I-beam frame

In iLogic you can write code that will manipulate the beams to allow you to select different sizes as shown below:

Once programmed then you can go into your parameters and pulldown the list for your beam sizes.

and then once you select one it will automatically update your assembly.

This is a very basic use for iLogic...one of the things that i am working on for this assembly is coding to be able to define which wall a ladder assembly will be placed and then having supporting beam members that are able to move around in the assembly depending on which wall is selected for the ladder.
So, as stated before...there are so many possiblities when it comes to using Inventor iLogic in your design process.