ARCVIEW 3.x ALTERNATIVE SCALEBAR TOOL This routine allows the creation of a scalebar by selecting a ViewFrame, pointing to a single placement point, and entering the desired values. No arguments, no hassles! ======================================================================= INSTALLING THE SCALEBAR TOOL IN THE DEFAULT PROJECT 1) Begin a NEW ArcView 3.x session. 2) Create a new script by double-clicking on the "Scripts" icon 3) Use "Properties..." under the "Script" menu to rename Script1 to Layout.Scalebar 4) Paste the following text: '====================================================================== 'Layout.Scalebar 'Create scalebar from given Viewframe and point of origin '**** Get user point and Layout units theLayout = av.GetActiveDoc p = theLayout.GetDisplay.ReturnUserPoint L_units = theLayout.GetDisplay.GetUnits '**** Get ViewFrame properties theViewFrame = theLayout.GetGraphics.GetSelected.Get(0) theView = theViewFrame.GetView V_units = theView.GetDisplay.GetUnits if (V_units.AsString.Contains("UNKNOWN")) then Msgbox.warning("View must have defined units","Invalid View") exit end V_scale = theViewFrame.ReturnScale '**** Create dialog box to set properties S_units = V_units.AsString.AsTokens("_").Get(2).LCase S_interval = Units.Convert(V_scale,L_units,V_units) labels = {"Units:", "Interval Size:", "Intervals:", "Left Divisions:"} defaults = {S_units, S_interval.AsString, "2", "2"} parmlist = MsgBox.MultiInput("Enter Desired Parameters:", "Scale Bar Parameters", labels, defaults) if (parmlist.Count = 0) then exit end temp = "#UNITS_LINEAR_"+parmlist.Get(0).Ucase S_units = temp.AsEnum S_interval = parmlist.Get(1).AsNumber S_intervals = parmlist.Get(2).AsNumber S_divisions = parmlist.Get(3).AsNumber '**** Calculate bounds temp = S_interval / V_scale I_size = Units.Convert(temp,S_units,L_units) S_size = ( I_size * S_intervals ) if (S_divisions > 0) then S_size = S_size + I_size end X2 = p.GetX + S_size Y2 = p.GetY + I_size '**** Create scalebar and set parameters r = Rect.MakeXY(p.GetX,p.GetY,X2,Y2) sf = ScalebarFrame.Make(r) sf.SetDisplay(theLayout.GetDisplay) theLayout.GetGraphics.UnselectAll sf.SetSelected(TRUE) sf.SetViewFrame(theViewFrame) sf.SetUnits(S_units) sf.SetInterval(S_interval) sf.SetIntervals(S_intervals) sf.SetDivisions(S_divisions) sf.SetStyle(#SCALEBARFRAME_STYLE_ALTFILLED) sf.SetPreserveInterval(true) theLayout.GetGraphics.AddName(sf) av.GetProject.SetModified(true) '====================================================================== [WARNING: In AV2.1 omit the line "sf.SetPreserveInterval(true)"] 5) Create a new script, named Layout.ScaleBarUpdate, with the following text: '====================================================================== 'Layout.ScalebarUpdate 'Enable if ViewFrame is selected theLayout = av.GetActiveDoc SELF.SetEnabled((theLayout.GetGraphics.GetSelected.Count = 1) AND (theLayout.GetGraphics.GetSelected.Get(0).Is(ViewFrame))) '====================================================================== 6) Compile and close both scripts 7) Double-click the tool bar, choose "Layout" and "Tools", and create a new tool 8) Double-click "Apply" and select Layout.Scalebar 9) Double-click "Update" and select Layout.ScalebarUpdate 10) Double-click "Cursor" and select Cursors.CrossHair 11) Double-click "Help" and enter: Scalebar//Create Scalebar 12) Double-click "Icon" and select FrameScalebar 13) Click the "Make Default Button" and then close the Customize dialog box 14) EXIT ArcView (do not save changes to "Untitled") and you're done! ======================================================================= INSTALLING THE BUTTON IN A SPECIFIC PROJECT 1) Open the desired project and follow steps 2-12 above 2) Close the "Customizer" and save the project This control (among others) may also be installed by loading the Stuff! extension. ======================================================================= USING THE SCALEBAR TOOL 1) Select the View Frame for which you want the scalebar 2) Pick the scalebar tool 3) Point to the desired location of the lower left corner of the scalebar and click once. 4) Enter units, interval size, number of intervals, and number of left divisions (see the Help topic: "Scale bar frame tool" for more information). The default values are as follows: Units: View units Interval Size: 1 Layout unit Number of Intervals: 2 Number of Left Divisions: 2 The default style is "Split filled bar scale". This may be changed by double clicking the scalebar after it's created. The text font and size may be altered via the palette (Ctrl-P). Enjoy! ======================================================================= Mark Cederholm plp@pierssen.com http://www.pierssen.com/PC/arcinfo.htm http://www.pierssen.com/arcview/arcview.htm