VS:ForEachObjectInList

From Vectorworks Developer
Revision as of 14:30, 12 August 2013 by Root (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Processes all items in the specified list and and applies the specified action to each item.

Table - ForEachObjectInList Selectors
Option Selector Description
Object Options
All objects 0
Visible Objects only 1
Selected Objects only 2
Unlocked objects only 4
Traversal Options
Traverse Shallow 0
Traverse Groups 1 Traverse inside groups
Traverse Deep 2 Traverse all containers

(walls, extrudes, sweeps, etc)

PROCEDURE ForEachObjectInList(
actionFunc :FUNCTION;
objOptions :INTEGER;
travOptions :INTEGER;
list :HANDLE);
def vs.ForEachObjectInList(actionFunc, objOptions, travOptions, list):
    return None

Parameters

actionFunc FUNCTION Subroutine which performs operation on found objects.
objOptions INTEGER Object selection option index.
travOptions INTEGER Search options index.
list HANDLE Handle to first item in list.

Remarks

Be careful using this together with a call to VS:BeginSym: it deselects all selected objects on active layer (VW 13)

It seems that when you fill in a NIL Handle in the list Parameter, the ActionFunc will be executed on all the objects of the active layer (VW2011).

Example

PROCEDURE Example;
CONST
pioName = 'Complex Window 2';
parameter = 'MeasureHeight';
value = 'Head of Window';

FUNCTION DoIt(h :HANDLE) :BOOLEAN;
BEGIN
h := FInSymDef(h);
SetRField(h, pioName, parameter, value);
END;

BEGIN
ForEachObjectInList(DoIt, 0, 0, FSymDef);
END;
RUN(Example);


Another example:

PROCEDURE Example;
CONST
pioName = 'Window';
parameter = 'UPI';
value = '25.4';

FUNCTION DoIt(h :HANDLE) :BOOLEAN;
BEGIN
h := FInSymDef(h);
IF (h <> NIL) & (GetType(h) = 86) & (Eval(h, 'R IN [pioName])') > 0) THEN BEGIN
SetRField(h, pioName, parameter, value);
END;
END;

BEGIN
ForEachObjectInList(DoIt, 0, 0, FSymDef);
END;
RUN(Example);

Version

Availability: from VectorWorks 8.5