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 VBA InStrRev not reversing

4 REPLIES 4
Reply
Message 1 of 5
cbn56B4Z
604 Views, 4 Replies

ilogic VBA InStrRev not reversing

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)

 

Labels (6)
4 REPLIES 4
Message 2 of 5
WCrihfield
in reply to: cbn56B4Z

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.InStr Method 

Strings.InStrRev(String, String, Int32, CompareMethod) Method 

VBA versions

InStr function 

InStrRev function 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5
JhoelForshav
in reply to: cbn56B4Z

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)
Message 4 of 5
cbn56B4Z
in reply to: WCrihfield

@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.

Message 5 of 5
cbn56B4Z
in reply to: WCrihfield

@WCrihfield i managed it wouthout InStrRev. using Mid instead

skimming the two InStrRev in iLogic 

InstrRev(stringcheck, stringmatch, [ start, [ compare ]])

InStr([ start ], string1string2, [ 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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report