FlexScan3D User Manual - Version 3.3.4.x
You can copy the following examples into a blank .script file.
This very basic script is all you need to scan.
Scan()
This script uses a loop to do a 360° scan using a rotary and an angle increment of 90° (4 scans).
increment = 90
for i=1,360,increment do
Scan()
RotaryRotate(1, increment)
end
Note that an easier way to accomplish the above example would be to use the Rotary360Scan() function. |
Often, you will want to create a new project before each scan session. To ensure a unique name, you can use the built-in Lua date and time functions from the "os" module. The result is also checked to make sure the project was created.
-- creates a project in the format "2012-03-23[1332532193]"
result = NewProject(os.date("%Y-%m-%d") .. "[" .. os.time() .. "]" )
if not result then
PrintValue( "The project was not created successfully." )
return
end
Here's a more advanced example of running several capture-only scans with a pause in between to allow a user time to change the position of the object before the next scan - useful if a rotary is not available. Afterwards, the script loops through all of the scan groups to process the data and create a mesh. The built-in "os.clock()" function is also used to track the amount of time it took to complete the script.
-- start the timer
startTime = os.clock()
-- enable capture-only mode
Set("Scanning_Generation_Type", 2)
-- capture 10 scans and add them to a list
groupList = NewListString()
for i=1,10 do
result, newGroups = Scan()
-- check to make sure the scan went OK - if not, we stop the script execution
if not result then
-- show a custom error message
PrintValue( "Scan #" .. i .. " failed." )
return
end
-- add the new groups to the list (usually there will only be one, but there could be more for multi-scanner setups)
groupList:AddRange( newGroups )
-- pause for 7 seconds to allow the object to be moved/rotated
Wait(7)
end
-- get the final count of groups
groupCount = groupList.Count
-- loop through and process the new scan groups into meshes - note that list indexing starts at 0
for i=0,groupCount-1 do
result = Process( groupList[i], 0 )
-- check the result
if not result then
PrintValue( "Failed to process group: " .. groupList[i] );
return
end
end
totalTime = os.clock() - startTime
PrintValue( "Script completed successfully. Time taken: " .. totalTime .. " seconds" )
Copyright © 2015 LMI Technologies, Inc. All rights reserved.