PDA

View Full Version : Help needed - lasercutting section script


frd
02-11-2008, 10:40 AM
...found a mel script that is supposed to generate sections for lasercutting from nurbs
I tried to run that one on maya 2008 and 8.5.
Nothing happened, not even an error message.

I would really appreciate if someone finds the time to take a look at the script
Thanks in advance

global proc string newModelx() {
$model = `group -em`;
setAttr "PlaneToolPaletteDatax.currentModel" -type "string" $model;
return $model;
}

global proc string newModelz() {
$model = `group -em`;
setAttr "PlaneToolPaletteDataz.currentModel" -type "string" $model;
return $model;
}

global proc deleteModelx () {
$model = `getAttr PlaneToolPaletteDatax.currentModel` ;
delete $model;
}

global proc deleteModelz () {
$model = `getAttr PlaneToolPaletteDataz.currentModel` ;
delete $model;
}


global proc planeWindow() {

$surface = `ls -sl`;


// Create a null to hold the data edited by the sliders
group -n PlaneToolPaletteDatax -em;
// The current model that the window is operating on
addAttr -ln currentModel -dt "string";

addAttr -ln mainModel -dt "string";
setAttr -type "string" PlaneToolPaletteDatax.mainModel $surface;

// model attributes
addAttr -ln numPlanesx -dv 1 -min 1 -max 30 -at double;
addAttr -ln spacingx -dv 1 -min 1 -max 30 -at double;
addAttr -ln hieghtx -dv 10 -min 1 -max 40 -at double;
addAttr -ln widthx -dv 20 -min 1 -max 200 -at double;

group -n PlaneToolPaletteDataz -em;
// The current model that the window is operating on
addAttr -ln currentModel -dt "string";

addAttr -ln numPlanesz -dv 1 -min 1 -max 30 -at double;
addAttr -ln spacingz -dv 1 -min 1 -max 30 -at double;
addAttr -ln hieghtz -dv 10 -min 1 -max 40 -at double;
addAttr -ln widthz -dv 40 -min 1 -max 200 -at double;

newModelx();
select -cl;

// start script jobs to call curveInterface automatically
scriptJob -attributeChange "PlaneToolPaletteDatax.numPlanesx" "planeInterfacex";
scriptJob -attributeChange "PlaneToolPaletteDatax.spacingx" "planeInterfacex";
scriptJob -attributeChange "PlaneToolPaletteDatax.hieghtx" "planeInterfacex";
scriptJob -attributeChange "PlaneToolPaletteDatax.widthx" "planeInterfacex";

newModelz();
select -cl;

scriptJob -attributeChange "PlaneToolPaletteDataz.numPlanesz" "planeInterfacez";
scriptJob -attributeChange "PlaneToolPaletteDataz.spacingz" "planeInterfacez";
scriptJob -attributeChange "PlaneToolPaletteDataz.hieghtz" "planeInterfacez";
scriptJob -attributeChange "PlaneToolPaletteDataz.widthz" "planeInterfacez";


// create the window
window -widthHeight 100 400 -title "Shape Tool Palette" PlaneToolPalette;
columnLayout -columnAttach "right" -10 -rowSpacing 10 -columnWidth 300;

attrFieldSliderGrp -min 1 -max 30.0 -at ("PlaneToolPaletteDatax.numPlanesx");
attrFieldSliderGrp -min 1 -max 30.0 -at ("PlaneToolPaletteDatax.spacingx");
attrFieldSliderGrp -min 1 -max 40.0 -at ("PlaneToolPaletteDatax.hieghtx");
attrFieldSliderGrp -min 1 -max 200 -at ("PlaneToolPaletteDatax.widthx");

attrFieldSliderGrp -min 1 -max 30.0 -at ("PlaneToolPaletteDataz.numPlanesz");
attrFieldSliderGrp -min 1 -max 30.0 -at ("PlaneToolPaletteDataz.spacingz");
attrFieldSliderGrp -min 1 -max 40.0 -at ("PlaneToolPaletteDataz.hieghtz");
attrFieldSliderGrp -min 1 -max 200.0 -at ("PlaneToolPaletteDataz.widthz");

button -label "Create Sections" -c "Sections";


showWindow PlaneToolPalette;
}



global proc planeInterfacez() {

$numPlanes = `getAttr PlaneToolPaletteDataz.numPlanesz`;
$spacing = `getAttr PlaneToolPaletteDataz.spacingz`;
$hieght = `getAttr PlaneToolPaletteDataz.hieghtz`;
$width = `getAttr PlaneToolPaletteDataz.widthz`;

$count=1;
$xmax = (($spacing*$numPlanes)/2);

deleteModelz();
$model = newModelz();


while ($count < $numPlanes){
$planeNum = $count;
$plane = makePlanez($planeNum,$spacing, $hieght, $width,$xmax);
parent $plane $model;
$count++;
}
}

