MaterialBlock
This object represents the material block within the program. It holds the width, height and thickness of the job and also the XY and Z origins. There is a single instance of the material block in the program. A number of methods are provided to covert between ?absolute? z values and z values relative to the surface of the material. These are very useful what writing scripts for toolpath generation as scripts need to take account of the fact that the user may change between Z0 on the machine representing the bottom of the material or the top of the material.
Constructor
MaterialBlock()
A new object which refers to the single material block within the program.
For Example:
local mtl_block = MaterialBlock()
Properties
.ActualXYOrigin
Interaction: Read Only
Returns: (Point2D) XY position for user specified origin position on material (see .XY origin)
.BlcOrigin
Interaction: Read Only
Returns: (Point3D) XYZ position for bottom left corner of material block
.Height
Interaction: Read Only
Returns: (double) height of material (length in Y)
.InMM
Interaction: Read Only
Returns: (bool) true if the job or job is in MM else it is in inches
.MaterialBox
Interaction: Read Only
Returns: (Box3D) the 3D bounding box for the material
.MaterialSurfaceZ
Interaction: Read Only
Returns: (double) Z value for surface of material
.Thickness
Interaction: Read Only
Returns: (double) thickness of material (length in Z)
Example
local mtl_block = MaterialBlock() local mtl_thick = mtl_block.Thickness
.Width
Interaction: Read Only
Returns: (double) width of material (length in X)
.CylinderDiameter
Interaction: Read Only
Returns: (double) (Rotary Only) the diameter of the material cylinder
.CylinderLength
Interaction: Read Only
Returns: (double) (Rotary Only) the length of the material cylinder
.XYOrigin
Interaction: Read Only
Returns: (XYOrigin) Value indicating position in material chosen as XY origin
Valid values are:
MaterialBlock.BLC - Bottom Left Corner of material MaterialBlock.BRC - Bottom Right Corner of material MaterialBlock.TRC - Top Right Corner of material MaterialBlock.TLC - Top Left Corner of material MaterialBlock.CENTRE - Centre of material (Note British spelling!) -------------------------------------------------------------------- if Material.XYorigin == "Bottom Right Corner" then ... elseif Material.XYorigin == "Top Right Corner" then ... elseif Material.XYorigin == "Top Left Corner" then ... elseif Material.XYorigin == "Bottom Left Corner" then ... elseif Material.XYorigin == "CENTRE" then ... else -- No Match Found Error message ... end
.ZOrigin
Interaction: Read Only
Returns: (ZOrigin) Value indicating position of Z origin.
Valid values are:
MaterialBlock.Z_TOP MaterialBlock.Z_CENTRE MaterialBlock.Z_BOTTOM
.FlipDirection
Interaction: Read and Write
Returns: FlipDirection (Double-Sided Only) Values indicating how we flip the material in a two-sided job.
Valid values are:
VectricJob.AROUND_X VectricJob.AROUND_Y Note: This can be used for creating a two sided job through CreateNew2SidedJob()
.JobType
Interaction: Read and Write
Returns: (JobType) Values indicating the value of the current job.
Valid values are:
MaterialBlock.SINGLE_SIDED MaterialBlock.DOUBLE_SIDED MaterialBlock.ROTARY
.RotationAxis
Interaction: Read Only
Returns: RotationAxis (Rotary Only) Values indicating the rotation axis of the cylinder.
Valid values are:
MaterialBlock.X_AXIS MaterialBlock.Y_AXIS
Methods
:CalcAbsoluteZ( double z_value)
Returns: an absolute
z value from a z value relative to the surface of the block. Z_value can be -ve for values below the surface or +ve for values above the surface.
z_value(double) z value relative to surface of material
:CalcAbsoluteZFromDepth( double z_value)
Returns: a depth value below the surface from an absolute z value. z_value(double) absolute z value.
:CalcDepthFromAbsoluteZ( double z_value)
Returns: a depth below the surface of the material from an absolute z value. z_value (double) Absolute z value
:SideZOrigin( UUID side_id)
Similar to .ZOrigin, but for the given side
:SideMaterialSurfaceZ( UUID side_id)
Similar to .MaterialSurfaceZ for the given side
:SideMaterialBox( UUID side_id)
Similar to .MaterialBox for the given side
:SideBlcOrigin( UUID side_id)
Similar to .BlcOrigin for the given side
:CalcSideAbsoluteZ( UUID side_id)
Similar to:CalAbsoluteZ() for the given side
:CalcSideDepthFromAbsoluteZ( UUID side_id)
Similar to:CalcDepthFromAbsoluteZ() for the given side
:CalcSideAbsoluteZFromDepth( UUID side_id)
Similar to:CalcAbsoluteZFromDepth() for the given side
Example Code:
-- VECTRIC LUA SCRIPT -- require("mobdebug").start() -- debugging function with ZeroBrane Studio require "strict" --[[ ------------------- DisplayMaterialSettings ------------------------------ | | Display information about the size and position etc of the material block | | | Return Values: ]] function DisplayMaterialSettings() local mtl_block = MaterialBlock() local units if mtl_block.InMM then units = " mm" else units = " inches" end -- Display material XY origin local xy_origin_text = "invalid" local xy_origin = mtl_block.XYOrigin if xy_origin == MaterialBlock.BLC then xy_origin_text = "Bottom Left Corner" elseif xy_origin == MaterialBlock.BRC then xy_origin_text = "Bottom Right Corner" elseif xy_origin == MaterialBlock.TRC then xy_origin_text = "Top Right Corner" elseif xy_origin == MaterialBlock.TLC then xy_origin_text = "Top Left Corner" elseif xy_origin == MaterialBlock.CENTRE then -- NOTE:British spelling for Centre! xy_origin_text = "Centre" else xy_origin_text = "Unknown XY origin value!" end local z_origin_text = "invalid" local z_origin = mtl_block.ZOrigin if z_origin == MaterialBlock.Z_TOP then z_origin_text = "Top of Material" elseif z_origin == MaterialBlock.Z_CENTRE then -- NOTE:British spelling for Centre! z_origin_text = "Centre of Material" elseif z_origin == MaterialBlock.Z_BOTTOM then z_origin_text = "Bottom of Material" else z_origin_text = "Unknown Z origin value!" end local xy_origin_pos = mtl_block.ActualXYOrigin -- get 3d box object describing material bounds. local mtl_box = mtl_block.MaterialBox local mtl_box_blc = mtl_box.BLC -- test methods to conver z values between absolute z and relative depths local test_val = 0.125 local depth = mtl_block:CalcDepthFromAbsoluteZ(test_val) local abs_z = mtl_block:CalcAbsoluteZFromDepth(test_val) DisplayMessageBox( "Width = " .. mtl_block.Width .. units .. "\n" .. "Height = " .. mtl_block.Height .. units .. "\n" .. "Thickness = " .. mtl_block.Thickness .. units .. "\n\n" .. "XY Origin = " .. xy_origin_text .. "\n" .. " Position = (" .. xy_origin_pos.x .. ", " .. xy_origin_pos.y .. ")\n" .. "Z Origin = " .. z_origin_text .. "\n\n" .. "Box Width = " .. mtl_box.XLength .. units .. "\n" .. "Box Height = " .. mtl_box.YLength .. units .. "\n" .. "Box Thickness = " .. mtl_box.ZLength .. units .. "\n" .. "Box Bottom Left Corner = (" .. mtl_box_blc.x .. "," .. mtl_box_blc.y .. "," .. mtl_box_blc.z .. ")\n\n" .. "Test Value = " .. test_val .. "\n" .. "Depth from absolute test value = " .. depth .. "\n" .. "Absolute Z from depth test value = " .. abs_z .. "\n\n" ) end --[[ --------- main --------------------------------- | Test the out come | | Entry point for script ]] function main() -- Check we have a job loaded local job = VectricJob() if not job.Exists then DisplayMessageBox("No job loaded") return false end DisplayMaterialSettings() return true end
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