Hi,
When you do a Save As or Save Copy As in Inventor the part number in the iProperties is automatically updated to match the new filename. I would expect the Document.SaveAs method in the API to act in a similar way. However I found out that this is not the case.
SaveAs: Document.SaveAs(filename, False) does not update the part number. The new part will still have the same part number as the original part. This can give problems since in the BOM parts with the same part number are interpreted as the same physical part.
SaveCopyAs: Document.SaveAs(filename, True) does work as expected and the part number will update correctly.
Is this a bug in the API? or is there a reasonable explanation for this?
Best regards, Daniël
---
Inventor 2013 SP2
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Did you search before posting? This topic as come up many times.
See topics like this one:
Yes I did search an actually found the post you've linked. However there's no real solution in it, only a workaround to fix the part number after the part is copied. I find it strange that the API SaveAs doesn't work the same at the 'normal' Save As. Since the other post is from over 2 years ago and the 'problem' is still there it's probably not a bug. But what is the reason Autodesk designed it this way? I doesn't seem logical to me.
Daniël
Hi,
I've accidentally answered in the linked thread, but here is the same:
>>>>>
Maybe I'm misunderstanding something, but when I checked in Inventor 2014 the part got the correct part number when saved for the very first time - this is when you should use SaveCopyAs = False
Sub CreateNewPartAndSave() Dim doc As PartDocument Set doc = ThisApplication.Documents.Add(kPartDocumentObject) ' I can use false here since I'm saving a part that ' has never been saved before Call doc.SaveAs("C:\NewPart.ipt", False) ' The Part Number is the same as the filename I passed to SaveAs MsgBox (doc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").value) End Sub
Some info on SaveCopyAs: http://adndevblog.typepad.com/manufacturing/2012/12/saveas-with-savecopyas-false.html
<<<<<
Cheers,
I understand now that I only should use SaveCopyAs=false when I'm saving a part that has not been saved before. If you use SaveCopyAs=false on an existing part, the part number won't update (when saving to a different filename). So SaveCopyAs=false should only be used on a new part. SaveCopyAs=true does update the part number and should be used on an existing part.
This is confusing since in the Inventor UI both Save As and Save Copy As will save to a different filename and update the part number. So SaveAs in the API is not the same as Save As in the UI. That's why I (any many other people) thought there was a problem.
But all is clear now.
Thanks, Daniël