Nicool
08-08-2004, 05:22 PM
Hi !
For my CGtalk buddies :twisted:
// connectEdge - By Nicolas d'Haussy
// Kind of bridge tool between two selected edges.
// Works from a feature of polyAppend fucntion.
// Retruns the object name from a string like : "pCube1.e[11]"
proc string componentStringToObjectName(string $componentString) {
string $buffer[];
tokenize($componentString, ".", $buffer);
return $buffer[0];
}
// Returns the number of the component (whatever it is) from a string (like : "pCube1.e[11]")
proc int componentStringToNumber(string $componentString) {
string $buffer[];
tokenize($componentString, ".", $buffer);
tokenize($buffer[1], "[", $buffer);
int $componentNumber = `match "[0-9]+" $buffer[1]`;
return $componentNumber;
// preg_match (/(.+?)\.[a-z]\[(\d+)\]/, $str, $ra) from php IRC help
}
// Edge connection procedure here
string $sel[] = `ls -sl`;
// Check if the selection is made of edges
if (size(`filterExpand -sm 32`) != 2) {
error("You must select two polygonal edges to connect them.\n");
}
// Check if the edges are from the same mesh
if ((componentStringToObjectName($sel[0])) != (componentStringToObjectName($sel[1]))) {
error("The two selected edges must come from the same polygonal mesh to be connected.\n");
}
polyAppend -ed (componentStringToNumber($sel[0])) -ed (componentStringToNumber($sel[1])) (componentStringToObjectName($sel[0]));
print($sel[0] + " connected to " + $sel[1] + ".\n");
For my CGtalk buddies :twisted:
// connectEdge - By Nicolas d'Haussy
// Kind of bridge tool between two selected edges.
// Works from a feature of polyAppend fucntion.
// Retruns the object name from a string like : "pCube1.e[11]"
proc string componentStringToObjectName(string $componentString) {
string $buffer[];
tokenize($componentString, ".", $buffer);
return $buffer[0];
}
// Returns the number of the component (whatever it is) from a string (like : "pCube1.e[11]")
proc int componentStringToNumber(string $componentString) {
string $buffer[];
tokenize($componentString, ".", $buffer);
tokenize($buffer[1], "[", $buffer);
int $componentNumber = `match "[0-9]+" $buffer[1]`;
return $componentNumber;
// preg_match (/(.+?)\.[a-z]\[(\d+)\]/, $str, $ra) from php IRC help
}
// Edge connection procedure here
string $sel[] = `ls -sl`;
// Check if the selection is made of edges
if (size(`filterExpand -sm 32`) != 2) {
error("You must select two polygonal edges to connect them.\n");
}
// Check if the edges are from the same mesh
if ((componentStringToObjectName($sel[0])) != (componentStringToObjectName($sel[1]))) {
error("The two selected edges must come from the same polygonal mesh to be connected.\n");
}
polyAppend -ed (componentStringToNumber($sel[0])) -ed (componentStringToNumber($sel[1])) (componentStringToObjectName($sel[0]));
print($sel[0] + " connected to " + $sel[1] + ".\n");