global proc planeInterfacex() {

$numPlanes = `getAttr PlaneToolPaletteDatax.numPlanesx`;
$spacing = `getAttr PlaneToolPaletteDatax.spacingx`;
$hieght = `getAttr PlaneToolPaletteDatax.hieghtx`;
$width = `getAttr PlaneToolPaletteDatax.widthx`;

$count=1;
$xmax = (($spacing*$numPlanes)/2);

deleteModelx();
$model = newModelx();


while ($count < $numPlanes){
$planeNum = $count;
$plane = makePlanex($planeNum,$spacing, $hieght, $width,$xmax);
parent $plane $model;
$count++;
}
}

global proc string makePlanez(float $planeNum, float $spacing, float $hieght, float $width,float $xmax) {


$planeItems = `group -em`;
$plane = `nurbsPlane -n "cutterz"`;
$movex = ($xmax-($spacing*$planeNum));
rotate 0 90 0;
move 0 0 $movex;
scale 0 $hieght $width;
select $plane;
parent $plane $planeItems;
return $planeItems;
}

global proc string makePlanex(float $planeNum, float $spacing, float $hieght, float $width,float $xmax) {


$planeItems = `group -em`;
$plane = `nurbsPlane -n "cutterx"`;
$movex = ($xmax-($spacing*$planeNum));
rotate 0 0 0;
move $movex 0 0;
scale 0 $hieght $width;
select $plane;
parent $plane $planeItems;
return $planeItems;
}


