Shorten filename and path

Shorten filename and path

Anonymous
Not applicable
1,515 Views
7 Replies
Message 1 of 8

Shorten filename and path

Anonymous
Not applicable

I'm using the "file name and path" from the drawing properties on our borders.

Is there a way i can shorten it so it misses the "C:Vault Workspace\Projects\" from the path?

0 Likes
Accepted solutions (1)
1,516 Views
7 Replies
Replies (7)
Message 2 of 8

Owner2229
Advisor
Advisor

Hi, try something like this:

 

Dim FileName As String
FileName = "C:\Vault Workspace\Projects\MyPart.ipt" 'write the specific iProperty code here
Dim FNP As Integer
FNP = InstrRev(FileName, "\", -1)
Dim oName As String
oName = Mid(FileName, FNP + 1)

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 8

Anonymous
Not applicable

So this needs to written as a rule, and then it will update <FILENAME AND PATH> that i have in a text box?

0 Likes
Message 4 of 8

MechMachineMan
Advisor
Advisor

Yes, one of the easier ways is definitely to have it as a property in the file at whatever level you want it to come from.

 

Alternative code for if you just want the file name is:

 

oName = System.IO.Path.GetFileName(ThisApplication.ActiveDocument.FullFileName)

 

or to only remove a starting section of the file path:

 

path = "C:\Users\Desktop\Excel Use.txt"
npath = path.Replace("C:\Users", "")
MsgBox(npath)

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 8

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Wane,

here attached you can find a sample of what MechMachine was saying.

 

My sample contain a short Ilogic rule, event trigger ("Before save"), one personalized Iproperty (as one of many options) and a modified definition of the titleblock.

 

The drawing was created with the release 2016.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 6 of 8

Anonymous
Not applicable
Thanks every one, this example .idw is spot on!
0 Likes
Message 7 of 8

mguman
Advocate
Advocate

I have done it for one drawing now but will this work with other unmodified drawings? I have multiple drawings where I have this same issue that needs to be changed. Will I have to add an iLogic rule and personalized iProperty for each drawing that needs the change? 

0 Likes
Message 8 of 8

rossano_praderi
Collaborator
Collaborator

Hi @mguman

I'm not sure if I clearly understand all your requirements, I will suppose the answer to your question is "YES", you have to apply "this solution" to all of your files.

 

If you have to apply "this solution" to all your files, I would like to suggest you this post.

 

Otherwise I recommend you to open a new request with more details.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes