intrange (lxintrange.h)

From The Foundry MODO SDK wiki
Jump to: navigation, search
There are security restrictions on this page


Integer Range

This file defines an interface and exotype, for storing a range of integer values. The values can be stored as comma seperated values, a range of values or a combination of the two. This is ideal for working with things like frame numbers.

IntRange Interface

The ILxIntRange interface is used by the IntRange ExoType. Ranges are entered as strings, and are inclusive: "1-5" matches 1, 2, 3, 4 and 5. A dash is used to specify ranges, such as "1-20", commas add more ranges or specific integers, such as "1-20,30,45-55", leading and trailing ellipses to mark all before and all after, such as "...1-10,20-30", and can be used to specify an exclusive range with something like "...0,11...". "..." by itself matches everything. Negative numbers are supported, such as "-1", "-1--30" or "-1-1". Whites space is automatically skipped, making negative numbers easier to read as "-1 - -30" or "-1 - 1", for example. Numbers can be in reverse order, such as "10-20,5-10" or "20-10". The range can be read in lowest to highest numerical order or in the order the of the string.

A range that does not follow the rules, such as an ellipses in the middle of the string, a dash without a number on the left side, no dash or comma between nubmers, or any illegal characters, is considered failed and will return false to all requests.

(1) SDK: Declarations
 #define LXu_INTRANGE            "FEAF19EC-B819-4C46-ABA3-EC8593F8BE8C"
 #define LXa_INTRANGE            "intrange"
 #define LXsTYPE_INTRANGE        "+intrange"

These return true LXe_TRUE if there are leading or trailing ellipses, and LXe_FALSE if not.

(2) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 AllBefore) (
         LXtObjectID              self);
 
         LXxMETHOD( LxResult,
 AllAfter) (
         LXtObjectID              self);

These functions allow the integer range to be walked. The basic walking functions are Next() and Prev() and increment the current position. What is considered "next" and "previous" is determined by if the list is being walked in numerical or user order. When there are no more integers left, the methods fail.

(3) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 Next) (
         LXtObjectID              self,
         int                     *i);
 
         LXxMETHOD( LxResult,
 Prev) (
         LXtObjectID              self,
         int                     *i);

Numerical order starts at lowest integer in the range and goes to the highest integer. Example uses are print ranges, where you always want to print from the first page to the last page.

User order starts from the first integer the user specified to the last, including reversed ranges. This is useful for things such as rendering sequences backward.

In both cases, each integer will be returned only once. Note that these functions will fail if the range consists entirely of "...", as there is no meaningful beginning or end to the range.

Min() and Max() are used to get the lowest or highest integer and set the mode to numerical order.

(4) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 Min) (
         LXtObjectID              self,
         int                     *min);
 
         LXxMETHOD( LxResult,
 Max) (
         LXtObjectID              self,
         int                     *max);

First() and Last() are used to get the first or last integer and set the mode to user order.

(5) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 First) (
         LXtObjectID              self,
         int                     *first);
 
         LXxMETHOD( LxResult,
 Last) (
         LXtObjectID              self,
         int                     *last);

This gets the current integer.

(6) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 Current) (
         LXtObjectID              self,
         int                     *current);

It is often useful to be able to simply test to see if an integer is within the range. This returns LXe_TRUE if in range. This does not affect the current position used to walk the range.

(7) SDK: ILxIntRange interface
         LXxMETHOD( LxResult,
 Test) (
         LXtObjectID              self,
         int                      i);

Empty IntRange Python user class.

(8) PY: IntRange method
 pass