HOW TO

Hotlink to multiple objects [SCRIPT]

Last Published: April 25, 2020

Procedure

Summary

The default hotlink functionality in ArcView GIS allows a feature to be linked to only one object.

Solution

The following two scripts serve as an example of how you can accomplish holinking to multiple objects.
Note:
You can modify the scripts to work with your data.

Place the "View.MultiToolApply" script as the "Apply" script on a new tool. Set up
the "View.MultiThemeProp" script to be run as the theme's Hotlink script in Theme
Properties.

The scripts below assume that your feature theme attribute table contains three fields, "BMPfield","Textfield" and "DWGfield". Each of the fields should the full path to the object that you want to hotlink to, for example, c:\mygisdata\myimage.bmp.
Code:

'------ Script: VIEW.MULTITOOLAPPLY
'
theView = av.GetActiveDoc
found = FALSE
listofFieldNames = {"BMPfield","Textfield","DWGfield"}
'--- Edit the field names above to match yours
listofValues = {}
p = theView.GetDisplay.ReturnUserPoint
t = theView.GetActiveThemes.Get(0)
if (t.Is(FTheme))
then
found = TRUE
theFtab = t.GetFTab
rec = t.FindByPoint(p).Get(0)
for each f in listofFieldNames
theVal = theFTab.ReturnValueString(theFTab.FindField(f),rec)
if (theVal <> NIL)
then
listofValues.Add(theVal)
else
listofValues.Add("a")
end
end
end
av.Run(t.GetHotScriptName,listofValues)
if (not found)
then
System.Beep
end
'
'------ End of Script: VIEW.MULTITOOLAPPLY


Note:
The code changes depending on the type of object you are linking to.


Code:

'------ Script: VIEW.MULTITHEMEPROP
'
theBMPFileName = Self.Get(0)
theTextFileName = Self.Get(1)
theDXFFileName = Self.Get(2)
MsgBox.Info("One moment please..."
+NL+"Hit OK to continue.","Multi Hotlink")

'--- For BMP Image
if (File.Exists(theBMPFileName.AsFileName))
then
theImageWin = ImageWin.Make(theBMPFileName.AsFileName,theBMPFileName)
else
MsgBox.Info("There is no Image File","")
end

'--- For Text File
if (File.Exists(theTextFileName.AsFileName))
then
theTextWin = TextWin.Make(theTextFileName.AsFileName,theTextFileName)
else
MsgBox.Info("There is no Text File","")
end

'--- For DXF Drawing
if (File.Exists(theDXFFileName.AsFileName))
then
srcDrawingLine = SrcName.Make(theDXFFileName ++ "line")
srcDrawingPoint = SrcName.Make(theDXFFileName ++ "point")
srcDrawingPoly = SrcName.Make(theDXFFileName ++ "polygon")
srcDrawingAnno = SrcName.Make(theDXFFileName ++ "annotation")
tPoly = Theme.Make(srcDrawingPoly)
tLine = Theme.Make(srcDrawingLine)
tPoint = Theme.Make(srcDrawingPoint)
tAnno = Theme.Make(srcDrawingAnno)
v = View.Make
v.AddTheme(tPoly)
v.AddTheme(tLine)
v.AddTheme(tPoint)
v.AddTheme(tAnno)
tLine.SetVisible(TRUE)
tPoint.SetVisible(TRUE)
tPoly.SetVisible(TRUE)
tAnno.SetVisible(TRUE)
v.SetTOCWidth(45)
v.SetTOCUnresizable(FALSE)
v.SetName(theDXFFileName)
if (av.FindScript("View.CloseImageView") = NIL)
then
s = Script.Make("av.GetProject.RemoveDoc(SELF)")
s.SetName("View.CloseImageView")
av.GetProject.AddScript(s)
end
v.SetCloseScript("View.CloseImageView")
theDXFWin = v.GetWin
theDXFWin.Resize(310,260)
theDXFWin.MoveTo(300,50)
else
MsgBox.Info("There is no Drawing to open","")
theDXFWin = nil
end

'--- Now open the Windows
if (theImageWin <> nil) then
theImageWin.Open
theImageWin.Resize(240,180)
theImageWin.MoveTo(1,100)
end
if (theTextWin <> nil) then
theTextWin.Open
theTextWin.Resize(240,180)
theTextWin.MoveTo(21,100)
end
if (theDXFWin <> nil) then
theDXFWin.Open
end
'
'------ End of Script: VIEW.MULTITHEMEPROP

Article ID:000001494

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic