iLogic to return specific folder in a path

iLogic to return specific folder in a path

YannickEnrico
Advisor Advisor
2,221 Views
2 Replies
Message 1 of 3

iLogic to return specific folder in a path

YannickEnrico
Advisor
Advisor

Hi there.

 

I would like to know if there is a way to make iLogic return say folder no. 4 of a file that is 6 folders down in the tree?

 

Currently I'm using folderpath, but that returns the folder of the file. 

 

My folder tree works like this:

C:/WF/Designs/CUSTOMER/ORDERNO/FRAMEGENERATOR/FRAME

I would like to return Customer and Orderno and write it to a custom iProperty. 

 

With my current setup, it naturally returns FRAMEGENERATOR and FRAME for frame generator parts



I know what isn't possible:

It isn't possible to cover everything by no. of characters from the start
It isn't possible to cover everything by no. of characters from the end.

It isn't possible to cover everything by parent folders, since frame parts won't return the proper names, then. 


 

_______________________________________________________________________________________
Intel Core i9-14900KF
64 GB DDR5 6000 MHz
2TB WD_BLACK
RTX A4000
------------------------------
Inventor 2026 Professional
0 Likes
Accepted solutions (1)
2,222 Views
2 Replies
Replies (2)
Message 2 of 3

YannickEnrico
Advisor
Advisor
Accepted solution

It would appear I figured it out. 

 

Thanks anyhow!

 

'get filepath
filePath = ThisDoc.Path
'separate into array by directory separator
filePathArray = Split(filePath, System.IO.Path.DirectorySeparatorChar)

'C=0, WF=1, Designs=2, Customer=3, OrderNo=4
filePathOrderNo = filePathArray(4)
filePathCustomer = filePathArray(3)

iProperties.Value("Custom", "Ordrenummer")=filePathOrderNo
iProperties.Value("Project", "Project")=filePathCustomer
_______________________________________________________________________________________
Intel Core i9-14900KF
64 GB DDR5 6000 MHz
2TB WD_BLACK
RTX A4000
------------------------------
Inventor 2026 Professional
0 Likes
Message 3 of 3

JelteDeJong
Mentor
Mentor

the following code splits the folderpath in sepparated strings. From there you can get the folder names that you need

 

'get the full file name of the this document
Dim folderpath As String = ThisDoc.PathAndFileName(False)

'split the "full file name" in folder foldernames
Dim folders As String() = folderpath.split("\")

'get the data you are looking for.
'Pay attension that ilogic start counting by 0
'C:/WF/Designs/CUSTOMER/ORDERNO/FRAMEGENERATOR/FRAME
'0  1    2        3        4          5          6
Dim Customer As String = folders(3)
Dim Orderno As String = folders(4)

iProperties.Value("Project", "Description") = Customer + " - " + Orderno

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com