Jorge Arango
01-15-2010, 12:40 PM
Note: to execute this script you must have a polygon object selected with at least one edge selected:
CallCommand(13957); // Clear console contents---------------
println("Console cleared");//Control------------------------
println("----------");
var nul = new(NullObject);
var active = doc->GetActiveObject();
if(!object)
{
println("Select a Polygon Object and, in edge mode, select at least one edge.");
return;
}
if(! (op->GetType()==OBJECT_POLYGON))
{
println("Must be a Polygon Object");
return;
}
var tol = .1; //Tolerance
var position = 6; //Position of cut
var prcntPos = .2; //Position in ATS tag
var posNul = nul->GetPosition();//Position of null object
CallCommand(1009671); //Edge to Spline
nul->InsertUnder(active);
var nul2 = op->GetDown();//Null object
var splineRef = nul2->GetNext();//Reference spline for ATS tag
var ats = AllocTag(Taligntospline);//Assign the ats tag to variable named ats
ats#ALIGNTOSPLINETAG_LINK = splineRef;
println("Just for control:");//Control--------------------------
println(splineRef->GetName()); //Control------------------------
println("----------");//Control---------------------------------
nul2->InsertTag(ats);//Add the ats tag to currently selected object
ats#ALIGNTOSPLINETAG_POSITION=prcntPos;//Percent position in ATS tag
------------------------------------------------------------------
//Working fine to here-----------------------------------------
------------------------------------------------------------------
var posNul2 = nul2->GetPosition();//Position of null object
println("With method A, 'GetPosition()':");
println("Position in Y=", posNul2.y);
println("----------");//Control---------------------------------
active->DelBit(BIT_ACTIVE);
nul2->SetBit(BIT_ACTIVE);//To make sure that the var nul2 really corresponds to the null object
var obj = doc->FindObject("Null Object");
var matrix = obj->GetMg(); // Get the global matrix
var globalPos = matrix->GetV0(); // Get the position from the matrix
println("With method B, 'GetMg()' and 'GetV0()':");
println("Global position = ", globalPos);
return;
This script does the following:
1. Executes the edge to spline command
2. Creates a null object as first child of the polygon object
3. Applies an align to spline tag, linked to the spline created with the edge to spline command to the null object
4. Sets the position in the ATS tag to 20%
5. Prints the position of the null object in the console twice. First using the GetPosition command and then it uses the GetMg() and the GetV0() commands.
6.It also does some minor things used to monitor the script like printing some variables and selecting some objects and unselecting others. It also creates some variables that I intend to use further on.
However, the position printed in the console does not correspond to the real position of the null object.
Anybody knows what I'm doing wrong?
CallCommand(13957); // Clear console contents---------------
println("Console cleared");//Control------------------------
println("----------");
var nul = new(NullObject);
var active = doc->GetActiveObject();
if(!object)
{
println("Select a Polygon Object and, in edge mode, select at least one edge.");
return;
}
if(! (op->GetType()==OBJECT_POLYGON))
{
println("Must be a Polygon Object");
return;
}
var tol = .1; //Tolerance
var position = 6; //Position of cut
var prcntPos = .2; //Position in ATS tag
var posNul = nul->GetPosition();//Position of null object
CallCommand(1009671); //Edge to Spline
nul->InsertUnder(active);
var nul2 = op->GetDown();//Null object
var splineRef = nul2->GetNext();//Reference spline for ATS tag
var ats = AllocTag(Taligntospline);//Assign the ats tag to variable named ats
ats#ALIGNTOSPLINETAG_LINK = splineRef;
println("Just for control:");//Control--------------------------
println(splineRef->GetName()); //Control------------------------
println("----------");//Control---------------------------------
nul2->InsertTag(ats);//Add the ats tag to currently selected object
ats#ALIGNTOSPLINETAG_POSITION=prcntPos;//Percent position in ATS tag
------------------------------------------------------------------
//Working fine to here-----------------------------------------
------------------------------------------------------------------
var posNul2 = nul2->GetPosition();//Position of null object
println("With method A, 'GetPosition()':");
println("Position in Y=", posNul2.y);
println("----------");//Control---------------------------------
active->DelBit(BIT_ACTIVE);
nul2->SetBit(BIT_ACTIVE);//To make sure that the var nul2 really corresponds to the null object
var obj = doc->FindObject("Null Object");
var matrix = obj->GetMg(); // Get the global matrix
var globalPos = matrix->GetV0(); // Get the position from the matrix
println("With method B, 'GetMg()' and 'GetV0()':");
println("Global position = ", globalPos);
return;
This script does the following:
1. Executes the edge to spline command
2. Creates a null object as first child of the polygon object
3. Applies an align to spline tag, linked to the spline created with the edge to spline command to the null object
4. Sets the position in the ATS tag to 20%
5. Prints the position of the null object in the console twice. First using the GetPosition command and then it uses the GetMg() and the GetV0() commands.
6.It also does some minor things used to monitor the script like printing some variables and selecting some objects and unselecting others. It also creates some variables that I intend to use further on.
However, the position printed in the console does not correspond to the real position of the null object.
Anybody knows what I'm doing wrong?
