HOW TO
This script will change the $HOME variable to the location of the active theme in the view. This will work regardless of the theme type. It will not set the variable to a directory that is not writable.
Code:
'-- This script is designed to run from either a script window
'-- or from a button attached to the View GUI.
'-- Get the view and the theme
theView = av.GetActiveDoc
theTheme = theView.GetActiveThemes.Get(0)
'-- Get the file name and strip out the theme name
'-- leaving only the directory path
theSrcName = theTheme.GetSrcName
theFileName = theSrcName.GetFileName
theLocation = theFileName.AsString.Substitute(theSrcName.GetName,"")
'-- Check the directory write permissions.
'-- If not writeable, let the user select one that is writable.
'-- Set the HOME variable.
If (File.IsWritable(theLocation.AsFileName)) then
System.SetEnvVar("HOME",theLocation)
Else
MsgBox.Warning("The directory is not writable"+nl+
"Please select another directory","Bad Path")
theString = MsgBox.Input("Path to new home variable:",
"New Home Variable",System.GetEnvVar("HOME"))
If ((theString = nil) OR (File.IsWritable(theString.AsFileName).Not)) then
MsgBox.Info("No changes were made.","")
Else
System.SetEnvVar("HOME",theString)
End
End
'-- Display the new path for the HOME variable.
MsgBox.Info(System.GetEnvVar("HOME"),"Home Variable")
Article ID:000004080
Get help from ArcGIS experts
Download the Esri Support App