You are currently reviewing an older revision of this page.
Original Article Date: March 2004
Updated: March 2008, December 2010
Driving MicroStation from a web page:A really cool component of MicroStation and the Internet, is the ability to send MicroStation commands from an HTML document (web page) directly to your design session. This is achieved through the use of HREF tag and two special protocols: ustnkeyin and ustnform. In this article we'll look at the ustnkeyin protocol.Sample Files for this article:Download and extract both the design file and cell library from 187_Files.zip.(The zip file contains both V7 and V8 file formats.)Once extracted, rename the cell library to ustnkeys.cel and carry on.Examples of sending commands from an Internet browser:The ustnkeyin protocol allows you to include links that run MicroStation keyins directly from an HTML file being read by Internet Explorer. In order to achieve this functionality, Internet Explorer must be opened from within MicroStation.
The protocol and the associated keyins are entered into the HREF tag in the same way one would attach a link to another web page. For example: href="ustnkeyin://fit+view+extended" would activate the MicroStation command fit view extended. When creating or building these tags, it's important to note that any spaces in the command must be replaced with the + character as shown above.The following are examples of using the ustnkeyin protocol and are designed to be used with the sample file provided. Open the design file and simply drag and drop Wegpage.html from the zip file into your open design file. MicroStation will start the web browser, load the HTML page and open the E-Links tool box.
Alternativly, you can connect to the browser from within MicroStation by choosing Utilities > Connect Web Browser. Then open the HTML page from the browser.
Once the page is loaded, click on each link and notice that it activates a MicroStation keyin. For example, clicking Draw Pipes executes the following MicroStation keyins: co=3;lv=9;lc=0;wt=0;place smartline. To make this keyin string work from an HTML web page, it's tagged as follows (replace the square brackets with the proper tag format).
[a href="ustnkeyin://co=3;lv=9;lc=0;wt=0;place+smartline"]Draw Pipes[/a]
Using ustnkeyins with E-Links (MicroStation pre-V8i):An Engineering Link is an web tag that allows you to go to a specific web page in your browser. However, if you replace the URL in the tag with a MicroStation keyin using the ustnkeyin protocol, you can execute specific keyins when Follow Engineering Links is selected.For example, if you want to add the rd= command to a match line on your drawing, all you do is key in the following in the URL field of the tag: ustnkeyin://rd=filename.dgn
A few other examples:To launch the Image Viewer and open a specific file:ustnkeyin://mdl+load+imagevue+[imageFile]To execute a macro:ustnkeyin://macro+[macro_name]To open another design file:ustnkeyin://rd=[filename.dgn]To attach a V8 reference:ustnkeyin://rf=[file_name]
NOTE: MicroStation has difficulty interpreting commas in the RF command. For example, rf=c:\dgn\road.dgn,,Road,,* will work fine as a normal keyin but reports File not found when called via USTNKEYIN. (TR#129912). To surcumvent this issue, simply create a little macro specifying the keyin and then call the macro from USTNKEYIN. For exampe, the macro roads.bas may contain the following lines:Sub mainMbeSendKeyin "rf=c:\dgn\road.dgn,,Road,,*"End SubAnd the webpage will show the following command:HREF="ustnkeyin://macro roads"
Using ustnkeyins with links (MicroStation V8i):Rather than using e-Links in MicroStation V8i, just use the tool Add Link to Element from the Organize task. This is a modern version of e-Links that also plays nice with the Project Explorer. In addition, it facilitates linking to external files, executing MicroSation keyins via the ustnkeyin protocol, as well as supporint URL links such as mailto.
The following video shows how to use this tool to add MicroStation keyins to an element. In this example, I'm attaching the keyin fit view extended to a piece of text and then edit the link so it reads a bit easier.
AskInga Article #187