#!/bin/sh ## ## Nautilus ## SCRIPT: 00_one3Dfile_SHOW_ivview.sh ## ## PURPOSE: Show a 3D file using the 'ivview' program. ## ## 'ivview' reads SGI Inventor files --- and VRML1 files, where ## the VRML1 spec is a subset of the Inventor spec. ## ## File suffix is typically '.iv' [or '.vrml' or '.wrl'], but ## the suffix can be anything. 'ivview' apparently reads header ## records to determine if it is reading the right type of file. ## ## The 'ivview' user interface is quite simple, but very effective. ## ## METHOD: Uses 'zenity' to warn if the file format may ## not be supported by 'ivview'. ## ## We run 'ivview' in an 'xterm' so that we can ## see error messages to stdout, if any. ## ## Some info on installing 3D viewers, like ivview, is available at ## http://www.subdude-site.com/WebPages_Local/RefInfo/Computer/Linux/LinuxGuidesByBlaze/apps3Dtools/3D_viewers-converters/3DviewersANDconverters_intro.htm ## ## HOW TO USE: In Nautilus, navigate to a 3D file that you want to ## view, right-click the file, and select this ## script to run from your menu of Nautilus scripts. ## ########################################################################## ## MAINTENANCE HISTORY: ## Started: 2013feb25 ## Changed: 2013 ########################################################################## ## FOR TESTING: (display the executed statements) # set -x ############################################## ## Get the filename of the selected file. ############################################## FILENAME="$1" # FILENAMES="$@" # FILENAMES="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ################################################################## ## Get the extension (suffix) of the input file. ## (Assumes just one dot [.] in the filename, at the extension.) ################################################################## FILEEXT=`echo "$FILENAME" | cut -d\. -f2` ########################################################### ## A zenity 'info' window to show 'ivview' usage info. ########################################################### zenity --info --title "'ivview' Usage Info" \ --no-wrap \ --text "\ 'ivview' Usage Info: 'ivview' reads SGI Inventor files --- and VRML1 files, where the VRML1 spec is a subset of the Inventor spec. File suffix is typically '.iv' [or '.vrml' or '.wrl'], but the suffix can be anything. 'ivview' apparently reads header records to determine if it is reading the right type of file." & ## Give the user a second or two to start reading the info. sleep 2 ################################################################### ## Check that the selected file is a '.iv' or '.vrml' or 'wrl' ## --- or some other 3D file viewable by 'ivview'. ## (Other suffixes may be added.) ################################################################### if test "$FILEEXT" != "iv" -a "$FILEEXT" != "vrml" -a "$FILEEXT" != "wrl" then CURDIRFOLDED=`echo "$CURDIR" | fold -55` zenity --question --title "Warning: May be unsupported by 'ivview'." \ --text " The file you selected may not be viewable in 'ivview'. The selected file is $FILENAME in directory $CURDIRFOLDED 'ivview' is said to read SGI Inventor and VRML1 files. Continue or Cancel?" if test $? != 0 then exit fi fi ################################################################### ## Set a 'central' or 'local' version of 'ivview' to use. ################################################################### ## NOTE: The 'local' version of 'ivview' uses 'dynamic loading' ## of shared libraries and may not run if the shared libraries ## on this machine are not compatible with 'the build'. ## One may be able to work around incompatible 'shared objects' ## by use of a LD_LIBRARY_PATH environment variable in this script ## and by finding compatible shared objects and pointing to their ## location with a LD_LIBRARY_PATH variable. ################################################################### if test -f /usr/bin/ivview then VIEWER3D="/usr/bin/ivview" else . $HOME/.freedomenv/feNautilusScripts/set_DIR_NautilusScripts.shi VIEWER3D="$DIR_NautilusScripts/zMORE/3Dtools/.ivview" fi ################################################################### ## Show the selected 3D file with 'ivview' --- in an xterm. ################################################################### ## FOR TEST: (show statements as they execute) # set -x xterm -hold -fg white -bg black -geometry 80x30+25+25 -e \ $VIEWER3D "$FILENAME" ## FOR TEST: (turn off display of statements) # set -