English

How To: Hotlink to a project and open the imported views

Summary

The 'Link.Project' system script imports the project but it doesn't open the documents, they must be opened by the user.

The script below allows the hotlink to import the project and opens only the imported views.

Procedure

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into the new window:

    Code:
    '-- Script: Link.ProjectOpenViews

    '-- SELF is the path to the project file mentioned in the feature's hot link field.

    theVal = SELF

    '-- Make a list of the views in the project before importing.

    theODL=av.Getproject.getdocs
    theOVL=List.Make
    for each d in theODL
    if (d.is(View))
    then theOVL.Add(d)
    end
    end

    '-- If the hotlink field for the selected feature has no path,
    '-- report a message and exit. Otherwise, convert
    '-- the SELF string to a FileName and import the project.

    if (theVal.IsNull.not)
    then
    av.GetProject.Import(theVal.AsFileName)
    else
    MsgBox.Info("This feature has no project mentioned in the table","Error")
    exit
    end

    '-- Make a list of all the views in the project after importing.

    theNDL=av.getproject.getdocs
    theNVL=List.Make
    for each do in theNDL
    if (do.is(View))
    then theNVL.Add(do)
    end
    end

    '-- Compare the new view list to the old view list.
    '-- Isolate those that are new, and open them.

    theUVL=List.Make

    for each v in theNVL
    theNum=theOVL.Find(v)
    if (theNum=FALSE)
    then theUVL.Add(v)
    end
    end

    for each uv in theUVL
    uv.getwin.open
    end

  3. Click the Compile button.
    [O-Image] Script compile button
  4. Make the view and theme active.
  5. Select Properties from the Theme menu.
  6. Click the HotLink icon.
  7. Select the name of the hotlink field in the Field dropdown list.

    Note:
    The values in the hotlink field must be the path to the apr file. For example: c:\temp\proj1.apr.

  8. Select Link to User Script in the Predefined Action dropdown list.
  9. Click the Load System Script button.
    [O-Image] Load System Script
  10. Select the hotlink script and click OK.
  11. Click OK in the Theme Properties dialog.