XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

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

01-18-2008, 09:29 PM

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

Thanks in advance.

01-19-2008, 12:27 AM
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-19-2008, 12:27 AM
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.