CadSheetManager: Difference between revisions

From SDK
Jump to navigation Jump to search
(Created page with " right|50px|link=High Level Objects Category:SDK This object is responsible for managing all the sheets within the applica􀆟on. A reference to the CadSheetManager is obtained via the SheetManager property of the VectricJob. The CadSheetManager maintains a list of all the sheet ids in the job. ==Properties== ===.ActiveSheetId === '''Read / Write''' UUID - Get the id of the active sheet. Set this value to the id of a different sheet to change the...")
 
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 11: Line 11:
'''Read / Write''' UUID - Get the id of the active sheet. Set this value to the id of a different sheet to change the
'''Read / Write''' UUID - Get the id of the active sheet. Set this value to the id of a different sheet to change the
active sheet.
active sheet.


===.NumberOfSheets===
===.NumberOfSheets===
'''Read Only'''  Integer- returns the number of sheets in the job.
'''Read Only'''  Integer- returns the number of sheets in the job.


'''''Example Code:'''''
Returns the number of sheets
<nowiki>function SheetCount()                                 
  local job = VectricJob()
  local sheet_manager = job.SheetManager
  return sheet_manager.NumberOfSheets
end -- function end</nowiki>


==Methods==
==Methods==
Line 22: Line 31:
Create num_sheets new sheets with the same properties as the sheet with id sheet_id.
Create num_sheets new sheets with the same properties as the sheet with id sheet_id.


'''num_sheets''' - integer - the number of new sheets to add to the job.
::''num_sheets - integer - the number of new sheets to add to the job.''
 
::''sheet_id - UUID - the id of the sheet that the new sheets should take their properties from (e.g. dimensions, Z Zero Posi􀆟on etc.).''
'''sheet_id''' - UUID - the id of the sheet that the new sheets should take their properties from
(e.g. dimensions, Z Zero Posi􀆟on etc.).
 
::''Layer_name (string) Name for layer''
 
===: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:''
 
'''Usage: GetNext()'''
<nowiki>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)===
'''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. 
===:CreateSheets:(integer num_sheets, UUID sheet_id, Box2D material_bounds)===
Create num_sheets new sheets with the same properties as the sheet with id sheet_id but with
width and height defined by material_bounds.


::''num_sheets - integer - the number of new sheets to add to the job.''
::''sheet_id - UUID - the id of the sheet that the new sheets should take their properties from.''
::''material_bounds - Box2D - the width and height dimensions for the new sheets.''


===:GetSheetIds()===
'''Returns:''' Lua iterator that can be used to iterate over all of the sheet ids in the job (see example
below).


===: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''
===:GetSheetName(UUID sheet_id)===
'''Returns:''' name of the sheet with the passed id as a string.


== Example Code: ==
::''sheet_id - UUID - the method will return the name of the sheet with this id.''


  <nowiki>--[[
'''''Example Code:'''''
  ]]
  <nowiki>-- =====================================================]]
   function SetBitmapBrightness(job, brightness)
  function SheetSet(Name)                                -- Move focus to a named sheet
     if not job.Exists then
    local job = VectricJob()
      DisplayMessageBox("No job loaded")
    local sheet_manager = job.SheetManager
      return false
    local sheet_ids = sheet_manager:GetSheetIds()
    for id in sheet_ids do
      if(sheet_manager:GetSheetName(id) == Name) then
        sheet_manager.ActiveSheetId = id
      end -- if end
    end -- for end
  end -- function end
  -- =====================================================]]
   function SheetNextSize(Name, X, Y)                            -- Make New Sheet to size (x, y)
    if X == nil then
      X = Milling.MaterialBlockWidth
    else
      X = X + (2 * Milling.Cal)
    end -- function end
     if Y == nil then
      Y = Milling.MaterialBlockHeight
    else
      Y = Y + (2 * Milling.Cal)
    end -- function end
    Milling.Sheet = Milling.Sheet + 1
    local sheet_manager = Milling.job.SheetManager
    local sheet_ids = sheet_manager:GetSheetIds()
    for id in sheet_ids do
      if(sheet_manager:GetSheetName(id) == "Sheet 1") then
        sheet_manager:CreateSheets(1, id, Box2D(Point2D(0, 0), Point2D(X, Y)))
      end -- function end
     end
     end
     local layer_manager = job.LayerManager
     SheetSet(Name)
    local pos = layer_manager:GetHeadPosition()
     return true
     while pos ~= nil do
  end -- function end
      local layer
-- =====================================================]]</nowiki>
          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()  </nowiki>


[[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 11.0, published October 18, 2011. 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 13:26, 9 May 2024

Back.jpg

This object is responsible for managing all the sheets within the applica􀆟on. A reference to the CadSheetManager is obtained via the SheetManager property of the VectricJob. The CadSheetManager maintains a list of all the sheet ids in the job.

Properties

.ActiveSheetId

Read / Write UUID - Get the id of the active sheet. Set this value to the id of a different sheet to change the active sheet.


.NumberOfSheets

Read Only Integer- returns the number of sheets in the job.

Example Code:

Returns the number of sheets
function SheetCount()                                   
  local job = VectricJob()
  local sheet_manager = job.SheetManager
  return sheet_manager.NumberOfSheets
end -- function end

Methods

:CreateSheets:(integer num_sheets, UUID sheet_id)

Create num_sheets new sheets with the same properties as the sheet with id sheet_id.

num_sheets - integer - the number of new sheets to add to the job.
sheet_id - UUID - the id of the sheet that the new sheets should take their properties from (e.g. dimensions, Z Zero Posi􀆟on etc.).


:CreateSheets:(integer num_sheets, UUID sheet_id, Box2D material_bounds)

Create num_sheets new sheets with the same properties as the sheet with id sheet_id but with width and height defined by material_bounds.

num_sheets - integer - the number of new sheets to add to the job.
sheet_id - UUID - the id of the sheet that the new sheets should take their properties from.
material_bounds - Box2D - the width and height dimensions for the new sheets.

:GetSheetIds()

Returns: Lua iterator that can be used to iterate over all of the sheet ids in the job (see example below).


:GetSheetName(UUID sheet_id)

Returns: name of the sheet with the passed id as a string.

sheet_id - UUID - the method will return the name of the sheet with this id.

Example Code:

-- =====================================================]]
  function SheetSet(Name)                                 -- Move focus to a named sheet
    local job = VectricJob()
    local sheet_manager = job.SheetManager
    local sheet_ids = sheet_manager:GetSheetIds()
    for id in sheet_ids do
      if(sheet_manager:GetSheetName(id) == Name) then
        sheet_manager.ActiveSheetId = id
      end -- if end
    end -- for end 
  end -- function end 
  -- =====================================================]]
  function SheetNextSize(Name, X, Y)                            -- Make New Sheet to size (x, y)
    if X == nil then
      X = Milling.MaterialBlockWidth
    else
      X = X + (2 * Milling.Cal)
    end -- function end
    if Y == nil then
      Y = Milling.MaterialBlockHeight
    else
      Y = Y + (2 * Milling.Cal)
    end -- function end
    Milling.Sheet = Milling.Sheet + 1
    local sheet_manager = Milling.job.SheetManager
    local sheet_ids = sheet_manager:GetSheetIds()
    for id in sheet_ids do
      if(sheet_manager:GetSheetName(id) == "Sheet 1") then
        sheet_manager:CreateSheets(1, id, Box2D(Point2D(0, 0), Point2D(X, Y)))
      end -- function end
    end
    SheetSet(Name)
    return true
  end -- function end
-- =====================================================]]
Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 11.0, published October 18, 2011. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information