Save as of a part

Save as of a part

blandb
Mentor Mentor
559 Views
5 Replies
Message 1 of 6

Save as of a part

blandb
Mentor
Mentor

I must be over simplifying this, but if I have a part that a user can open to start with, then input a desired name in the part number property, fill out the sizes they want, and then hit the button to copy part which then launches the following rule, but doesnt seem to work.

 

ThisDoc.Document.SaveAs("C:\......\" & iProperties.Value("Project", "Part Number") & ".ipt", False)

 

My hopes with this was that when I copy, it does a save as, and the new part name is the desired name and it is an independent copy... Any thoughts?

Autodesk Certified Professional
0 Likes
Accepted solutions (1)
560 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Before you work on saving the part you will need to configure where you want to save the file. 

If your looking to save the part in the same folder as the current part you can use the ilogic snippet “ThisDoc.Path”

I would suggest use a variable to write  the whole file path so you can check if the file path is correct via a message box before attempting a save.

 

oFullFileName =ThisDoc.Path & ”\” & “NewName” & “.ipt”

 

 

If you need to pick a folder where to save files to target another specific folder you can use the inventor dialogue (the API help has this sample) or you can use the system.IO to retrieve retrieve folder/file information from windows. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 6

BrianEkins
Mentor
Mentor
Accepted solution

The last argument of the SaveAs method specifies if you want to do a SaveAs or SaveCopyAs.  In your sample code, you have this set to False which will do a SaveAs, which means the file is saved the specified file and the open file is now that file.  If you change that argument to True, it will save the document to the new file but you'll still be editing the original file, which it sounds like that is what you want.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 6

CattabianiI
Collaborator
Collaborator

I don't get the workflow here: "hit the button to copy part which then launches the following rule", where is the rule? is an external rule?

Anyway maybe the document wasn't a part? you could replace ".ipt" with a more general: IO.Path.GetExtension(ThisApplication.ActiveDocument.FullFileName)

Message 5 of 6

blandb
Mentor
Mentor

I was just trying to play around with having a template part a user could open up. So this rule just existed in the part, not external yet.

 

The idea was to have this template part that has a form that launches, and then they could manipulate whatever dims necessary and fill out what the part is going to be named such as 12345, customer info, etc, then at the bottom of the form, click the save as button. This would then save the part as its own independent file with the name 12345.ipt and save it in a specific directory. Also, if the file existed, could prompt file exists, or inv would state, do you want to overwrite and existing file.

 

Once the save as was complete, user could generate another, or just close the template without saving.

Autodesk Certified Professional
0 Likes
Message 6 of 6

blandb
Mentor
Mentor

This appears to accomplish what I was looking for, thanks!

Autodesk Certified Professional
0 Likes