updating and saving a new part file with a assembly using iLogic

updating and saving a new part file with a assembly using iLogic

Anonymous
Not applicable
821 Views
1 Reply
Message 1 of 2

updating and saving a new part file with a assembly using iLogic

Anonymous
Not applicable

I have previously gotten this to work but my computer fried before I got it to an external hard drive and cant remember how I previously did it. 

 

Am trying to update and save as a part file within an assembly using iLogic rules. Here is what I have.

Assembly Code

length = 15
width = 12
thickness = 3

Dim map As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
map.Add("Arg1", length)
map.Add("Arg2", width)
map.Add("Arg3", thickness)
iLogicVb.RunRule("Part1.ipt","Rule0", map)

Part Code

'The following Code was written to generate Custom and Standards size refractory bricks from the users input
LENGTH = RuleArguments("Arg1")
WIDTH = RuleArguments("Arg2")
THICKNESS = RuleArguments("Arg3")
MATERIAL = RuleArguments("Arg4")


'iProperties.Material=Material
If CUT = False Then
iProperties.Value("Project", "Part Number") = "PAS " & MATERIAL & " - " & LENGTH & " x " & WIDTH & " x " & THICKNESS
iProperties.Value("Project", "Stock Number") = LENGTH & " x " & WIDTH & " x " & THICKNESS
iProperties.Value ("Summary", "Title") =  "PAS " & MATERIAL & " - " & LENGTH & " x " & WIDTH & " x " & THICKNESS & ".ipt"
ElseIf CUT = True Then
iProperties.Value("Project", "Part Number") = "PAS " & MATERIAL & " - " & LENGTH & " x " & WIDTH & " x " & THICKNESS & " CUT"
iProperties.Value("Project", "Stock Number") = "CUT AS REQUIRED"
iProperties.Value ("Summary", "Title") =  "PAS " & MATERIAL & " - " & LENGTH & " x " & WIDTH & " x " & THICKNESS & " CUT"
iLogicVb.UpdateWhenDone = True
End If

''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
oDoc = ThisDoc.Document
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'set the directory to open the dialog at
oFileDlg.InitialDirectory = "C:\Users\ronno\OneDrive\Documents\work\"
'set the file name string to use in the input box
oFileDlg.FileName = iProperties.Value("Summary", "Title")

'MyFile = oFileDlg.FileName
'oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As


'oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As
''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)
oFileDlg.ShowSave()


'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, False) 'True = Save As Copy & False = Save As
End If

'Return To parent In assembly
'ThisApplication.SilentOperation = True
'Dim oControlDef As ControlDefinition
'    ThisApplication.CommandManager.ControlDefinitions.Item("AppReturnParentCmd").Execute2 _
'               (True)
'               iLogicVb.UpdateWhenDone = True
              
'ThisApplication.SilentOperation 

 

its giving me an error of cant find part in the directory but there both saved in the same directory 

0 Likes
822 Views
1 Reply
Reply (1)
Message 2 of 2

Ralf_Krieg
Advisor
Advisor

Hello

 

1. You try to retrieve MATERIAL as argument 4, but don't define a fourth argument in your assembly rule.

2. Material is a type, so you can't define a variable with this name. Possible is for instance sMATERIAL.

Renaming MATERIAL to sMATERIAL and there's no other error message. Sure that you posted the right part of code? And what do you mean with "...both saved in ..."? Your Code only save's a copy of the part and replace it in the assembly.

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes