Add Circle Centre Lines using MicroStation VBA

  • Products
  • Services
  • Publications
  • Links
  • WishList
  • LA Solutions
LA Solutions
tel: +44 1398 361 800

This article concerns Bentley Systems' MicroStation® computer-aided-design (CAD) tool.

Q How do I mark-up a circle with a cross at its centre?

This VBA example was developed to show how to migrate an existing MicroStation BASIC tool. Its purpose is to add a circle (or ellipse) centre marker, in the form of a cross, to an existing ellipse (or circle). Here's a screenshot of some circles & ellipses as drawn …

Circles & Ellipses

A The tool prompts the MicroStation user to identify a circle (or ellipse). The tool adds lines radiating from the centre of the ellipse. The length of each line is computed from the current text size. In other words, the size of the resulting cross is in proportion to current text annotation. The symbology of the cross is taken from the chosen ellipse. The lines are added to a new, unique, graphic group.

Circles & Ellipses with centre markup

VBA Project Structure

The main module (modMain) provide the Main subroutine that is the entry point for this macro. In other words, when you keyin vba run [MarkCircleCentre]modMain.Main, this starts execution at the Main subroutine.

Main does little more than invoke the locator class. The locator class is simple and provides a way to let the user identify an EllipseElement (circle or ellipse) for markup. When a user accepts an ellipse, it calls the procedure that creates and draws the LineElements that form the markup.

VBA Version Notes

The locator class sets a command name for MicroStation's Edit|Undo menu using property CommandState.CommandName. That property was introduced with MicroStation XM.

If you are using an earlier version of MicroStation (i.e. MicroStation V8.5 2004 Edition or earlier), you will see a run-time error when MicroStation attempts to execute the statement. The fix is simple: comment the line that contains CommandState.CommandName. The commented line should look something like this …

' CommandState.CommandName = "Mark Circle Centre"

Download VBA Project

Download

You can download the MarkCircleCentre.mvba project. Unpack the ZIP archive and extract MarkCircleCentre.mvba to a well-known location such as \Bentley\Workspace\Standards\vba. Run the macro using the keyin
vba run [MarkCircleCentre]modMain.Main


Bentley Technology Partner

Trademarks

All trademarks are acknowledged. Trademarks may be registered in some jurisdictions.
e-mail Contact LA Solutions using this enquiry form.

Home
Home
Updated on 27-Jun-16 Copyright © 2010…2025 Jon Summers