global proc Sections() {




$surface = `getAttr PlaneToolPaletteDatax.mainModel`;

$sizex = `getAttr $surface.boundingBoxSizeX`;
$sizez = `getAttr $surface.boundingBoxSizeZ`;
$sizey = `getAttr $surface.boundingBoxSizeY`;

$spacingx = `getAttr PlaneToolPaletteDatax.spacingx`;
$spacingz = `getAttr PlaneToolPaletteDataz.spacingz`;

select "cutterx*";
$listx = `ls -sl -tr`;

select "cutterz*";
$listz = `ls -sl -tr`;

$group = `group -em`;
$i=0;
$up = 50;
$back = 0;
while($i < size($listx)){
$thing = `intersect $surface $listx[$i]`;

$curve = `duplicateCurve -ch 1 -rn 0 -local 0 $thing[0]`;
$count = 0;

select "cutterz*";
$listz = `ls -sl -tr`;

$spacingz = `getAttr PlaneToolPaletteDataz.spacingz`;
$notches[30] = 1;
while ($count < size($listz)){
$thing2 = `intersect $surface $listz[$count]`;

$curve2 = `duplicateCurve -ch 1 -rn 0 -local 0 $thing2[0]`;
string $node = `curveIntersect -useDirection true -direction 0 1 0 -ch on $curve[0] $curve2[0]`;
float $p1[] = `getAttr ($node + ".parameter1")`;
float $p2[] = `getAttr ($node + ".parameter2")`;

$notches[$count] = $p1[0];

delete $curve2;
delete $thing2;
$count++;
}
select $curve;
move $back $up 0;
$offsetmain = `offsetCurve -ch on -rn false -cb 2 -st true -cl true -cr 0 -d 1 -tol 0.01 -sd 5 -ugn false $curve[0]` ;
$ncount=0;
while ($ncount < size($listz)){
$nvector = `pointOnCurve -pr $notches[$ncount] -p $curve[0]`;
$line1 = `curve -d 1 -p $nvector[0] ($nvector[1]+.5) ($nvector[2]+.1) -p $nvector[0] ($nvector[1]-.5) ($nvector[2]+.1)`;
$line2 = `offsetCurve -ch on -rn false -cb 2 -st true -cl true -cr 0 -d .2 -tol 0.01 -sd 5 -ugn false $line1`;
$v1 = `pointOnCurve -pr 1.0 -p $line1`;
$v2 = `pointOnCurve -pr 1.0 -p $line2[0]`;
curve -d 1 -p $v1[0] $v1[1] $v1[2] -p $v2[0] $v2[1] $v2[2];
$ncount++;
}
$vectormain1 = `pointOnCurve -pr 0.0 -p $curve[0]`;
$vectormain2 = `pointOnCurve -pr 0.0 -p $offsetmain[0]`;
curve -d 1 -p $vectormain1[0] $vectormain1[1] $vectormain1[2] -p $vectormain2[0] $vectormain2[1] $vectormain2[2];
$text = `textCurves -ch 0 -f "Proxy 9|h-20|w400|c0" -t $i`;
rotate 0 90 0;
move $vectormain1[0] $vectormain1[1] ($vectormain1[2]+10);
$newcurvemain1 = `reverseCurve $curve[0]`;
$vectormain1 = `pointOnCurve -pr 0.0 -p $newcurvemain1[0]`;
$vectormain2 = `pointOnCurve -pr 0.0 -p $offsetmain[0]`;
curve -d 1 -p $vectormain1[0] $vectormain1[1] $vectormain1[2] -p $vectormain2[0] $vectormain2[1] $vectormain2[2];

$up = $up + $sizey;
$back = $back - $spacingx;

$i++;
}

$i=0;
$up = 50;
$back = 0;
$up2 = 50;
$back2 = 0;
while($i < size($listz)){
$thing = `intersect $surface $listz[$i]`;

$curve = `duplicateCurve -ch 1 -rn 0 -local 0 $thing[0]`;
$count = 0;
select "cutterx*";
$listx = `ls -sl -tr`;

$spacingz = `getAttr PlaneToolPaletteDataz.spacingz`;
$notches[30] = 1;
while ($count < size($listx)){
$thing2 = `intersect $surface $listx[$count]`;

$curve2 = `duplicateCurve -ch 1 -rn 0 -local 0 $thing2[0]`;
string $node = `curveIntersect -useDirection true -direction 0 1 0 -ch on $curve[0] $curve2[0]`;
float $p1[] = `getAttr ($node + ".parameter1")`;
float $p2[] = `getAttr ($node + ".parameter2")`;

$notches[$count] = $p1[0];

delete $curve2;
delete $thing2;
$count++;
}

$offsetmain = `offsetCurve -ch on -d 1 -ugn false -nr 0 1 0 $curve[0]` ;
select $curve;
rotate 0 90 0;
move $back2 $up2 $sizex;
$up2 = $up2 + $sizey;
$back2 = $back2 - $spacingz;

$ncount=0;
while ($ncount < size($listx)){
$nvector = `pointOnCurve -pr $notches[$ncount] -p $curve[0]`;
$cmaxy = `pointOnCurve -pr 0.0 -p $curve[0]`;
$offmaxy = `pointOnCurve -pr 0.0 -p $offsetmain[0]`;
$line1 = `curve -d 1 -p $nvector[0] ($nvector[1]+.5) ($nvector[2]+.1) -p $nvector[0] ($nvector[1]+.5) ($nvector[2]+.1)`;
if ($cmaxy[1] < $offmaxy[1]){
$line1 = `curve -d 1 -p $nvector[0] ($nvector[1]+.5) ($nvector[2]+.1) -p $nvector[0] ($nvector[1]-1) ($nvector[2]+.1)`;
}else{
$line1 = `curve -d 1 -p $nvector[0] ($nvector[1]-.5) ($nvector[2]+.1) -p $nvector[0] ($nvector[1]-1.5) ($nvector[2]+.1)`;
}
$line2 = `offsetCurve -ch on -rn false -cb 2 -st true -cl true -cr 0 -d .2 -tol 0.01 -sd 5 -ugn false $line1`;
$v1 = `pointOnCurve -pr 0.0 -p $line1`;
$v2 = `pointOnCurve -pr 0.0 -p $line2[0]`;
curve -d 1 -p $v1[0] $v1[1] $v1[2] -p $v2[0] $v2[1] $v2[2];
$ncount++;
}
$vectormain1 = `pointOnCurve -pr 0.0 -p $curve[0]`;
$vectormain2 = `pointOnCurve -pr 0.0 -p $offsetmain[0]`;
curve -d 1 -p $vectormain1[0] $vectormain1[1] $vectormain1[2] -p $vectormain2[0] $vectormain2[1] $vectormain2[2];
$text = `textCurves -ch 0 -f "Proxy 9|h-20|w400|c0" -t $i`;
rotate 0 90 0;
move $vectormain1[0] $vectormain1[1] ($vectormain1[2]-10);
$newcurvemain1 = `reverseCurve $curve[0]`;
$vectormain1 = `pointOnCurve -pr 0.0 -p $newcurvemain1[0]`;
$vectormain2 = `pointOnCurve -pr 0.0 -p $offsetmain[0]`;
curve -d 1 -p $vectormain1[0] $vectormain1[1] $vectormain1[2] -p $vectormain2[0] $vectormain2[1] $vectormain2[2];

$i++;
}

}

azshall
02-13-2008, 12:29 AM
Good luck getting anyone to sift through that mess... I know I don't have the time to debug that. If you had a starting point that might be helpful.

HowardB
02-15-2008, 06:19 AM
if you source that script and run "Sections" proc you will get a window, but i don't know how to use this script so maybe that will get you started.

ticket01
02-18-2008, 05:47 AM
I figured that much that you need to call planeWindow to fire it up. Problem is that there obviously some prerequisites that I don't know of. Where'd you get the script? Maybe there's some more info.

frd
03-10-2008, 05:11 PM
thanks...
your hints already helped

CGTalk Moderation
03-10-2008, 05:11 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.