- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here's what I am trying to do.
I will open the part and run a rule
Save a copy of the part to a temp location
Alter some parameters on this part
Save it to it's final location
Close the temporary part window.
I can do all these things, but the issue is that I do not know how to change the parameter in the temp part, it is changing the parameters in the part that the rule is running in.
w is the parameter I am trying to change.
TempFile="C:\Users\***\Target\temp_part.ipt"
TargetFile="C:\Users\***\Target\New file.ipt"
ThisDoc.Document.SaveAs(TempFile , True)
Temp2=ThisApplication.Documents.Open(TempFile)
w = InputBox("Width", "Size", "10")
InventorVb.DocumentUpdate()
Temp2.SaveAs(TargetFile, True)
Temp2.Close
All the forum posts I could find related to the part being in an assembly which is not how I am doing this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
parameters and properties allow you to specify the file as well as the parameter/property name in an overloaded option. This means you can force the active (or choice) file into the parameter call instead of the 'current' file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hoping that below iLogic code may helpful.
TempFile="C:\Users\***\Target\temp_part.ipt"
TargetFile="C:\Users\***\Target\New file.ipt"
ThisDoc.Document.SaveAs(TempFile, True)
Dim Temp2 As PartDocument
Temp2 = ThisApplication.Documents.Open(TempFile)
Dim oDef As PartComponentDefinition
oDef = Temp2.ComponentDefinition
oDef.Parameters.Item("w") = InputBox("Width", "Size", "10")
InventorVb.DocumentUpdate()
Temp2.SaveAs(TargetFile, True)
Temp2.Close
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Error on Line 12 : Property 'Item' is 'ReadOnly'.
Line 12 is
oDef.Parameters.Item("w") = InputBox("Width", "Size", "10")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can you please provide non confidential sample part to test? please mention the Inventor version as well.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Simply using a square block to test. Attached.
Inventor 2018
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try below iLogic code.
TempFile="C:\Users\***\Target\temp_part.ipt"
TargetFile="C:\Users\***\Target\New file.ipt"
ThisDoc.Document.SaveAs(TempFile, True)
Dim Temp2 As PartDocument
Temp2 = ThisApplication.Documents.Open(TempFile, True)
Dim oDef As PartComponentDefinition
oDef = Temp2.ComponentDefinition
oDef.Parameters.Item("w").Expression = InputBox("Width", "Size", "10")
Call Temp2.Update
Temp2.SaveAs(TargetFile, True)
Temp2.Close
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks, that works now but I don't understand why it works. Please can you have a look? I have commented out what I think is happening in each stage.
I also don't really understand what the command DIM does.
It's great getting help on the internet but if I don't understand it I will never learn to do it myself.
Thank you!
'location of temporary folder
TempFile="***\temp_part.ipt"
'Location of target folder
TargetFile="***\New file.ipt"
'Save a temporary file
ThisDoc.Document.SaveAs(TempFile, True)
'Declares Temp2 as a PartDocument variable?
Dim Temp2 As PartDocument
'Switches ilogic focus to the open temp file?
Temp2 = ThisApplication.Documents.Open(TempFile, True)
'Definies the temp part's parameters as a variable?
Dim oDef As PartComponentDefinition
'Switches iLogic focus to the temp parameters instead of where rule is running?
oDef = Temp2.ComponentDefinition
'Sets the temp part parameter from input box
oDef.Parameters.Item("w").Expression = InputBox("Width", "Size", "10")
'forces a rebuild?
Call Temp2.Update
'Saves temp file as new file in target location
Temp2.SaveAs(TargetFile, True)
'Close Temp file
Temp2.Close
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ThisDoc means always focus would be in a document where iLogic rule is running. To shift the focus to current document, Temp2 variable is defined. After that, parameters are accessed from componentdefinition.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
