Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Document.SaveAs partnumber not updated

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
djreesing
583 Views, 5 Replies

Document.SaveAs partnumber not updated

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

5 REPLIES 5
Message 2 of 6
jdkriek
in reply to: djreesing

Did you search before posting? This topic as come up many times.

 

See topics like this one:

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 6
djreesing
in reply to: jdkriek

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

Message 4 of 6
jdkriek
in reply to: djreesing

You are absolutely correct - not logical, but perhaps necessary for the API.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 6
adam.nagy
in reply to: djreesing

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,



Adam Nagy
Autodesk Platform Services
Message 6 of 6
djreesing
in reply to: adam.nagy

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

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report