CadLayerManager: Difference between revisions
(Created page with " right|50px|link=High Level Objects Category:SDK This object is responsible for managing all the layers within the application. A reference to the CadLay...") |
|||
| (13 intermediate revisions by the same user not shown) | |||
| Line 26: | Line 26: | ||
::''Layer_name (string) Name for layer'' | ::''Layer_name (string) Name for layer'' | ||
'''''Example Code:''''' | |||
<nowiki> local layer = job.LayerManager:FindLayerWithName(layer_name) </nowiki> | |||
===:GetActiveLayer()=== | ===:GetActiveLayer()=== | ||
| Line 55: | Line 59: | ||
::'''''Note:''''' ''GetNext(pos) is returning two values:'' | ::'''''Note:''''' ''GetNext(pos) is returning two values:'' | ||
''' | '''''Example Code:''''' | ||
<nowiki>local pos = layer_manager:GetHeadPosition() | <nowiki> | ||
local job = VectricJob() | |||
local layer_manager = job.LayerManager | |||
local pos = layer_manager:GetHeadPosition() | |||
local layer | |||
while pos ~= nil do | |||
layer, pos = layer_manager:GetNext(pos) | |||
DO SOMETHING WITH LAYER:. | |||
end -- while end </nowiki> | |||
===:GetPrev(POSITION pos)=== | ===:GetPrev(POSITION pos)=== | ||
| Line 70: | Line 77: | ||
===:GetTailPosition()=== | ===:GetTailPosition()=== | ||
'''Returns:''' (POSITION) a variable to allow access to the tail of the list of layers | '''Returns:''' (POSITION) a variable to allow access to the tail of the list of layers | ||
===:HaveDataOnSheets() === | |||
Returns true if there is data on more than one sheet. | |||
===:RemoveLayer(CadLayer layer) === | |||
Remove the passed layer object from the list of layers in the job. | |||
Layer - CadLayer - layer to remove from the job. | |||
===:SetActiveLayer(CadLayer layer)=== | ===:SetActiveLayer(CadLayer layer)=== | ||
| Line 76: | Line 93: | ||
::''Layer (CadLayer) layer to be made the active layer'' | ::''Layer (CadLayer) layer to be made the active layer'' | ||
'''''Example Code:''''' | |||
<nowiki> | <nowiki> function SetBitmapBrightness(job, brightness) | ||
if not job.Exists then | if not job.Exists then | ||
DisplayMessageBox("No job loaded") | DisplayMessageBox("No job loaded") | ||
| Line 109: | Line 124: | ||
[[File:Back.jpg|right|50px|link=High Level Objects]] | [[File:Back.jpg|right|50px|link=High Level Objects]] | ||
==References== | ==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 [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] | '''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 [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] | ||
Latest revision as of 18:29, 10 May 2024
This object is responsible for managing all the layers within the application. A reference to the CadLayerManager is obtained via the LayerManager property of the VectricJob. The CadLayerManager maintains a list of all the CadLayers in the job.
Properties
.Count
Interaction: Read Only
Returns: (integer) the number of layers being managed
.IsEmpty
Interaction: Read Only
Returns: (bool) true if there are no layers else false
Methods
:FindLayerWithName(string layer_name)
Returns: (string or nil) the CadLayer with passed name. If no layer exists with the passed name it returns nil
- Layer_name (string) Name for layer
Example Code:
local layer = job.LayerManager:FindLayerWithName(layer_name)
:GetActiveLayer()
Returns: the current active CadLayer. If no layer exists Returns nil
:GetAt(POSITION pos)
Returns: the layer at the passed position
- pos (POSTION) current position in list
:GetHeadPosition()
Returns: (POSITION) a variable to allow access to the head of the list of layers
:GetLayerWithName(string layer_name)
Returns: the CadLayer with passed name. If no layer exists with the passed name a new layer is created
:GetLayerWithId(UUID layer_id)
Returns: the CadLayer with passed id. The id is usually obtained from the .RawLayerId property of a CadObject
:GetNext(POSITION pos)
Returns: Both the layer 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 (POSTION) current position in list
- Note: GetNext(pos) is returning two values:
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
local pos = layer_manager:GetHeadPosition()
local layer
while pos ~= nil do
layer, pos = layer_manager:GetNext(pos)
DO SOMETHING WITH LAYER:.
end -- while end
:GetPrev(POSITION pos)
Returns: the layer 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 (POSTION) current position in list
:GetTailPosition()
Returns: (POSITION) a variable to allow access to the tail of the list of layers
:HaveDataOnSheets()
Returns true if there is data on more than one sheet.
:RemoveLayer(CadLayer layer)
Remove the passed layer object from the list of layers in the job.
Layer - CadLayer - layer to remove from the job.
:SetActiveLayer(CadLayer layer)
Sets passed layer to be the current active layer. If passed layer is nil, sets first layer to be active.
- Layer (CadLayer) layer to be made the active layer
Example Code:
function SetBitmapBrightness(job, brightness)
if not job.Exists then
DisplayMessageBox("No job loaded")
return false
end
local layer_manager = job.LayerManager
local pos = layer_manager:GetHeadPosition()
while pos ~= nil do
local layer
layer, pos = layer_manager:GetNext(pos)
if not layer.IsSystemLayer then
local layer_pos = layer:GetHeadPosition()
while layer_pos ~= nil do
local object
object, layer_pos = layer:GetNext(layer_pos)
if object.ClassName == "vcCadBitmap" then
cad_bitmap = CastCadObjectToCadBitmap(object)
MessageBox("Found bitmap - brightess = " .. cad_bitmap.Brightness)
cad_bitmap.Brightness = brightness
cad_bitmap.Visible = visible
end -- if end
end -- while end
end -- if end
end -- while end of for each object on layer
end -- function end of for each layer
job:Refresh2DView()
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