Help with writing a macro or a MVB, please.

Good Morning Folks,

I would like to create what I think is a pretty simple custom command that simply combines the "Measure Area" command and takes that result and then puts it into the the dialog box of the "Place Text" command; thus allowing me to rotate, change font, and all the other things that are found on the the text editor dialog box.  But this is all new to me.  I have started a introductory online course on programming but when I try to relate what I have learned so far to MicroStation v8i Visual Basic it is just "too big" of a jump for me, but the concept of what I am looking for seems so simple.  Could someone please give me some guidance?

In my office we are still using MicroStation v8i SS2.

Any help would be Greatly Appreciated, Wil

Parents
  • MicroStation's VBA implementation  offers a Macro Record tool, which can generate some useful code as a good starting point. There is a MicroStation VBA book that is very good, too. The key to using the "recorded" code is to replace the code that uses the fixed coordinates and fixed text strings with code that prompts the user to pick elements and/or points and extract the necessary values to be passed along to the "recorded" code. I believe the book has example of that, but even the MicroStationVBA.chm file in the Overview > Getting Started with Visual Basic > Recording and Revising Macros topic is a pretty good explanation of a recorded macro and the edits required to get user input.

    That example is to create a smart line. The code to alow users to select elements is more complex and can be very complex, depending upon the code used. Many examples that manipulate or query elements use classes. While these are nor rocket science, they are a more advanced form of programming. 

    Last word, I recommend this link LA Solutions MicroStation VBA Topics

    It's author, Jon Summers is a fount of knowledge on all things programming. 


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration
    Maryland DOT - State Highway Administration User Communities Page

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
  • Good Morning Chuck,

    Thanks for your reply.  I would like to take a class on MicroStation VB through EnvisionCAD but I don't know if my office will spring for it or not, and I need to check to see if there is any online training provided by Bentley on this topic.  Chuck, what is the title of the MicroStation VB that you recommended?

    Just one more question, what is the difference between MicroStation Visual Basic and that "Recording of Commands" procedure that MicroStation has; is that just a simplified interface that produces a mvba file or does it create another type of file entirely? 

    Thanks Again Chuck, and have a Good  Day, 

  • What "Recording of Commands" are you talking about? Where is this in the interface?

    Learning MicroStation VBA by Jerry Winters (Amazon)

    It might also be  available from Bentley or ebook.


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration
    Maryland DOT - State Highway Administration User Communities Page

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
Reply Children
  • Hello again Chuck,

    I was looking in the only book I have on the MicroStation VB subject, "CAD Manager" by EnvisionCAD and in this book there is a chapter titled "VBA Project Manager".  The chapter has a few exercises that use the VBA Project Manager to record series of commands and inputs but one exercise is titled "Recording a Macro" and the other is "Creating a New MVBA" and I not sure if these are one and the same or if the VBA Project Manager interface is simply used to create both styles of customized commands?  At least I thought that "Macros" and "VB files" were two different animals, but I could be wrong.

    Peace, 

  • Yes,recording a series of commands writes MVBA code, which is binary outside of MicroStation & the VBA Editor (IDE - Integrated Development Environment).

    But there are 2 types of macros in MicroStation: MBE and VBA.

    1. MBE is the MicroStation Basic Extension (Environment?) which first appeared in MicroStation 95 & PowerDraft 95. Once the MicroStation VBA IDE was released, Bentley announced that MBE Macros were considered obsolete technology and would eventually be phased out.
    2. VBA is the recommended user and developer tool for regular duty programming  Since these are also called macro's throughout the programming world, there  is that potential for confusion.

    I started using Excel VBA pretty extensively long before MicroStation came out with its VBA. Although there are a lot of differences, I found the knowledge did transfer. It's actually harder to go the other way because CADD is an interactive tool, relying on many more "events" than are available in programs like Excel. And while "events" complicate things, you can start with simple programs and build up to more complex programs.


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration
    Maryland DOT - State Highway Administration User Communities Page

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
  • Right-O Chuck,

    Having read your response, it is starting to make more sense.  I read somewhere that MicroStation was no longer recommending the use "Macros" but like you were saying they were still referring to them in their book.  But this is really more a function of the term "Macro" being a legacy term. 

    Thanks Again, and have a Good Day,