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: 

Ilogic move and rename parts

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
phillip.shields
1811 Views, 5 Replies

Ilogic move and rename parts

I have a part file XXXXYYYY.ipt and I would like an ilogic code that searches if my file name contains "XXXXYYYY" to replace the X's and Y's with 1244SIMS and moves that file to a specified folder. Is there any code out there that will allow me to do this?
5 REPLIES 5
Message 2 of 6

You may consider the huge set of methods in the .NET String class to change filename.

Look at these links:

String Class
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.aspx?cs-save-lang=1&cs-lang=vb...

Strings in Visual Basic
http://msdn.microsoft.com/en-us/library/hzcd8ze0.aspx

 

You may use
ThisDoc.Document.SaveAs(NewFileNameAndExtension , SaveCopyAs)
method to save the file with another filename.

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 6

Thanks for the quick reply and info. Now, that I have a basic understanding of strings how do I tell my renamed file what path to take? I want my renamed file to save to a certain directory.

Message 4 of 6

Assume
1) the new filename is MyNewFile.ipt
2) you want to save your renamed file to the existing folder   d:\AAA\BBB\CCC\DDD

then your rule could be similar to the following:

'new filename
dim Filename as string = "MyNewFile.ipt"
'target folder path
dim DirName as string = "d:\AAA\BBB\CCC\DDD"
'now you may create the full filename
dim FullFilename as string = DirName & "\" & Filename
'save file
ThisDoc.Document.SaveAs(FullFilename , False)

See also System.IO.Path class details.
Very useful if you need to perform operations on strings that contain file or directory path information.

http://msdn.microsoft.com/en-us/library/system.io.path.aspx


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

Thanks that worked but how do I delete the old folder once my file has been moved?

Message 6 of 6

My advice - use .NET System.IO namespace objects.

In this particular case - Directory.Delete(...) method
http://msdn.microsoft.com/en-us/library/system.io.aspx

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report