CadObjectList

From SDK
Jump to navigation Jump to search
Back.jpg

This object holds a list of CadObjects

Constructor

CadObjectList(bool owns_objects)

Creates a new CadObjectList owns_objects -bool – true if this list owns the objects it contains. If this is true and the list still contains objects when it goes out of scope the objects will be deleted.


Properties


.Count

Read Only - integer – return the number of objects in the list



.IsEmpty

Read Only - bool – return true if the list is empty


Methods


:AddHead( CadObject obj)

Add the passed object to the front of the list

obj –CadObject –object to put in list



:AddTail( CadObject obj)

Add the passed object to the end of the list

obj –CadObject –object to put in list



:CanTransform( integer flags)

Return true if object can be transformed

flags –integer –value indicating type of transform – these can be combined e.g 3 (1+2) will check for both Move and Rotate

1 = Move 2 = Rotate 4 = Mirror 8 = Scale Symetric 16 = Scale Asymetric



:GetAt( POSITION pos)

Returns the object at the current position

pos – POSITION – current position in list



:GetHeadPosition()

Returns a POSITION variable to allow access to the head of the list



:GetNext( POSITION pos)

Returns the object at the current position AND a new value for position pointing to the next item in the list (or nil if at end of list)

pos – POSITION – current position in list
note that GetNext(pos) is returning two values ...

Usage Syntax: =

         local pos = obj_list:GetHeadPosition() 
         local object 
         while pos ~= nil do
            object, pos = obj_list:GetNext(pos)
            DO SOMETHING WITH OBJECT .... 
         end  -- while end  


:GetPrev( POSITION pos)

Returns the object at the current position AND a new value for position, pointing to the previous item in the list (or nil if at start of list)

pos – POSITION – current position in list



:GetTailPosition()

Returns a POSITION variable to allow access to the tail (end) of the list



:RemoveHead()

Remove the id at the front of the list and return it



:RemoveTail()

Remove the id at the end of the list and return it



:Transform( Matrix2D xform)

Transform all objects in list by passed transform

xform – Matrix2D – transformation matrix to apply to objects


Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information