Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

Author Topic: collapse points command  (Read 13161 times)

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Anim8rOrg
collapse points command
« on: May 30, 2010, 10:00:13 pm »

Being non-programmer ive come to understand basics of parametric script from great starter advice from asl masters like Kubajzz and Null.
But soon i hope to learn about the command types which seem to work in different way

im unsure how to begin with these push ,pop ,marked,unmarked (no idea) etc functions or how they work together in ASL ?

so to gain understanding how commands work in ASL  i request any simple examples

something simple like nudge X+10 command : select point or points and move them along x plain by + 10
should be enough to help
« Last Edit: June 03, 2010, 01:17:40 am by BOB_I_Ts »
Logged

Kubajzz

  • Flying Platypus
  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 548
  • Little doggie ate my avatar...
    • View Profile
Re: command script 101
« Reply #1 on: May 31, 2010, 08:03:38 am »

Hi Bob,

I found a simple example for you. I created this script several years ago, it never proved to be useful, but it's simple enough to be used as a learning source. It's called "Grow Points Selection" - it finds all selected points and selects all their neighbours.

Code: [Select]
#command("object");

shape $Shapes[0], $S;
int $i, $j, $SelectedPts[0];

/* Find all the shapes in the current object and store them in the $Shapes array */
project.curObject.GetShapes($Shapes);

/* Loop through all the shapes */
while ($Shapes.size > 0) {

  /* Remove the last item from the array */
  $S = $Shapes.pop();

  /* Continue only if the current shape is a mesh */
  if ($S.GetKind() == SHAPE_KIND_MESH) {

    $SelectedPts.size = 0;

    /* Loop through all points of this shape */
    for $i = 0 to $S.GetNumPoints()-1 do {

      /* If the current point is selected, add it to the $SelectedPts array */
      if ($S.GetPointSelected($i))
        $SelectedPts.push($i);
    }


    /* Select all neighbour points of each point in the $SelectedPts array */
    for $i = 0 to $SelectedPts.size-1 do {

      for $j = 1 to $S.GetNumEdges() do {

        if ($S.GetEdgeIndex0($j) == $SelectedPts[$i])
          $S.SetPointSelected($S.GetEdgeIndex1($j), true);

        else if ($S.GetEdgeIndex1($j) == $SelectedPts[$i])
          $S.SetPointSelected($S.GetEdgeIndex0($j), true);
      }
    }
  }
}

I tried to provide enough comments, if you have any questions I'll be happy to help you.

As for your questions... The pop and push functions are used to remove/add array items, as you can see from the example above. ASL arrays do not have a fixed size so you can always remove the last item by calling the pop() function or you can add a new item to the end of the array by calling the push() function.

The Marked property and SetXXXMarked() and GetXXXMarked() functions are something I've never used... Anyway, you can make any shape, texture, edge, face etc. "marked" or "unmarked" just like you can make certain components selected/unselected. The difference is that making things marked does not make them look differently, it's just an internal property you can use. It might be useful in very complex scripts where you need to keep track of many things...

Command scripts are not much different than parametric scripts or export scripts... The only difference is that you have a few extra functions available while some features (such as user input) are more restricted. As always, the ASL specification is your best friend ;)
Logged

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Anim8rOrg
Re: command script 101
« Reply #2 on: May 31, 2010, 11:58:39 pm »

thanks Kubajzz ,il take look at it tonight , ,I will try something like collapse points  command x,y,z aka flatten command with points
Logged

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Anim8rOrg
Re: command script 101
« Reply #3 on: June 01, 2010, 01:34:29 pm »

collapse points command

align selected points to specified coordinate

how to use
align options :
create attribute align set to type (string)
names for string to correspond with collapse x,y,z,xy,xz,yz or xyz (all strings use lowercase)

set alignment
create attribute collapse set to type (point)
copy paste coordinate from existing point or manual input   :)

special thanks to Kubajzz  8)

edit:  :-[ i forget to set y coordinate in the collapse in the xyz string command file updated
« Last Edit: June 04, 2010, 02:30:12 am by BOB_I_Ts »
Logged

kreator

  • Hero Member
  • *****
  • Posts: 1146
  • Anim8or, Blender, & Carrara. A Great Combination!
    • View Profile
    • Anim8orWorld
Re: collapse points command
« Reply #4 on: June 05, 2010, 02:51:14 am »

Quote
im unsure how to begin with these push ,pop ,marked,unmarked (no idea) etc functions or how they work together in ASL ?

Where are these commands push,pop etc ?
Logged
O

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Anim8rOrg
Re: collapse points command
« Reply #5 on: June 05, 2010, 04:38:13 am »

there not commands but the are ASL code functions

here is my attempt at visualizing how they work imagine liberian working at book shelf(array) at local library

function pop means liberian would take last book off the shelf read out its contents (sets value to assigned counter !) then throw it in a bin
function push means liberian writes new book based on parameter values then put it on the end of the shelf

unsure how a literal  pop command script would work but you could change collapse script to be a  push / (nudge command)

example

Code: [Select]
if ($xyz == "x") {
$at = project.curObject.LookupAttribute("collapse");
$sp = $at.GetPoint3Value();
$p.x = $sp.x;
}
change to $p.x = $p.x + , $p.y = $p.y + and  $p.z = $p.z + like so
Code: [Select]
if ($xyz == "x") {
$at = project.curObject.LookupAttribute("collapse");
$sp = $at.GetPoint3Value();
$p.x = $p.x + $sp.x;
}
then attribute "collapse" should just nudge distance of the value to each point set separately !

collapse command is first mesh editing command but first one i did was new material.zip 2007 but seems Steve did one better with updating anim8or with edit > copy material and paste new material so it would be pointless me completing that script

i hope to do command related to UV were these push pops will come handy ,first i need to finish editing model for that v0.9 f8ce plug-in before i attempt
Logged

kreator

  • Hero Member
  • *****
  • Posts: 1146
  • Anim8or, Blender, & Carrara. A Great Combination!
    • View Profile
    • Anim8orWorld
Re: collapse points command
« Reply #6 on: June 05, 2010, 06:15:13 am »

I was thinking perhaps there might be something to do a "hide" for points Now that would be a useful script!

Logged
O

BOB_I_Ts

  • Full Member
  • ***
  • Posts: 157
    • View Profile
    • Anim8rOrg
Re: collapse points command
« Reply #7 on: June 05, 2010, 08:33:57 am »

ASL restricts configure GUI menu :( , you can just set wire to view outline points and smooth to only show outline for mesh

i saw a script which stores selections in sticky topic it maybe possible to use similar method to hide points but would also hide polygons connected to selected point as a hide selection , unhide selection ,it kinda seem scary script to attempt though loss undo data just by using render preview

i think create new object then copy paste deattache face is much more safe method
Logged