Share

Script25_FeatureDetection.lua

-- Lua example for Autodesk Netfabb 2019.1

-- Demonstrates feature detection method that applies coloring to a mesh for any detected features

-- A "feature" is any surface area segment whose triangles have the space above them interfered with below a certain distance.

system:setloggingtooglwindow(true)

local insertMeshesIntoTable
insertMeshesIntoTable = function(meshgroup, Outtable)
    for mesh_index = 0, meshgroup.meshcount - 1 do
        local traymesh = meshgroup:getmesh(mesh_index)
        table.insert(Outtable, traymesh)
    end
    for group_index = 0, meshgroup.groupcount - 1 do
        subgroup = meshgroup:getsubgroup(group_index)
        insertMeshesIntoTable(subgroup, Outtable)
    end
end

-- Get root meshgroup from tray
root = tray.root

-- Collect meshes in the tray
meshes = {}
insertMeshesIntoTable(root, meshes)

-- Iterate over meshes in tray
for i, traymesh in pairs(meshes) do
    local luamesh = traymesh.mesh
    newMesh = luamesh:dupe()
    local matrix = traymesh.matrix
    newMesh:applymatrix(matrix)
    newMesh:featuredetection(0.5, 1, true)
    newtraymesh = root:addmesh(newMesh, traymesh.name .. " 0.5 mm threshold", tonumber(traymesh.color,16))
end

Was this information helpful?