Share

Slice time calculation

Properties

Property Read/write Type Description
lasercount read number For how many lasers there are vectors present in the current slice layer
marktime read number Time occupied by exposing vectors based on mark speed
jumptime read number Time occupied by jumping between consecutive vectors based on jump speed
markstartdelay, markenddelay read number Time given to deflection system to account for beam switching
polygondelay read number Time given to deflection system to change beam direction
markstartevents, markendevents, polygonevents read number Counts how often the respective events appear in the current layer
totaltime read number Sum of all involved times for the current layer

If not set otherwise, Netfabb calculates with a mark speed and jump speed of 100 m/s. These parameters are not available as properties for the slice time calculation object, only as properties of the slice object itself.

Back to top

Methods

Property Syntax Description
setlayer setlayer(number) Specifies the layer to calculate
nextlaser nextlaser() Sets calculation pointer to the next laser; returns boolean; false indicates that there was no next laser to point to

Back to top

Example

This example is also available as <Netfabb installation folder>Examples\Lua\SliceCommanderScript6_TimeCalculationAndVisualization.lua.

dialog = nil;
dialog_image = nil;
graphdrawer = nil;

LINE_NONE              = 0;
LINE_SMOOTH            = 1;
LINE_EXACT             = 2;

NODE_NONE              = 0;
NODE_CIRCLE            = 1;
NODE_QUAD              = 2;
NODE_DIAMOND           = 3;

MODIFY_NO              = 0;
MODIFY_ON_DEFAULT      = 1;
MODIFY_ON_SHIFT        = 2;
MODIFY_ON_CTRL         = 4;
MODIFY_ON_SHIFT_CTRL   = 8;

function CalculateTiming()
    -- create draw object
    graphdrawer = system:creategraphdrawer();
    graphdrawer.title = 'Slice Timing';
    graphdrawer.caption_x = 'Layer';
    graphdrawer.caption_y = 'Duration';
    graphdrawer.unit_x = '#';
    graphdrawer.unit_y = 's';
    graphdrawer.formatter_x = '#\%.f';
    graphdrawer.formatter_y = '\%.1f s';
    graphdrawer.grid_space_x = 100;
    graphdrawer.grid_space_y = 20;
    graphdrawer.font_size = system.fontsize;
    graphdrawer.margin = 60;
    graphdrawer.margin_right = 80;
    graphdrawer.margin_bottom = 130;
    graphdrawer.padding = 25;
    graphdrawer.border = 2;
    graphdrawer.grid = 1;
    graphdrawer.color_background = 0xFFFFFF;
    graphdrawer.modify_x = MODIFY_ON_DEFAULT + MODIFY_ON_SHIFT_CTRL;
    graphdrawer.modify_y = MODIFY_ON_CTRL + MODIFY_ON_SHIFT_CTRL;

    dataset_total = graphdrawer:adddataset();
    dataset_total.legend = 'Total';
    dataset_total.line_type = LINE_EXACT;
    dataset_total.node_type = NODE_NONE;
    dataset_total.line_size = 3;
    dataset_total.color_line = 0x888888;

    local calculator = slicetray:createtimecalculation();
    local dataset_lasers = {}
    for i=0, slicetray.layercount-1 do
        calculator:setlayer(i);
        local total = 0;
        local laser = 1;
        repeat
            local dataset_marktime = dataset_lasers[laser*2 + 0]
            if dataset_marktime == nil then
                dataset_marktime = graphdrawer:adddataset();
                dataset_marktime.legend = 'Mark Time ' .. laser;
                dataset_marktime.line_type = LINE_EXACT;
                dataset_marktime.node_type = NODE_NONE;
                dataset_marktime.line_size = 3;
                dataset_marktime.color_line = 0x880000 + 0x202020 * laser;
                dataset_lasers[laser*2 + 0] = dataset_marktime;
            end;
            dataset_marktime:addvalue(i, calculator.marktime);

            local dataset_jumptime = dataset_lasers[laser*2 + 1]
            if dataset_jumptime == nil then
                dataset_jumptime = graphdrawer:adddataset();
                dataset_jumptime.legend = 'Jump Time ' .. laser;
                dataset_jumptime.line_type = LINE_EXACT;
                dataset_jumptime.node_type = NODE_NONE;
                dataset_jumptime.line_size = 3;
                dataset_jumptime.color_line = 0x008800 + 0x202020 * laser;
                dataset_lasers[laser*2 + 1] = dataset_jumptime;
            end;
            dataset_jumptime:addvalue(i, calculator.jumptime);
            total = math.max(total, calculator.totaltime);
            laser = laser + 1;
        until(not calculator:nextlaser())
        dataset_total:addvalue(i, total);
    end;
end;

function DoDraw ()
    -- render into generic image object
    local graph_image = graphdrawer:draw(dialog_image.width, dialog_image.height);

    -- save to disk
    -- graph_image:saveto('D:/Temp/SliceTimingPlot.png');

    -- show result in dialog
    dialog_image:setimage(graph_image);
end;

function DoCancel ()
    system:log('close');
    dialog:close (false);
end;

function ShowDialog ()
    dialog = application:createdialog ();
    dialog.caption = "Slice Timing"
    dialog.width = 700;
    dialog.translatecaption = false;

    dialog_image = dialog:addimage();
    dialog_image.width = 695;
    dialog_image.height = 500;

    button = dialog:addbutton ();
    button.caption = "Close";
    button.translate = false;
    button.onclick = "DoCancel";

    CalculateTiming();
    DoDraw();
    dialog_image:setmousehandler(graphdrawer);
    if dialog:show () then
        return true;
    end;
    return false;
end;

system:setloggingtooglwindow(true);
ShowDialog ()

Was this information helpful?