Necessity truly is the mother of invention. Here's an example. Someone (who will go unamed...OK, me) that does not scan every day, ran into a little problem. I'm working on a project for another article that involves scanning a disassembled mouse. I scanned one side, flipped it, and scanned the other without thinking too much about the model formation in Studio....and this is what I saw when I looked at the screen...

 

mouse_001.jpg

Both orientations of the scanned mouse are superimposed. At first I thought I would just selected the first ten models and be done with it...but where's the fun in that? So I decided to write a script that would (with all the models selected) allow me to select the points (on all the models) in an area of the scan data that I knew were part of the same orientation, and then merge them automatically.

Here's the hot scripting action...

The Support KB Nugget can be found here...and the python file and test data are available for download here.

Enjoy!


'''
SelectModels_by_ActiveSelections.py - Geomagic Helper Script

This script will walk the list of models and build a list of of their names
if they have data selected (i.e., active selections or"red" points, polys, or ordered grids/scans)

It will then construct a geo.select_objects macro and execute it.

Then, for this example, it will merge the scans associated with those selected models

Assumptions for this script and test data:

All model names must be unique.

The models cannot be Grouped.

The model data type is Ordered Points (Scans).

Author : Richard Sandham
Date : 08/30/2012

-------------------------------------------------------------------------------------
Disclaimer

THIS SOFTWARE IS PROVIDED"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR GEOMAGIC, INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

------------------------------------------------------------------------------------

'''

import string

import geoappall
for m in geoappall.execStrings: exec m in locals(), globals()

import geoapiall
for m in geoapiall.modules: exec"from %s import *" % m in locals(), globals()

models = geoapp.getModels()

pointsModelList = []
meshModelList = []
gridModelList = []

pointsModelNames =""
meshModelNames =""
gridModelNames =""

#
# walk the model list
# look for active selections of points, polys, or grids (scans/ordered points)
#

for model in models:

# points

pts = geoapp.getPoints( model )

if pts != None:
pSel = geoapp.getActivePointSelection( pts )
if pSel.numSelected > 0:
pointsModelList.append( model.name )

# polys

mesh = geoapp.getMesh( model )

if mesh != None:
tSel = geoapp.getActiveTriangleSelection( mesh )
if tSel.numSelected > 0:
meshModelList.append( model.name )

# gridded points

grid = geoapp.getGriddedPoints( model )

if grid != None:
gSel = geoapp.getActiveQuadSelection( grid )
if gSel.numSelected > 0:
gridModelList.append( model.name )

#
# build the model name strings for use in geo. macro calls
# (e.g.,"Scan 001","Scan 002","Scan 003" )
#

# points

lenPointsList = len( pointsModelList )

if lenPointsList > 0:
pointsModelNames =",".join( '"{0}"'.format( i ) for i in pointsModelList )
print pointsModelNames
else:
print"No points selected."

# polys

lenMeshList = len( meshModelList )

if lenMeshList > 0:
meshModelNames =",".join( '"{0}"'.format( i ) for i in meshModelList )
print meshModelNames
else:
print"No triangles selected."

# oredered points

lenGridList = len( gridModelList )

if lenGridList > 0:
gridModelNames =",".join( '"{0}"'.format( i ) for i in gridModelList )
print gridModelNames
else:
print"No ordered data selected."

#
# perform some macro with the list of selected models - based by data type
#

# points

if len( pointsModelNames ) > 0:
exec( 'geo.select_objects( 1, \"Point\""