PDA

View Full Version : Maya crashed by using draggerContext


X-Tender
03-25-2003, 07:39 AM
Mo,

i have following Script!

proc scaleObj(float $start[], float $end[], string $Obj)
{
float $scaleX = 1 + $end[0] - $start[0];
$scaleY = $scaleX;
$scaleZ = $scaleX;

string $message = ("sx:"+`swFloatToNiceString $scaleX` + " sy: "+`swFloatToNiceString $scaleY` + " sz: "+`swFloatToNiceString $scaleZ`);
draggerContext -edit -drawString $message buildContext;

select -r $Obj;
scale $scaleX $scaleY $scaleZ;
}

global proc buildContextPress(string $Obj)
{
global float $pressPosition[3];
float $pressPosition[] = `draggerContext -query -anchorPoint buildContext`;
string $modifier = `draggerContext -query -modifier buildContext`;

select -r $Obj;

if ( $modifier == "shift" )
{
move $pressPosition[0] `getAttr ($Obj+".ty")` $pressPosition[2];
}
else
move $pressPosition[0] $pressPosition[1] $pressPosition[2];

refresh -currentView;

}


proc buildContextDrag(string $Obj)
{
float $pressPosition[] = `draggerContext -query -anchorPoint buildContext`;
float $dragPosition[] = `draggerContext -query -dragPoint buildContext`;
string $modifier = `draggerContext -query -modifier buildContext`;
string $message;


select -r $Obj;

if ( $modifier == "shift" )
{
string $message = ("tx:"+`swFloatToNiceString $dragPosition[0]` + " ty:0 tz:"+`swFloatToNiceString $dragPosition[2]`);
draggerContext -edit -drawString $message buildContext;
move $dragPosition[0] `getAttr ($Obj+".ty")` $dragPosition[2];
}
else if ($modifier == "ctrl")
scaleObj($pressPosition, $dragPosition, $Obj);
else
{
string $message = ("tx:"+`swFloatToNiceString $dragPosition[0]` + " ty:"+`swFloatToNiceString $dragPosition[1]` + " tz: "+`swFloatToNiceString $dragPosition[2]`);
draggerContext -edit -drawString $message buildContext;
move $dragPosition[0] $dragPosition[1] $dragPosition[2];
}

refresh -currentView;
}


proc buildContextRelease(string $Obj)
{

float $releasePosition[] = `draggerContext -query -dragPoint buildContext`;

select -r $Obj;

setToolTo buildContext;
}


proc createDragObj(string $name)
{

global string $buildContextName;
global string $currentObj;
$currentObj = $name;

if ( `draggerContext -exists $buildContextName` )
{
deleteUI $buildContextName;
}

$buildContextName = `draggerContext
-pressCommand ("buildContextPress($currentObj)")
-dragCommand ("buildContextDrag($currentObj)")
-releaseCommand ("buildContextRelease($currentObj)")
-cursor "crossHair"
-space world
buildContext`;

setToolTo buildContext;
}

proc string swFloatToNiceString(float $swFloat)
{
string $swReturn;
string $swPrintData[];

if (($swFloat < 0.000001) && ( $swFloat > -0.000001)) $swReturn = "0.000000";
else

{
string $swTmp = $swFloat;
tokenize $swTmp "." $swPrintData;
if (size ($swPrintData) == 2)
{

$swPrintData[1] = $swPrintData[1] + "000";
$swReturn = $swPrintData[0] + "." + `substring $swPrintData[1] 1 3`;
}
else
$swReturn = $swPrintData[0] + ".000";
}
return $swReturn;
}


Procedure is called by createDragObj($anslectedobject);

and tehn i get this after i drag the object a little bit arround or try to use the modifyer "shift" or "crtl".

You can test it if you copy/paste the code .. create an object .. and insert the name of the object in $anselectedobject e.g. createDragObj("pcube2");

http://xtender.00network.org/error.gif

:cry:

X-Tender
03-25-2003, 03:22 PM
solved ...

but did someone know how i can get the koordinate when i click on an object? i meant the koordinate of the point i hit .. like a traceline ...


|
----------------------->|
|


get teh coordinate of the point ehre teh arrow show .. on a plane/face ..

damn .. my english is so bad :annoyed:

CGTalk Moderation
01-14-2006, 05:00 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.