Hello,
I previously posted this in the general section, but was refered here, so sorry for the double post.
---
I'm looking for a way to reference a folder name that contains my part / assembly. I want to use that folder name in the title block of my drawing.
For Example:
server\drawings\customer 1\machineA\replacement part01.ipt
server\drawings\customer 2\machine04\replacement assembly.iam
I want to be able to 'extract' the customer 1 or customer 2 name from the file path.
I've searched around for awhile now, but I can't find a solution.
I'm new to using iLogic and coding, but I've stumbled through this bit of code:
'My Ilogic Dim Flp As String 'Set Flp to file path Flp = ThisDoc.Path 'set iproperties for Company--- iProperties.Value("Summary", "Company")= Flp
It gets the file path and sets that equal to the iProperty-Company. Is there some way I can only take part of the filename string?
Thanks for your help,
-Ryan
Solved! Go to Solution.
Solved by Ktomberlin. Go to Solution.
"server\drawings\customer 1\machineA\replacement part01.ipt"
You can do something like.
Flpath=(Mid(ThisDoc.WorkspacePath(),16))
Flpdir="\"
Folderpos=InStr(Flpath, Flpdir)
oFolder=Folderpos-1
Flp=(Left(Flpath,oFolder))
The first line should get rid of the "server\drawings\" Then you can find the position of the next "\". then use that to get the customer only.
Dim Flp As String
Dim Flpdir As String
'Set Flp To file path
Flp = ThisDoc.Path
'removes server name and drawings directory
Flpath=(Mid(Flp,13))
'Flpath=(Mid(ThisDoc.WorkspacePath(),16))
Flpdir="\"
Folderpos=InStr(Flpath, Flpdir)
oFolder=Folderpos-1
'original: oFolder=Folderpos-1
Flp=(Left(Flpath,oFolder))
'set iproperties for Company---
iProperties.Value("Summary", "Company")= Flp
iLogicVb.UpdateWhenDone = True
I had to modify it a bit because I kept getting the error that length couldn't equal zero. I think it was because I said that my structure was:
server\drawings\customer 1 when it's really Z:\drawings\customer1\...
Thank you
Sure that path difference would cause that issue. If this is working for you great. Your using "Flp = ThisDoc.Path" I would think ThisDoc.WorkspacePath would give a better result.