Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 1.83 KB

File metadata and controls

77 lines (62 loc) · 1.83 KB

Count

Description

Counts all of the objects which match the search criteria.

FUNCTION Count(c : CRITERIA): LONGINT;
def vs.Count(c):
    return LONGINT

Parameters

Name Type Description
c CRITERIA Search criteria.

Remarks

Undocumented is that criteria also accept the object type flag as parameter. The example above can also be written:

CountValue := Count((FP=4)and(T=3)); { 3 is object type flag for 'Rectangle&amp' }

This is valid for all object types being assigned a name in the Script Appendix.

Examples

VectorScript

CountValue := Count((FP=4)and(T='Rect'));
{counts all rectangles with a fillpat index of 4}

Python

CountValue = vs.Count("(FP=4)AND(T='Rect')")
# counts all rectangles with a fillpat index of 4
BEGIN
	ObjCount := Count(SEL);
	IF ObjCount > 0 THEN
		BEGIN
			ALLOCATE RedList[1..ObjCount];
			ObjCount := 0;

{Load our handle array with the current Selection Set}
gSelectionSize := Count(SEL);
ALLOCATE selHandles[1..gSelectionSize];
ALLOCATE ObjLoc[1..gSelectionSize];
gNumObjs := 0;
ForEachObjectInLayer(LoadHandleArray, 2, 0, 4);

BEGIN
	IF ResourceIsOK THEN
	if Count(ALL) > 0 then BEGIN
		for cnt := 1 to kMaxPopUp DO types[cnt] := GetLocStr(11004, cnt);
		mT := GetPlugInString(7002);
import vs

# Counts all of the objects which match the search criteria.
c = "(SEL=TRUE)"  # selection criteria - all selected objects

count = vs.Count(c)
vs.Message('Count returned: ' + str(count))

See also in tutorials: 23. Count Objects by Criteria (Formula-Driven)

Version

Availability: from All Versions

Category