CadLayer: Difference between revisions
Line 108: | Line 108: | ||
<nowiki> function MyLayerClear(LayerName) -- Clears layer if empty | <nowiki> function MyLayerClear(LayerName) -- Clears layer if empty | ||
local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName) | local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName) | ||
if Mylayer. | if Mylayer.Visible then | ||
return true | |||
end -- if end | end -- if end | ||
return | return false | ||
end -- function end </nowiki> | end -- function end </nowiki> | ||
===.Id=== | ===.Id=== |
Revision as of 19:09, 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)
.Count
Interaction: Read Only
Returns: (integer) Returns the number of CadObjects present on 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
.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:
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
.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:
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
.Locked
Interaction: Read and Write:(bool) Get or set the locked property for the layer
Example Code:
function MyLayerLocked(LayerName) -- Test to see if layer is locked local Mylayer = Milling.job.LayerManager:GetLayerWithName(LayerName) if Mylayer.Locked then return true end -- if end return false end -- function end
.Name
Interaction: Read and Write:(string) get or set the name 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
.Visible
Interaction: Read and Write:(bool) Get or set the visible property for the layer
Example Code:
function MyLayerClear(LayerName) -- Clears layer if empty 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:
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
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