PDA

View Full Version : Change Polygon Component edge node name into int type number


sol3dartist
01-18-2008, 08:29 PM
Hi,

Is there anyway to get just "int" type number from the edge id number? For example "30" of pSphere1.e[30]

Thanks in advance.

GennadiyKorol
01-18-2008, 11:27 PM
You have couple of ways:

Using string matching:


string $name = "pSphere1.e[034]";
string $tmp = `match "\\[[0-9]+\\]" $name`;
int $l = `size $tmp`;
int $id = `substring $tmp (2) ($l-1)`;



Using substring only, if you know the name of the object:


string $objectName = "pSphere1.e";
string $name = "pSphere1.e[034]";
int $a= `size $objectName`;
int $b = `size $name`;
int $id = `substring $name ($a+2) ($b-1)`;



Using tokenize:

string $name = "pSphere1.e[034]";
string $tokens[];
tokenize $name "[" $tokens;
int $l = `size $tokens[1]`;
int $id = `substring $tokens[1] (1) ($l-1)`;



Depending on what exactly you're doing you might have to tweak those a bit.
Your mileage may vary :)

CGTalk Moderation
01-18-2008, 11:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.