The script for chain

 From:  Michael Gibson
6087.38 In reply to 6087.36 
Hi Brian,

> Currently bogged down with trying to get "Array Dir" factory to work in script.

Array dir's inputs are like this:

index 0 = object list - objects to be arrayed.
index 1 = integer - number of items to make in the array (the original object is included in this count, so for example num items = 3 will actually make 2 copies).
index 2 = point - base point
index 3 = point - offset point
index 4 = point - extent point
index 5 = string - can be one of: "Offset, Count" or "Extent, Count" or "Offset, Extent"

How the points are interpreted depends on the mode, the most simple mode is "Offset, Count" mode that will be where only the base point and offset point are set and that defines a distance that is used for each generated copy.



> Not sure if the Array output is a list of multiple chain links or ...?

Which method are you using for generatring the output, is it factory.calculate() ? That method always generates an object list for its output. For array dir it will be all the copied objects that were generated.


> Still fuzzy on objects versus object lists, and object lists with one object, and how to
> concatenate link1 and link2 with .addobject...etc...

Yeah the "object list of a single object" can be kind of awkward, that comes into play though when you use some general purpose interface that is set up to be flexible so that it handles both commands that generate one object and also commands that generate multiple objects with a common way of operating. So for example the .calculate() method is like that it always returns an object list with the objects that were generated in it, that way it behaves the same way for all factories instead of returning different things depending on whether the factory made only one object versus a bunch of them.

For concatenating 2 lists together, you need to do something like this

var list1, list2;

...

// Combine list2 into list1
for ( var i = 0; i < list2.length; ++i )
{
var obj = list2.item(i);
list1.addObject( obj );
}

If you need to do this a lot, make a helper function that will do that task for you so you can call your function to do it when you need it.


And one thing to note is that the geometry database is not exactly the same thing as an object list, although the geometry database contains within it a list of objects, it has its own interface for dealing with it and has some additional methods like addObjects() that takes an object list. Currently an object list itself does not have a method that adds another object list to it, it only has an addObject() function.

- Michael