Script36_ScreenshotOfAllParts
-- Lua example for Autodesk Netfabb 2021.0
-- Demonstrates taking an individual screenshot for every part on the current tray
Dialog = application:createdialog()
Dialog.caption = "Screenshots of all parts"
Dialog.translatecaption = false
Groupbox = Dialog:addgroupbox()
Groupbox.caption = "Screenshots of all parts"
Groupbox.translate = false
Edit = Groupbox:addedit()
Edit.captionwidth = 120
Edit.caption = "Output folder:"
Edit.translate = false
Splitter = Groupbox:addsplitter()
Splitter:settoleft()
Button = Splitter:addbutton()
Button.caption = "Save screenshots"
Button.translate = false
Button.onclick = "savescreenshots"
Splitter:settoright()
Button = Splitter:addbutton()
Button.caption = "Close"
Button.translate = false
Button.onclick = "closedialog"
function setVisibility(Visible)
local Root = tray.root
for i = 0, Root.meshcount - 1 do
local Mesh = Root:getmesh(i)
Mesh.visible = Visible
end
end
function savescreenshots()
setVisibility(false)
local Root = tray.root
for i = 0, Root.meshcount - 1 do
local Mesh = Root:getmesh(i)
Mesh.visible = true
Mesh.selected = true
system:zoomto(zoomtoSelected)
Mesh.selected = false
local FileName = Edit.text .. "/screenshot_mesh_" .. tostring(i) .. ".png"
local Options = system:createjson()
Options:loadfromstring(
'{"show_horizontalruler":false,"show_verticalruler":false, "show_labels": false, "show_viewcube": false, "show_coordsystem": false, "show_platform": false, "show_logo": false, "show_gizmo": false }'
)
local Image = system:createscreenshot(1920, 1080, Options)
Image:saveto(FileName)
Mesh.visible = false
end
setVisibility(true)
system:zoomto(zoomtoAllparts)
end
function closedialog()
Dialog:close(false)
end
Dialog:show()