05 Understanding the Object Model Framework, Etc.

Document created by David Kosakowski on May 1, 2018Last modified by David Kosakowski on May 10, 2018
Version 4Show Document
  • View in full screen mode

Creating Common Objects

  • Point – coordinate control

  • Polyline

  • Polygon

  • Arc/Circle

  • Rectangle

  • Block

  • Hatch

  • Alignment

  • Corridor

  • Surface – Add Isopach,

  • Breakline

  • Boundary

  • Contour line

  • Legend

  • Text (Smart Text?)

  • Label

  • Texture

  • Material

  • Site Improvement

Using the Object Browser

There is nothing in the Object Browser now?

The Object Browser allows you to review all available classes defined in the DLLs in your project to see their properties, methods, and events. This helps you understand what classes are, where they are stored, and what you can do with them. In addition, you can see the procedures and constants that are available from object libraries in your project. You can use the Object Browser to find classes to use.

Note: You can easily display online Help by pressing F1 as you browse.

The View Project Data (Members of Project) macro is a tool to help people write macros. Within Trimble Business Center, this lists (as a hierarchy) all the components in your current VCE project file. E.g., the TrimbleVce.Core.Components.DimensionStyleCollection is the object that holds dimension styles. So if you want to find dimension styles, you need to find that collection and then iterate through it. Same with ViewFilterCollection, same with BlockCollection, same with LabelStyleCollection, LayerCollection, etc. These are all in a new project without data, e.g., in an empty project, you will still have two layers: 0 and Points, which exist on startup. When you create additional layers, they are listed too. WorldView is the container for Plan View geometry, such as polylines, etc.

To use the Object Browser:

  1. Select View > Object Browser.

  2. TBD

Using Common Controls

Most TBC commands use 'custom controls' to allow you to select and enter values for coordinates, stations, layers, etc. Only a portion of these controls have been converted to work in the macros. Currently, the available controls include:

  • AngularEdit (enter/pick two points for an angle)

  • BearingEdit (enter/pick two points for a bearing)

  • ComboBoxEntityPicker (select an object from a list)

  • CoordinateEdit (enter/pick a coordinate)

  • DistanceEdit (enter/pick two points for a distance)

  • ElevationEdit (enter an elevation)

  • EnergyEdit ()

  • MemberSelection (select multiple objects)

  • NumericEdit (general numeric control)

  • OffsetEdit (enter/pick two points for an offset)

  • SelectEntity (select one object)

  • StationEdit (enter/pick a station)

  • StreamingCoordinateEdit (click-and-drag to create a line of CAD points)

  • VerticalAngleEdit (enter/pick two points in a profile view for a vertical angle)

  • LeftRightEdit (select the side of a line looking down the line from the starting station)

  • Layer (select a layer from a list)

  • LineStyle (select a dashed or other style for lines from a list)

  • TextStyle (select a typeface, font, and styles from a list)

  • NameEdit (enter/pick an object to use its name)

  • TrimbleColor (select a color from a list)

Commands with UI

  • Dialog box style

    • Just show dialog in Execute function

    • ToggleTabs.py

    • ToggleTabs.xaml

  • Can create window directly or create class that inherits from Window

    • If using python class, WPF will automatically generate property for each named control

  • Docked commands

    • Typically, a command frame docks the UI. When you run a docked command, the program creates a C# helper class that is basically a native C# command with the properties of the Python script inside it. That's how the Python code gets integrated.

    • If you have a WPF command, you start with the outside Window co and then you start adding other controls (typically a grid and a stacker) which helps specify where other components are.

    • A “helper” class is created that holds the basic framework of the command. This command uses WPF for UI layout.

    • By default, the xaml file has a grid with a stacker panel for the macro command’s use. The StackPanel goes inside the UI of the command that is running.

    • The macro must define a class that inherits from the wpf StackPanel control

    • At Runtime. wpf.LoadComponent is used to to read xaml file and create UI controls.

    • Several predefined functions are available. If these function are defined, they will l be called.

      • OnLoad(MacroCmdUI, okBtn, cancelBtn, EventArgs)

        • Program is ready to load the UI; do you want to do anything? This is when you register for call backs or set defaults, etc.CancelClicked(MacroCmdUI, RoutedEventArgs)

        • What to do if you click Cancel.OkClicked(MacroCmdUI, RoutedEventArgs)

        • What to do if you click OK.

    • Using WPF, you can change fonts, size, etc.

    All of this is using IronPython.

    Command Data Class

    These properties are assigned to each “Command”:

    Properties

    • Key

      • Not case-sensitive, not localized, and cannot contain blank spaces or control characters

    • Command Name (defaults to Key)

      • The translated version of the key

    • Command Caption (defaults to Name)

      • The name shown in the UI, which you will want to put in standard English with spaces and capitalization

    • Hidden

      • If True, this hides the command, such as when it it not ready to use or only for internal diagnostics. This precludes the macro command from appearing in the UI, but you can type the key on the Command line to open it.

    • ImageSmall

      • The bitmapped 'icon' for placing the command on a ribbon or toolbar; if you do not supply one, a default icon will be inserted

        Note: The icon you supply should be 19x19 pixels.

    • HasStartup

      • If True, the function “SetupExecute()” will be called when the application starts. Typically, no project is loaded at this time, so this is usually used to modify the ribbon. (You will rarely set this to True, unless you wanted e.g., .)

    • EnableNoProject

      • If True, command is always enabled, whether a project is open or not, e.g. a macro for reconfiguring the layout of ribbon tabs and panes.

    • UIForm

      • Name of Class in your script that defines what the UI controls when command shows UI in the command frame. Just leave as empty string if the command does not use the command frame UI. If this is defined, a command wrapper is created, UI is called and placed in it. (used often)

    • HelpFile

      • Specify a custom help file so when the user presses F1, it calls your own help.

    • UIViewForm

      • Specify the class name that defines what the UI controls when the form appears in an MDI view (like the Point Spreadsheet). Leave this empty string if not used.

    • Properties (for Ribbon placement)

      • DefaultTabKey

        • Specify which ribbon to place the macro command on; if you type a new tab name, it will create a new one for you.

      • DefaultTabGroupKey

        • Specify which group within a ribbon.

      • InsertAfterMenuToolKey

        • Specify the key of a tool after which the command will be inserted. If the value is string.Empty, the tool is inserted as the first item in the menu. If the value is null or the key is not found, the tool is added to the bottom of the menu.

      • QuickAccessMenuLocation

        • Specify the location of the macro command on the Quick Access toolbar at the top of the application window.

      • ShortCaption

        • Add a shortened command name if you lack space on the ribbon or Quick Access toolbar.

      • DescriptionOnMenu

        •  

      • ToolTipTextFormatted

        • Add a description of the command that will appear when you hover.

      • ToolTipTitle

        • Typically, you add the caption here.

Next topic: 06 Creating Your Own Macros

Attachments

    Outcomes