Changing file name of a open file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I was wondering if there is a way to change a name of open file?
Lets say i have an assembly and it consists of part 1 and part 2.
I have a rule that makes a new file from a part , copying it and changing its name using custom iproperty.
But what i get is 2 files - part2.ipt and custom.ipt, and assembly is still using part 2 and not custom.ipt.
Is there a way to change the name of an open file? Or i can only use save file as with a new name?
Code i am using:
customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Dim Nr_fasady As String Dim Nr_elementu As String Dim Nr_katalogowy As String Dim Długość As String Dim Kolor As String question = MessageBox.Show("Czy zapisywany plik to część?" & vbLf & "Wybierz Tak dla części oraz Nie dla złożenia", "Rodzaj pliku", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If question = vbYes Then Nr_fasady = InputBox("Proszę wpisać Nr fasady:", "Potrzebne informacje", "") Nr_elementu = InputBox("Proszę wpisać Nr elementu:", "Potrzebne informacje", "") Kolor = InputBox("Proszę wpisać kolor elementu:", "Potrzebne informacje", "") Dim iprop(2) As String iprop(1) = "Kod elementu (Nr katalogowy)" iprop(2) = "Długość" For k = 1 To 2 Dim prop(k) As String Try prop(k) = iProperties.Value("Custom", iprop(k)) Catch 'Assume error means not found customPropertySet.Add("", iprop(k)) iProperties.Value("Custom", iprop(k)) = "null" End Try Next For j = 1 To 2 Dim var(j) As String If iProperties.Value("Custom", iprop(j)) = "null" Then question = MessageBox.Show("Wartość dla: " & iprop(j) & " Nie została określona, czy chcesz określić?", "IProperty nie określone", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If question = vbYes Then var(j) = InputBox("Proszę wpisać wartość dla: " & iprop(j), "Warning", "") iProperties.Value("Custom", iprop(j)) = var(j) End If Else var(j) = iProperties.Value("Custom", iprop(j)) End If Next Nr_katalogowy = iProperties.Value("Custom", iprop(1)) Długość = iProperties.Value("Custom", iprop(2)) Dim Name As String Name = ThisDoc.Path & "\" & Nr_fasady & "_" & Nr_elementu & "_" & Nr_katalogowy & "_" & Długość & "_" & Kolor & ".ipt" ThisDoc.Document.SaveAs(Name, True) End If If question = vbNo Then Nr_fasady = InputBox("Proszę wpisać Nr fasady:", "Potrzebne informacje", "") Nr_elementu = InputBox("Proszę wpisać Nr elementu:", "Potrzebne informacje", "") Dim Name As String Name = ThisDoc.Path & "\" & Nr_fasady & "_" & Nr_elementu & ".iam" ThisDoc.Document.SaveAs(Name, True) End If
Sorry if the code is messy but it is my first code that i have writen myself, important part is here:
Dim Name As String
Name = ThisDoc.Path & "\" & Nr_fasady & "_" & Nr_elementu & ".iam"
ThisDoc.Document.SaveAs(Name, True)
As you can see, name of the file is Nr_fasady and Nr_elementu, but it creates a new .iam or .ipt file ( depending on original file) and instead of that i would want it to change the name of the original file.