SelectionList: Difference between revisions

From SDK
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:
[[Category:SDK]]
[[Category:SDK]]
This object holds a list of CadObjects representing the current selection in the program.   
This object holds a list of CadObjects representing the current selection in the program.   
 
 
 


== Properties ==
== Properties ==
Line 12: Line 10:


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



Revision as of 07:21, 7 September 2023

Back.jpg

This object holds a list of CadObjects representing the current selection in the program.


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

:Add( CadObject obj, bool add_tail, bool group_add)

Add the passed object to the list

obj –CadObject –object to put in list
add_tail –bool –if true add to end of selection else insert at start group_add –bool –if you are adding a lot of objects to the selection, set this true and call :GroupSelectionFinished() when you have added all the objects. This stops a lot of unnecessary updating while you are updating the selection.



: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 - these can be combined e.g 3 (1+2) will check for both Move and Rotate flags –integer –value indicating type of transform –

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

:CanSelect(CadObject obj)

Return true if passed object can be selected

obj –CadObject –object to test



:Clear()

Clear the selection (list is emptied)



:GetAt(POSITION pos)

Returns the object at the current position

pos – POSITION – current position in list



:GetBoundingBox()

Return a Box2D with the bounds of the selected objects



: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

Example - note that GetNext(pos) is returning two values ...

local pos = obj_list:GetHeadPosition() local object while pos ~= nil do

   object, pos = obj_list:GetNext(pos)     DO SOMETHING WITH OBJECT .... 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

:GroupSelectionFinished()

Call this if you have been using :Add(…) with group_add set to true to update the application when you have finished adding objects to the selection.



:RemoveOnLayer(UUID layer_id)

Remove any objects from the selection which are on the layer with the passed id. The objects are just removed from the selection, they are not deleted are changed in any other way.


:Remove( CadObject obj, bool group_remove)

Remove the passed object from the selection

obj –CadObject –object to put in list group_remove –bool –if you are removing a lot of objects to the selection, set this true and call :GroupSelectionFinished() when you have removed all the objects. This stops a lot of unnecessary updating while you are updating the selection.



: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


Usage: job.Selection()

   The selection is accessed via the job …  
   -- Check we have a document loaded     
   local job = VectricJob()   
   if not job.Exists then  
      DisplayMessageBox("No job loaded")       
      return false;      
   end -- if end
   local selection = job.Selection    
   if selection.IsEmpty then  
      MessageBox("Please select one or more vectors to label")        
      return false       
   end 



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