Jump to content
davidyannick

Python du vex string manipulation

Recommended Posts

I'm trying tto convert a python scipt to vex, is there a VEX equivalent to rfind (python) ?

 

node = hou.pwd()
geo = node.geometry()

for prim in geo.prims():
    path=prim.attribValue("name")
    newpath=path[:path.rfind("/")]
    prim.setAttribValue("name",newpath)

Thanks

Share this post


Link to post
Share on other sites

Bonjour David,

A quick Google Search gives this as the first result → find

This gives the first occurrence instead of the last one. To find the last one, I would invert the string temporarily.

Although it looks like you are trying to split a path to get the name of the file (or the last folder)
There is the splitpath function that does just that.

Hope that helps !

Share this post


Link to post
Share on other sites
17 hours ago, Alain2131 said:

Bonjour David,

A quick Google Search gives this as the first result → find

This gives the first occurrence instead of the last one. To find the last one, I would invert the string temporarily.

Although it looks like you are trying to split a path to get the name of the file (or the last folder)
There is the splitpath function that does just that.

Hope that helps !

thanks it helps me a lot,  I'm a complet noob in Python sorry

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×