Ideate: 888.662.7238 | Imaginit: 415.593.6000
Author: Matt Miyamoto AutoCAD Civil 3D, AutoCAD

While on technical support at Ideate, we often receive requests from our customers for items or features that aren’t currently part of AutoCAD and Civil 3D. One recent request was for a Viewport Scale Bar that dynamically updates its values when a user changes the Viewport scale in their drawing.

Although this can be done by linking blocks with fields to Sheet Set Views, not all users use sheet sets or take the time to set them up with a linked scale. In this case, we were able to create a custom made viewport scale bar linked to the Viewport itself without the use of Sheet Sets.

The scale bar we were looking for is fairly standard. It is divided into three 1-inch sections, each linked to a multiple of the viewport scale. To the right of the 0 value, a whole number representing the viewport scale and a double value of the scale are shown. To the left, half and whole value increments are displayed.



*image not to scale

This Scale bar is dynamically linked to the Viewport through the use of Fields.  When a Viewport Scale is specified (1:10 in the example) and the drawing is regenerated, the SCALE: item is updated along with the values for 10, 20, -5 and -10. Although it seems easy enough, these are not standard Field options and require some manipulation of the Field codes.

In each case, a Field was inserted for the value, with the Field Name and Field Category set to Object. The Viewport was selected as the Object Type and Custom Scale was set as the Property.

In the Format section, the 1:# and 1”=#’ options were the starting points for the modified field codes.

To get the whole number value, I started with the code for 1:#

From that, removing the highlighted 1: item produces just the # value in the field (1:10 becomes 10).

The revised code looks like this:

For the 0.5x and 2x multiple values, the 1”=#’ code was the starting point

Since this code was created to apply a multiplier of 0.0833333333333333 to the original scale factor, all I needed to do was change that to 0.5 and 2 respectively. Once that was done, removing the 1/”= portion of the code left me with only the multiplied values. The “-“ was also added to the codes on the left side of the 0 value (-10 is the code from above with a “-“ added to it).

The resulting code for -0.5x and 2x values are:

The result is a dynamic Viewport Scale bar that updates (after REGENALL) if a user changes the Viewport scale.

That said, it is not without its faults. Here are some tips and items to consider when using this custom scale bar:

  1. Because Fields are linked to specific objects in a file, the Dynamic Scale bar cannot be copied and pasted directly into another drawing. BOTH items (Scale bar and Viewport) need to be copied in order for it to work in another file.
  2. The modified code used to generate the required values is NOT supported since it is a modification to background coding intended for use with Object Fields. Use of these objects is at your own risk.
  3. Updating of the values is not triggered automatically. Users are required to REGENALL for the numbers to update after a viewport scale is changed.  Always remember to verify the scale with the Scale Bar regardless of dynamic functionality.
  4. The scale bar in our sample file was set up for engineering scales (i.e. 1:10, 1:20 etc.). It will also convert fractional (Architectural) scales to this format. A ¼”=1’-0” scale would display as 1:48 using this Scale Bar.
  5. Viewports and Scale Bars can be saved to your drawing template (.DWT) file so that they automatically appear in new files. The size of the viewport can be adjusted as needed after the drawing is created.
  6. Layouts can be created with pre-defined paper sizes (Page Setups) that include these Viewports and Scale Bars. Use the Design Center to copy these into existing drawings or to add them to a template (.DWT) file.
  7. Do Not convert the Scale Bar into a Block. The Scale Bar needs to remain un-blocked in order for the Fields to function properly after it is copied.

For more information on the software solutions, training and consulting Ideate provides, please visit the Ideate, Inc. homepage.

      Matt Miyamoto
Matt Miyamoto
ENI Manager & Senior Application Specialist

Matt is an ENI Manager and Senior Application Specialist in Ideate, Inc.’s Seattle office. He has a B.S. in Mechanical Engineering and is a licensed Civil Engineer. Prior to joining Ideate, Matt worked as a civil engineer, using Civil 3D on a variety of projects including site development, roadway improvements and infrastructure design. With over 10 years of experience in the civil engineering industry, Matt now provides training, consulting, technical support, and implementation strategies for organizations transitioning to Civil 3D. Matt is an Autodesk Certified Instructor (ACI), as well as an Autodesk Certified BIM Specialist: Roads and Highway Solutions. Additionally, Matt is and Autodesk Certified Professional for AutoCAD, and AutoCAD Civil 3D. Find Matt on Twitter.