i want it to find the project folder and the project name, so i tell it to find the constant value (427, our office number)
but for some strange reason InStr and InStrRev both return the same number rather than reversing the search direction. what's wrong with my code?
'dims oPath = ThisDoc.Path 'get base project folder placement oGet01 = InStr(oPath, "427")-1 oSet01 = Left(oPath, oGet01) 'get project name oGet02 = InStrRev(oPath, "427")-1 oSet02 = Right(oPath, oGet02) oGet03 = InStr(oSet02, "\") oSet03 = Left(oSet02, oGet03) MessageBox.Show("Get1: " & oGet01 & vbCrLf & "Set1: " & oSet01 & vbCrLf & "Get2: " & oGet02 & vbCrLf & "Set2: " & oSet02 & vbCrLf & "Get3: " & oGet03 & vbCrLf & "Set3: " & oSet03)
Are you using iLogic or VBA? Similar code exists in both environments, but they're not exactly the same.
See these links:
VB.NET versions
Strings.InStrRev(String, String, Int32, CompareMethod) Method
VBA versions
Wesley Crihfield
(Not an Autodesk Employee)
Hi @cbn56B4Z
Is the document you're running the rule in saved? Otherwise ThisDoc.Path will return an empty string..
Have you tried using the DesignProjectManager object?
Something like this maybe?
Dim oActiveProject As DesignProject = ThisApplication.DesignProjectManager.ActiveDesignProject MsgBox("Workspacepath: " & oActiveProject.WorkspacePath & vbCrLf _ & "Project name: " & oActiveProject.Name)
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
@WCrihfield i'm using ilogic
@JhoelForshav sorry for the misunderstanding, but when i said project i did not literally mean project file, we run a single project folder via Vault, that project is split into years and then split into each "collection" i will call it instead, i need to get this "collection" number, not the project.
@WCrihfield i managed it wouthout InStrRev. using Mid instead
skimming the two InStrRev in iLogic
InstrRev(stringcheck, stringmatch, [ start, [ compare ]])
InStr([ start ], string1, string2, [ compare ])
they are basically the same, but they moved the [ start ] value.
if anybody knows of a reverse string search do tell.
anyways, here's my ugly solution for anybody who cares:
'dims oPath = ThisDoc.Path 'get base project folder placement oGet01 = InStr(oPath, "427")-1 oSet01 = Left(oPath, oGet01) 'get project name oGet02 = InStr(oGet01 + 1, oPath, "\")-1 oSet02 = Left(oPath, oGet02) oGet03 = InStrRev(oSet02, "\") oSet03 = mid(oSet02, oGet03+1) MessageBox.Show("Get1: " & oGet01 & vbCrLf & "Set1: " & oSet01 & vbCrLf & "Get2: " & oGet02 & vbCrLf & "Set2: " & oSet02 & vbCrLf & "Get3: " & oGet03 & vbCrLf & "Set3: " & oSet03)
Can't find what you're looking for? Ask the community or share your knowledge.