English

How To: Edit scale bar parameters independently

Summary

Editing one property in the scale bar properties dialog automatically updates the remaining properties. The following script changes each property independently from the rest.

Procedure

  1. Open a new script window.

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

  2. Paste this code into the script window:

    Code:
    '-- This script will allow you to set the scale bar
    '-- properties without automatically updating other scale
    '-- bar parameters (such as when you edit properties in the
    '-- scale bar frame editor dialog box). You will also be able
    '-- to enter interval values with a leading "0".
    '
    theLay = av.GetActiveDoc
    theGraa = theLay.GetGraphics
    theGrab = theGraa.Findbyclass(scalebarframe)
    if (theGrab = nil) then
    msgbox.error("You need to create a scale bar","")
    exit
    else
    end
    Scaunits = { "inches","feet", "yards", "miles", "millimeters",
    "centimeters", "meters", "kilometers" }
    theUnits = msgbox.choiceAsString(Scaunits, "Enter Unit Type:", "Units")
    if (theUnits = ("miles")) then
    Scauni = #UNITS_LINEAR_MILES
    elseif (theUnits = ("inches")) then
    Scauni = #UNITS_LINEAR_INCHES
    elseif (theUnits = ("feet")) then
    Scauni = #UNITS_LINEAR_FEET
    elseif (theUnits = ("yards")) then
    Scauni = #UNITS_LINEAR_YARDS
    elseif (theUnits = ("millimeters")) then
    Scauni = #UNITS_LINEAR_MILLIMETERS
    elseif (theUnits = ("centimeters")) then
    Scauni = #UNITS_LINEAR_CENTIMETERS
    elseif (theUnits = ("meters")) then
    Scauni = #UNITS_LINEAR_METERS
    elseif (theUnits = ("kilometers")) then
    Scauni = #UNITS_LINEAR_KILOMETERS
    else msgbox.info("Please Enter A Valid Scale Unit","")
    exit
    end

    theGrab.setunits(Scauni)
    Scaint = theGrab.GetInterval.AsString
    theNum = msgbox.input("Enter Interval:", "Scale Interval", Scaint)
    theGrab.SetInterval(theNum.AsNumber)
    Scaints = theGrab.GetIntervals.AsString
    theNumints = msgbox.input("Enter Number of Intervals:", "Scale Intervals", Scaints)
    theGrab.SetIntervals(thenumints.AsNumber)
    Scadiv = theGrab.GetDivisions.AsString
    theNumdiv = msgbox.input("Enter Number of Left Divisions:", "Left Divisions", Scadiv)
    theGrab.SetDivisions(thenumdiv.AsNumber)
    av.GetProject.SetModified(true)
    theLayout = av.GetActiveDoc
    theLayout.GetDisplay.ZoomToPage
    '

  3. Attach the script to a button on the Layout GUI.

    A. Compile the script.
    B. Switch to the Project window.
    C. Select Customize from the Project menu.
    D. On the Customize dialog, select Layout under Type dropdown.
    E. Select Buttons under Category.
    F. Click the New button.
    G. Double-click the Click property in the Customize dialog box.
    H. Enter the name of the script in the Script Manager and click Select.
    I. Close the Customize dialog box.

    For more information, see 'Customize dialog box' in ArcView Help.

  4. Open the layout and click the new button.