CadLayer: Difference between revisions
Line 71: | Line 71: | ||
'''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: == | |||
<nowiki> 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 </nowiki> | |||
===.Name=== | ===.Name=== |
Revision as of 18:56, 31 January 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: Interaction: Read and Write 32 bit (integer) get or set the colour for a layer as a COLORREF (32 bit colour value)
Example Code:
layer = Milling.job.LayerManager:GetLayerWithName(Milling.LNToeDrawerPocket .. What) Red, Green, Blue = GetColor(Milling.LNToeDrawerPocketColor) layer:SetColor (Red, Green, Blue)
Example Code:
Interaction: Interaction: Read and Write 32 bit (integer) get or set the colour for a layer as a COLORREF (32 bit colour value) this is the U.S spelling version of the method above!
Sample Code
function MakeLayers() local job = VectricJob() if not(job.Exists) then DisplayMessageBox("Error: The Gadget cannot run without a job being setup.\n" .. "Select: 'Create a new file' under 'Startup Tasks' and \n" .. "specify the material dimensions") return false ; end local layer = job.LayerManager:GetLayerWithName("Text") layer:SetColor (0.0, 1.0, 0.0) -- Green layer = job.LayerManager:GetLayerWithName("Handle") layer:SetColor (0.0, 0.0, 1.0) -- Blue return true end
.Count
Interaction: Read Only
Returns: (integer) Returns the number of CadObjects present on the layer
.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.
.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.
.Locked
Interaction: Read and Write:(bool) Get or set the locked property for the 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
.Name
Interaction: Read and Write:(string) get or set the name for the layer
.Visible
Interaction: Read and Write:(bool) Get or set the visible property for the layer
.Id
Interaction: Read Only
Returns: luaUUID (Id of this layer)
RawId
Interaction: Read Only
Returns: (UUID) The unique identifier for this layer
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