CadLayer: Difference between revisions
No edit summary |
|||
| (24 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
===.Colour=== | ===.Colour=== | ||
'''Interaction:''' ''' | '''Interaction:''' Read and Write | ||
'''Returns:''' 32 bit (integer) get or set the colour for a layer as a COLORREF (32 bit colour value) | |||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> | <nowiki> | ||
local job = VectricJob() | |||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
local Col1 = layer.Color | |||
if Col1 then | |||
fileW:write("Layer Name = " .. tostring( Col1) .. "\n") | |||
else | |||
fileW:write("Layer Name = Not Found \n") | |||
end | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.Color=== | |||
'''Interaction:''' Read and Write | |||
'''Returns:''' 32 bit (integer) get or set the Color for a layer as a COLORREF (32 bit Color value) | |||
''' | |||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> | <nowiki> | ||
local job = VectricJob() | |||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
local Col1 = layer.Color | |||
if Col1 then | |||
fileW:write("Layer Name = " .. tostring( Col1) .. "\n") | |||
else | |||
fileW:write("Layer Name = Not Found \n") | |||
end | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.Count=== | ===.Count=== | ||
| Line 31: | Line 57: | ||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> function | <nowiki> function LayerCount(job) -- Clears layer if empty | ||
local Mylayer = | local Mylayer = job.LayerManager:GetLayerWithName(LayerName) | ||
if Mylayer.IsEmpty then | if Mylayer.IsEmpty then | ||
Milling.job.LayerManager:RemoveLayer(Mylayer) | Milling.job.LayerManager:RemoveLayer(Mylayer) | ||
| Line 44: | Line 70: | ||
'''Returns:''' (bool) true if this is a bitmap layer. The bitmap layer is used for imported bitmaps and is placed at the start of the layer list so that bitmaps are drawn before vectors. | '''Returns:''' (bool) true if this is a bitmap layer. The bitmap layer is used for imported bitmaps and is placed at the start of the layer list so that bitmaps are drawn before vectors. | ||
'''Example Code:''' | '''''Example Code:''''' | ||
<nowiki> | |||
<nowiki> | local job = VectricJob() | ||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
local Col1 = layer.IsBitmapLayer | |||
if Col1 then | |||
fileW:write("Layer is a Bit Map Layer \n") | |||
else | |||
fileW:write("Layer is not a Bit Map Layer \n") | |||
end | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.IsEmpty=== | ===.IsEmpty=== | ||
| Line 74: | Line 107: | ||
'''Returns:''' (bool) Returns(bool) true if this is a system layer. System layers are used for holding items such as toolpath previews. | '''Returns:''' (bool) Returns(bool) true if this is a system layer. System layers are used for holding items such as toolpath previews. | ||
'''''Example Code:''''' | |||
<nowiki> | '''''Example Code:''''' | ||
<nowiki> | |||
local job = VectricJob() | |||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
local Col1 = layer.IsSystemLayer | |||
if Col1 then | |||
fileW:write("Layer is a Is System Layer \n") | |||
else | |||
fileW:write("Layer is not a System Layer \n") | |||
end | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.Locked=== | ===.Locked=== | ||
'''Interaction:''' Read and Write:(bool) Get or set the locked property for the layer | '''Interaction:''' Read and Write:(bool) Get or set the locked property for the layer | ||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> | |||
<nowiki> | local job = VectricJob() | ||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
local Col1 = layer.Locked | |||
if Col1 then | |||
fileW:write("Layer is a Locked Layer \n") | |||
else | |||
fileW:write("Layer is not a Locked Layer \n") | |||
end | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.Name=== | ===.Name=== | ||
'''Interaction:''' Read and Write:(string) get or set the name for the layer | '''Interaction:''' Read and Write:(string) get or set the name for the layer | ||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> | <nowiki> | ||
local | local job = VectricJob() | ||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
fileW:write("Layer Name = " .. layer.Name .. "\n") | |||
end-- if end | |||
io.close(fileW) </nowiki> | |||
===.Visible=== | ===.Visible=== | ||
| Line 135: | Line 187: | ||
return true | return true | ||
end -- function end </nowiki> | end -- function end </nowiki> | ||
===RawId=== | ===RawId=== | ||
| Line 141: | Line 194: | ||
'''Returns:''' (UUID) The unique identifier for this layer | '''Returns:''' (UUID) The unique identifier for this layer | ||
'''''Example Code:''''' | '''''Example Code:''''' | ||
<nowiki> | <nowiki> | ||
local | local job = VectricJob() | ||
local layer_manager = job.LayerManager | |||
if layer_manager then | |||
local fileW = io.open("C:/temp/Color.log","a") | |||
fileW:write("Color Log " .. "\n") | |||
local layer = job.LayerManager:FindLayerWithName("Black") | |||
fileW:write("Layer RawId =" .. layer.RawId .. "\n") | |||
io.close(fileW) </nowiki> | |||
==Methods== | ==Methods== | ||
Latest revision as of 21:41, 9 May 2024
This object holds all the data for a layer within the application. Layers are created and accessed via the CadLayerManager object. A layer maintains a list of CadObjects.
Properties
.Colour
Interaction: Read and Write
Returns: 32 bit (integer) get or set the colour for a layer as a COLORREF (32 bit colour value)
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
local Col1 = layer.Color
if Col1 then
fileW:write("Layer Name = " .. tostring( Col1) .. "\n")
else
fileW:write("Layer Name = Not Found \n")
end
end-- if end
io.close(fileW)
.Color
Interaction: Read and Write
Returns: 32 bit (integer) get or set the Color for a layer as a COLORREF (32 bit Color value)
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
local Col1 = layer.Color
if Col1 then
fileW:write("Layer Name = " .. tostring( Col1) .. "\n")
else
fileW:write("Layer Name = Not Found \n")
end
end-- if end
io.close(fileW)
.Count
Interaction: Read Only
Returns: (integer) Returns the number of CadObjects present on the layer
Example Code:
function LayerCount(job) -- Clears layer if empty
local Mylayer = job.LayerManager:GetLayerWithName(LayerName)
if Mylayer.IsEmpty then
Milling.job.LayerManager:RemoveLayer(Mylayer)
end -- if end
return true
end -- function end
.IsBitmapLayer
Interaction: Read Only
Returns: (bool) true if this is a bitmap layer. The bitmap layer is used for imported bitmaps and is placed at the start of the layer list so that bitmaps are drawn before vectors.
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
local Col1 = layer.IsBitmapLayer
if Col1 then
fileW:write("Layer is a Bit Map Layer \n")
else
fileW:write("Layer is not a Bit Map Layer \n")
end
end-- if end
io.close(fileW)
.IsEmpty
Interaction: Read Only
Returns: (bool) true if the layer has no objects on it.
Example Code:
function MyLayerClear(LayerName) -- Clears layer if empty
local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName)
if Mylayer.IsEmpty then
Milling.job.LayerManager:RemoveLayer(Mylayer)
end -- if end
return true
end -- function end
.IsSystemLayer
Interaction: Read Only
Returns: (bool) Returns(bool) true if this is a system layer. System layers are used for holding items such as toolpath previews.
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
local Col1 = layer.IsSystemLayer
if Col1 then
fileW:write("Layer is a Is System Layer \n")
else
fileW:write("Layer is not a System Layer \n")
end
end-- if end
io.close(fileW)
.Locked
Interaction: Read and Write:(bool) Get or set the locked property for the layer
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
local Col1 = layer.Locked
if Col1 then
fileW:write("Layer is a Locked Layer \n")
else
fileW:write("Layer is not a Locked Layer \n")
end
end-- if end
io.close(fileW)
.Name
Interaction: Read and Write:(string) get or set the name for the layer
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
fileW:write("Layer Name = " .. layer.Name .. "\n")
end-- if end
io.close(fileW)
.Visible
Interaction: Read and Write:(bool) Get or set the visible property for the layer
Example Code:
function MyLayerVisible(LayerName) -- Checks to see if layer is visible
local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName)
if Mylayer.Visible then
return true
end -- if end
return false
end -- function end
.Id
Interaction: Read Only
Returns: luaUUID (Id of this layer)
Example Code:
function MyLayerClear(LayerName) -- Clears layer if empty
local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName)
if Mylayer.IsEmpty then
Milling.job.LayerManager:RemoveLayer(Mylayer)
end -- if end
return true
end -- function end
RawId
Interaction: Read Only
Returns: (UUID) The unique identifier for this layer
Example Code:
local job = VectricJob()
local layer_manager = job.LayerManager
if layer_manager then
local fileW = io.open("C:/temp/Color.log","a")
fileW:write("Color Log " .. "\n")
local layer = job.LayerManager:FindLayerWithName("Black")
fileW:write("Layer RawId =" .. layer.RawId .. "\n")
io.close(fileW)
Methods
:AddObject( CadObject object, bool on_current_sheet)
Add passed object to this layer object (CadObject) the object (contour) to add to layer object becomes property of layer on_current_sheet(bool) this should always be true, and the object is created on the current sheet. If false the sheet from the object would be retained, but as this sheet property is not controllable from Lua, false should not be used in normal operation.
:Find( UUID id)
Returns: the position in the list for the object with the passed id. If no object is found the returned position is nil
- id (UUID) id for object
:GetHeadPosition()
Returns: (POSITION) a variable to allow access to the head of the list of objects on layer
:GetTailPosition()
Returns: (POSITION) a variable to allow access to the tail of the list of objects on layer
:GetNext( POSITION pos)
Returns: Both 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 (POSTION) current position in list
:GetPrev( POSITION pos)
Returns: Both 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 (POSTION) current position in list
:GetAt( POSITION pos)
Returns: the object at the passed position
- pos (POSTION) position in list
:RemoveObject( CadObject object)
Removes passed object from this layer. Object becomes property of the script. Object removed or nil if object was not found on layer.
- Object (CadObject) the object (contour) to remove from layer object becomes property of caller
:RemoveAt( POSITION pos)
Removes the CadObject at the passed position and Returns it.
- pos (POSTION) position in list
:SetColour( double red, double green, double blue)
Set the colour for the layer
- red(double) red component of colour in range 0.0 to 1.0
- green(double) green component of colour in range 0.0 to 1.0
- blue(double) blue component of colour in range 0.0 to 1.0
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