HOW TO
Editing one property in the scale bar properties dialog automatically updates the remaining properties. The following script changes each property independently from the rest.
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
'
Get help from ArcGIS experts
Download the Esri Support App