For Microstation V8i, I have been given the assignment of converting several UCMs to Basic or Visual Basic. Since there is a manual for converting UCM to Basic, I decided that I would convert them to Basic. Then new macros could be created in VBA. I am just learning Microstation and of course, my management wants this assignment completed quickly.
I would like to know if it is possible to call a Basic Macro from another Basic Macro with parameters of any built-in or Macrostation type, such as an MbePoint. If not, is there an alternative? These small UCM Macros that are called frequently by many Macros, but I don't think there are include files in Basic.
For now, I'm using Basic Subroutines, which isn't ideal.
I would like to convert the UCMs to VBA, but I think that would take much longer, unfortunately.
Unknown said: It is good to take a step back and see what your UCM code is doing. Then translate the concepts to VBA. Excellent suggestion! [/quote] I'll second Robert's suggestion. I've converted over 300 UCM's to VBA's for different clients. That is the exact approach I took, replace the functionality but redesign from scratch. You are needlessly making the job much more difficult if you are examining every line of UCM code to translate to VBA.
It is good to take a step back and see what your UCM code is doing. Then translate the concepts to VBA.
Excellent suggestion!
[/quote]
I'll second Robert's suggestion. I've converted over 300 UCM's to VBA's for different clients. That is the exact approach I took, replace the functionality but redesign from scratch. You are needlessly making the job much more difficult if you are examining every line of UCM code to translate to VBA.
Rod WingSenior Systems Analyst
Unknown said:It is good to take a step back and see what your UCM code is doing. Then translate the concepts to VBA.
Regards, Jon Summers LA Solutions
Hi Elaine,
Another suggestion... UCM is a programming language with a bunch of very simple tools that can't do much. I was helping someone convert some UCMs to VBA. First, he had tried to do automated conversions to BASIC, which produced unreadable, terrible code which was a major pain to work with. Another thing I saw was these huge drawn out processes to do something very simple. In UCM, to get the square root of "A" squared plus "B" squared, it was a 4 or 5 step process, rather than one line of code. Also, point manipulation was done on X, then Y, then Z. In VBA, that could be one command, and it definitely should be one Point3d variable rather than three un-named variables.
What I'm trying to say is that it is good to take a step back and see what your UCM code is doing. Then translate the concepts to VBA--not just a direct word-for-word conversion.
--Robert
Unknown said:I don't need to be concerned about working units and UORs in converting CVT?
VBA provides the Point3d and Point2d data types for working with coordinates. Normally, you work in Master Units, and don't need to be concerned about UORs. Because UCMs used UORs you often had to convert between the two. You can assign a Point3d the like this...
Dim point As Point3dpoint.X = 1.point.Y = 2.point.Z = 3.
Or, you might prefer the API, which offers useful methods like this...
Dim point As Point3dpoint = Point3dFromXYZ (1., 2., 3.)
MicroStation VBA's default transform works in master unit values and UORs conversions should be minimized except where absolutely required by a method.
The MicroStation objects (Attachement and ModelReference) provide the following convenience functions:
Here is a sample showing how to take those numeric values and display them as strings, note that you can use Microsoft VBA's CStr() function to convert a number to a string value if you need to store the result:
Sub ActiveModelDisplayWorkingUnits() Debug.Print "UORsPerMasterUnit: " & ActiveModelReference.UORsPerMasterUnit Debug.Print "UORsPerSubUnit: " & ActiveModelReference.UORsPerSubUnit Debug.Print "UORsPerStorageUnit: " & ActiveModelReference.UORsPerStorageUnitEnd Sub
Lastly as many have mentioned already, MicroStation BASIC, MicroStation User Commands (UCMs), and MicroCSL have all been deprecated prior to the MicroStation 8.1 version release and documented in some of the following references:
HTH,Bob
Unknown said:I highly recommend that you convert things to VBA over Basic. I have never tried this so I do not know how successful it will be, start the VBA recorder and then run the UCM it should record the playback of the UCM depending on how complex, it may help you get what you need.
I just want to mention again that I highly recommend that any new end user customization be done in VBA. I would hate to see you have to do the work twice if you choose to convert things to Basic.
In "UCM-to-Basic.pdf" it says that CVT converts between working units and UORs and stores the result in var1. If var1 is a character string, the conversion is from UORs (Units of Resolution) to working units and then I would need to find the equivalent in VBA.
However, in VBA I did do something similar to what you showed in your reply, except made them const. So I don't need to be concerned about working units and UORs in converting CVT?
Unknown said:CVT A0 = '.25' Is there something different about the MIcroStation V8i version compared to the older version so that I don't need to translate CVT to the VBA counterpart?
Is there something different about the MIcroStation V8i version compared to the older version so that I don't need to translate CVT to the VBA counterpart?
There's a lot different. CVT is a conversion instruction: the quoted string is converted to a decimal and stored in register A0.
VBA has more explicit assignments:
Dim decimalNumber As DoubledecimalNumber = 1.234
The TCB registers Ax are globally-available storage slots. Those UCM slots don't know or care what's stored in them: an integer number, floating point number, or a 3D point. A VBA variable is local to your macro, and is usally declared to store a certain type of data. That makes VBA much safer to use.
Thank you, caddcop. I've been using "Microstation-UCM-REF15.pdf" and "UCM-to-Basic.pdf" to understand the UCM code, but I don't have the "MicroStation Productivity book." What I'm not clear about is CVT:
CVT A0 = '.25'
CVT A1 = '.625'
CVT A2 = '.5'
CVT A3 = '.125'
When I used the counterpart of this using Basic, the graphic didn't work correctly. But when I ignored it, it did. I converted the UCM code to VBA ignoring CVT and it also works.
Is there something different about the MIcrostation 8vi version compared to the older version the illustrators are using, Microstation SE O5.07.01.22, so that I don't need to translate CVT to the VBA counterpart?
I recently found my copy of the MicroStation Productivity book. It lists many of the register and/or tcb variables that UCM's used. If you need any explanation of some of these to determine what the code was doing, I can help.
Charles (Chuck) Rheault CADD Manager
MDOT State Highway Administration