Quantcast
Channel: mel wiki
Viewing all articles
Browse latest Browse all 610

How can I extract the vertex id number from its name?

$
0
0
When you query the selection of vert via ls(), it will give you back data like so: pPlane1.vtx[60].
How can you get just the vert id number 60 from that string? Python's re module makes this pretty easy:
# Python code
import re

myStr = 'pPlane1.vtx[60]'
pattern = r'\d+'
# This will return a list ["1", "60"], so grab the last item, & turn it into an int:
vid = int(re.findall(pattern, myStr)[-1])
# 60

Viewing all articles
Browse latest Browse all 610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>