Submitted by Stanvdm on Tue, 09/23/2014 - 22:40
Forums:
Hi All,
I am trying to save an existing part As another name. The idea is to change the parts name or to rename the part. I found this;
Dim instance As Part
Dim pathName As String
Dim returnValue As PartSaveStatus
returnValue = instance.SaveAs(pathName)
This only lets you save the part in another folder, as opposed to letting you change the filename. Has anyone had any idea what else I can do to do this task? I don't find a rename option there either.
re: save as
You can use the OS file handling functions to rename a given file. However, doing so will break any references to the file (assembly references, interpart references, wave links, etc). A better way would be to open the part along with any parts that depend on it and performing a Save-As to your desired new name. After the Save-As is complete, you can delete the original file (don't forget to save the parts that reference the newly renamed part).
Save As
Hi,
thanks for the answer, however the question is using snap - the function does not allow for changing the file name only the path name. This is actually what I need to know. Is there a real way using the SNAP programming tool to do a true renaming or save as while keeping all references to the assembly and other links of the software?
Thanks in advance,
StanV
SNAP SaveAs
The input the the SNAP SaveAs function is the full pathname of the new file. This pathname includes the file name. So, you should be able to write something like
myPart.SaveAs("C:\parts\newPart.prt")
Doesn't that work?