CadLayer: Difference between revisions

From SDK
Jump to navigation Jump to search
(Created page with " right|50px|link=High Level Objects Category:SDK This object holds all the data for a layer within the application. Layers are created and accessed via t...")
 
 
(57 intermediate revisions by the same user not shown)
Line 7: Line 7:


===.Colour===
===.Colour===
'''Interaction:''' '''Interaction:''' Read and Write 32 bit (integer) get or set the colour for a layer as a COLORREF  (32 bit colour value)
'''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:'''''
<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===
===.Color===
'''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!
'''Interaction:''' Read and Write  


'''Sample Code'''
'''Returns:''' 32 bit (integer) get or set the Color for a layer as a COLORREF (32 bit Color value)
  <nowiki>function MakeLayers()
 
  local job = VectricJob()
'''''Example Code:'''''
   if not(job.Exists) then
  <nowiki>
     DisplayMessageBox("Error: The Gadget cannot run without a job being setup.\n" ..
  local job = VectricJob()
                      "Select: 'Create a new file' under 'Startup Tasks' and \n" ..
   local layer_manager = job.LayerManager
                      "specify the material dimensions")
  if layer_manager then
     return false ;
     local fileW = io.open("C:/temp/Color.log","a")
  end
    fileW:write("Color Log " .. "\n")
  local layer = job.LayerManager:GetLayerWithName("Text")
     local layer = job.LayerManager:FindLayerWithName("Black")
        layer:SetColor (0.0, 1.0, 0.0)   -- Green
    local Col1 = layer.Color
        layer = job.LayerManager:GetLayerWithName("Handle")
    if Col1 then
        layer:SetColor (0.0, 0.0, 1.0)   -- Blue
      fileW:write("Layer Name = " .. tostring( Col1) .. "\n")
   return true
    else
end</nowiki>
      fileW:write("Layer Name = Not Found \n")
    end
   end-- if end
   io.close(fileW) </nowiki>


===.Count===
===.Count===
Line 34: Line 55:
'''Returns:''' (integer) Returns the number of CadObjects present on the layer
'''Returns:''' (integer) Returns the number of CadObjects present on the layer


'''''Example Code:'''''
<nowiki> 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 </nowiki>


===.IsBitmapLayer===
===.IsBitmapLayer===
Line 40: 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:'''''
<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 46: Line 92:
'''Returns:''' (bool) true if the layer has no objects on it.
'''Returns:''' (bool) true if the layer has no objects on it.


'''''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>


===.IsSystemLayer===
===.IsSystemLayer===
Line 52: 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>
  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:'''''
<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:'''''
<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")
    fileW:write("Layer Name = " .. layer.Name .. "\n")
  end-- if end
  io.close(fileW) </nowiki>


===.Visible===
===.Visible===
'''Interaction:''' Read and Write:(bool) Get or set the visible property for the layer
'''Interaction:''' Read and Write:(bool) Get or set the visible property for the layer


'''''Example Code:'''''
<nowiki> 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 </nowiki>


===.Id===
===.Id===
Line 69: Line 177:


'''Returns:''' luaUUID  (Id of this layer)
'''Returns:''' luaUUID  (Id of this 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>




Line 75: Line 193:


'''Returns:''' (UUID) The unique identifier for this layer
'''Returns:''' (UUID) The unique identifier for this layer
'''''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")
    fileW:write("Layer RawId =" .. layer.RawId .. "\n")
  io.close(fileW)  </nowiki>


==Methods==
==Methods==
Line 118: Line 247:


::''Object (CadObject) the object (contour) to remove from layer object becomes property of caller''
::''Object (CadObject) the object (contour) to remove from layer object becomes property of caller''


===:RemoveAt( POSITION pos)===
===:RemoveAt( POSITION pos)===
Line 133: Line 263:




===:SetColor (double red,  double green,  double blue)===
Set the color for the layer (U.S spelling)


::''red(double) <span style="color: red;>'''red'''</span> component of colour in range 0.0 to 1.0''
[[File:Back.jpg|right|50px|link=High Level Objects]]
::''green(double) <span style="color: green;>'''green'''</span> component of colour in range 0.0 to 1.0''
::''blue(double) <span style="color: blue;>'''blue'''</span> component of colour in range 0.0 to 1.0''


[[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 20:41, 9 May 2024

Back.jpg

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


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