General Category > ASL Scripts
collapse points command
BOB_I_Ts:
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
Kubajzz:
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: ---#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);
}
}
}
}
--- End code ---
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 ;)
BOB_I_Ts:
thanks Kubajzz ,il take look at it tonight , ,I will try something like collapse points command x,y,z aka flatten command with points
BOB_I_Ts:
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
kreator:
--- Quote ---im unsure how to begin with these push ,pop ,marked,unmarked (no idea) etc functions or how they work together in ASL ?
--- End quote ---
Where are these commands push,pop etc ?
Navigation
[0] Message Index
[#] Next page
Go to full version