Anim8or Community

General Category => ASL Scripts => Topic started by: VBSmiles on November 09, 2008, 04:43:45 am

Title: Yeaaah..
Post by: VBSmiles on November 09, 2008, 04:43:45 am
Appearently this ASL stuff is rigged. Ok, maybe not. I just seem to be having a little problem with soaking in it as a programmer.

#command("object"); /*1*//* To start as menu item ? */
point3 $C_point;     /*2*//* current point */
float $dist;    /*6*//* Distance between points and ... */
 /*7*/   $model = project.curObject;

/* Get the marked point */
for $i = 0 to GetNumPoints($model)

 int $test = GetPointMarked($i);
if ($test = 1){
SetPoint ($i, $c_point.x, 0);

so uh.... what went wrong?
Title: Re: Yeaaah..
Post by: Francesco on November 09, 2008, 10:33:44 am
Hi VBSmiles,
one of the things that went wrong is the comparison you use in the if test. The boolean "is equal to" is "==", a single equal sign is used for assignation.

Another thing you missed is the "do" at the end of the "for" statement. Also you shouldn't be using functions such as "GetNumPoints()" as stand alone, it should be something like "$curshape.GetNumPoints()", where $curshape needs to be properly assigned with a new shape or an existing one, such as in:
$curshape = project.curObject.LookupShape("mesh01");

If you take a look at the Anim8or console while loading a script, some of the common mistakes are pointed out by the script parser.

Reading some already working script does help too, I've learnt a lot only by reading the scripts that NickE and Kubajzz shared on the forum.
Title: Re: Yeaaah..
Post by: Kubajzz on November 09, 2008, 12:09:05 pm
First, I recommend reading the ASL specification (, it will help you a lot. As for your code, I've got several more notes:
Code: [Select]
$model = project.CurObject;
The "$model" variable is not declared in your code...

The "CurObject" function returns the current object, not the current shape. To select certain shape inside your object, use the "project.curObject.LookupShape(<<name>>);" function as Francesco suggested. You can also use "project.curObject.GetShapes(<<array>>);" to get an array of all shapes.

Code: [Select]
Correct syntax is "$model.GetNumPoints();"

Oh, and Francesco is right, it really helps a lot to read the console output to find out what's wrong :) Good luck!
Title: Re: Yeaaah..
Post by: Steve on November 11, 2008, 06:50:47 am
Yu also need to be careful about upper and lower case names.  $C_point is not the same as $c_point
Title: Re: Yeaaah..
Post by: VBSmiles on November 12, 2008, 10:13:48 pm
Thanks guys. I think I caught a few of the mistakes myself when I slowed down and studied ASL a little more closely. Also I am very well aquanted with VB ( hence the name ) rather than  than c++ so have forgotten some of the common differences in opperators and such  :P

theres some other differences I've yet to work out but will check out what you guys have stated.

( Steve )  ;D A common mistake of mine. Maybe I should use my VB compiler to code. It makes those fixes by itself. Just too lazy to load it onto the computer.
Title: Re: Yeaaah..
Post by: VBSmiles on November 13, 2008, 04:38:18 am
Sweet! got it to work!

Code: [Select]
/*** Script in progress made to flatten points ***/
/*** Created by: VBSmiles                              ***/
/*** declaration ***/
#command("object"); /*1*//* To start as menu item ? */
point3 $c_point;     /*2*//* current point */
float $dist;    /*6*//* Distance between points and ... */
shape $model;
int $test, $i, $NP;
file $file;
string $Output;

/*** Initialization ***/
$model = project.curObject.LookupShape("mesh01");
/*** Get the number of points in model ***/
if ($model != NULL)

$NP = $model.GetNumPoints();

for $i = 0 to $NP do
   $Output = PrintToString("%d", $NP);
   $"$console", "w");
   $file.print("\n\n Value of $NP: " +$Output+ "\n\n");
   $Output = PrintToString("%d", $i);
   $file.print("\n\n Value of $i: " +$Output+ "\n\n");

   /* Get the selected point */
   $test = $model.GetPointSelected($i);
   /*** if selected then store it's values ***/
   if ($test == 1)
      $c_point = $model.GetPoint ($i);
      /*** reset it's x componenet to 0 ***/
      $c_point.y = 0;
      /*** move the point ***/
      $model.SetPoint ($i, $c_point);

} else
   $"$console", "w");
   $file.print("\n\n where the hell is the model? \n\n");

Now I just have to figure out a better way  and add a way to choose axis  ;D