I am working on a macro to import polygonal models into an IMInspect and have each be a new piece. I think the solution is to populate a list of polygonal model names using an array of strings. The problem is I cannot figure out how to launch a browser to select the polygonal models (not always going to be all of them). I would like the macro to work inside of IMInspect.
I just sat the IMI_New_Piece_Batch_Processing macro on the TSZ, which has helped, but I still cannot find out how to select polygonal models that are in the workspace manager.
Has anyone done something like this that they would like to share?
I think I found it!!!
MACRO INPUT PWK_OBJECTS (stringout, , "Polygonal Model", "Select Polygonal Model", )
Didn't know that command existed ;)
News to me as well. Nice find.
Here is what I did to place a Polygonal Model in difference pieces.
DECLARE PM
DECLARE NoPM
DECLARE iPM
SET iPM 1
#Select the Polygonal Model
MACRO INPUT PWK_OBJECTS (PM,,"Polygonal Model","Brows for file")
SET NoPM SIZE(PM)
#Add the first Polygonal Model to piece 1
FILE IMPORT_DATA POLYGONAL_MODEL_IN_PWK(,$PM[$ipm])
++ iPM
#Add the rest of the Polygonal Models to new pieces
WHILE $iPM <= $NoPM
PIECE NEW()
TREEVIEW DATA SELECT ALL
EDIT OBJECT DELETE ( )
FILE IMPORT_DATA POLYGONAL_MODEL_IN_PWK(,$PM[$iPM])
++ iPM
ENDWHILE
Looks like Innovmetric already had something similar in the TSZ.
version "5.0"
#=======================================================
# ---- InnovMetric Software Inc.
# ---- Module : IMInspect
# ---- Version : 12.0.1 ( 12.00.01.3700 )
# ---- Date : Friday, November 18, 2011 - 15:53:08
#-------------------------------------------------------
############################# DISCLAIMER #################################
#This macro script is provided "AS IS", and may contain bugs, errors, and
#other problems that could cause system or other failures and data loss.
#InnovMetric Software Inc. disclaims any warranty or liability obligations
#of any kind to the user of this macro.
##########################################################################
# This macro will allow you to inspect multiple pieces by selecting a folder containing all the data files (STL) that need to be used as Data object.
# This example will only use STL file in folder
# Declare Variables
DECLARE Data_Files
DECLARE Data_Directory
DECLARE Data_Name
DECLARE Data_Nb
DECLARE i 1
DECLARE Input_Directory "Y"
## Turn Off Refresh
#WINDOW REFRESH ( "Off", "Off" )
#TREEVIEW REFRESH ( "Off" )
# Input Files/Directory
IF $Input_Directory:u != "Y"
MACRO INPUT FILE_PATH( Data_Files, "Files to Inspect", , "On" )
# Get Number of Pieces Selected
SET Data_Nb SIZE ( Data_Files )
ELSE
MACRO INPUT DIRECTORY_PATH( Data_Directory, "Directory to Inspect", )
# Create File List (only .STL for this example)
SYSTEM COMMAND("dir", "${Data_Directory}\*.stl", "/B", ">", "${Data_Directory}\files.txt")
# Get Number of Pieces Available
DATA_FILE PROPERTIES NB_LINES GET( "${Data_Directory}\files.txt", Data_Nb )
# Get File Path for the Pieces
SET i 1
WHILE $i <= $Data_Nb
DATA_FILE READ LINE("${Data_Directory}\files.txt", $i, Data_Files[$i])
SET Data_Files[$i] "${Data_Directory}\${Data_Files[$i]}"
++ i
ENDWHILE
ENDIF
# Loop through Data Files
SET i 1
WHILE $i <= $Data_Nb
# New Piece
PIECE NEW ( "$Data_Files[$i]:t" )
# Name of the Old Data to Replace
TREEVIEW DATA NAME GET( 1, Data_Name )
# Import Data
FILE IMPORT_DATA POLYGONAL_MODEL ( $Data_Files[$i], "$Data_Files[$i]:e", $Data_Name )
# Extract Measured
MEASURE PLAY EXTRACTION
++ i
ENDWHILE
# Turn On Refresh
WINDOW REFRESH ( "On", "On" )
WINDOW REFRESH NOW
TREEVIEW REFRESH ( "On" )
TREEVIEW REFRESH