« Six Flags Strikes Back | Main | Bulletin Board Upgrade »

Friday August 6, 2010

I Made a Wiki

At work we use these really old programs written in the early 80's to take input and create drawings that we use on our plans. This was seriously cutting edge technology back in the day, using Fortran programs to create electronic files. Over the years the company that makes the drafting software has made a lot of changes and we kept paying consultants to update our programs so they would still work. The guy who originally wrote the programs went on to other things, not least of which was becoming second in charge of our agency before leaving to become a consultant.

VBA Wiki logo


We are now a couple of versions behind the latest version of our CAD software, partly because the file format has changed and it takes a lot of preparation to make the jump. Meanwhile, it takes us longer and longer to adjust the drawings that come out of the Fortran program to show it like we want. There are beams we didn't even know about that have never been incorporated and nobody has been willing to try to make changes. It's a dying technology.

Skipping ahead, the latest version of the CAD software (made in 2008; the version we are using came out in 1998) uses Microsoft Visual Basic for Applications to run macros and user commands and programs. The good thing about that is it doesn't take any other software to create programs since it all runs internally to the CAD software. This 2008 version was installed on our machines earlier this year in preparation for us to migrate to it (well, most computers have it, but mine doesn't because I forgot to leave my computer on the night they were running the installation). In the last few weeks I have been learning how to do some computer drafting which I had never even attempted before. As our CAD technicians reach retirement and are not replaced (primarily because if a person knows enough about computers to be a CAD technician, they can make more money than we offer), engineers will be doing more of the drafting, so I want to minimize the drafting by updating our programs. If I can get the output from 80% complete to 90% complete, I can cut the workload in half.

So last week I started playing around with VBA on a spare computer. My goal was to draw a rectangle. I created a form with a Width and Height field and a button that says Draw. The idea is that when I run this macro (or program or application, which are all the same thing) I can enter the Width and Height and the computer will draw a rectangle.

But things are 3D now and to make a line you have to make points. The points are arrays of 3 numbers (X, Y, and Z coordinates). Then you would think there would be some command like DrawLine from Point A to Point B. But not, you have to write:

CreateLineElement2(Nothing, PointA, PointB)

This took about a day to figure out because I didn't know what command to look for or how to set up points, and so on. You can look for help online, but the software is fairly obscure and programming it in VBA is even more obscure. What is worse is that they have changed the language a little over time, so one of the basic sample programs I tried to run bombed out. Well, once I had a line, it wasn't but a few minutes until I could draw a rectangle.

Next I wanted to place a cell, which is a standardized drawing that might consist of text and lines (for example, a stop sign graphic that has eight sides and says "STOP"). This took another day and some really very odd stuff. And I guess all of this is so basic that nobody on the internet feels a need to explain it.

Really the only other thing I need to be able to do is place text. So that was another day or so. If I can place lines, cells, and text, I can pretty much produce a complete drawing by repeating all of those things.

So I wanted to write all of this down, mostly for me, but also for anyone else trying to do the same thing.

I thought I would create a Wiki on my website. I have been writing a lot of stuff at a Flashlight Wiki and wrote some stuff for the family Wiki that Jeb set up before it got erased. And of course I read the biggest Wiki of all, Wikipedia, and have even made a couple of edits to articles there. In fact, all of these Wikis use the same software, which is called Wikimedia. And it is free. It runs on a web server like blog software or bulletin board software. So I figured I could install it just as I was able to create a community bulletin board even though it hasn't gotten much use.

For most of these programs, you download a file to your server, then uncompress all the files, edit a configuration file, and you are done. At least that's what I thought. I forgot that I also need to set up a database on the php server with an admin name and password before I do any of that. So I ran into some trouble there, but got it set up eventually. Then I set up a subdomain so that I could just go to wiki.igirder.com instead of igirder.com/wiki. It went pretty smoothly except for setting permissions, but I think that is squared away too. To avoid spam like the flashlight wiki gets, I decided not to allow anyone else to edit the Wiki for now. I also added a logo which is the rectangle that I eventually was able to draw, including cells (the red arrowheads and blue circles). In fact, because I am so bad at drafting, it was easier for me to modify my program to include the text "VBA" and "Wiki" on the drawing instead of using the drafting commands.

Comments (2)

You'll want a backup plan. To get the database content out, you have to "dump" the database as a series of SQL query commands that can be used to reset up the database as well ad re-add content. You can do that manually with something like myPHPAdmin, cPanel, or use scripts running under chron. I'll send you the script I use separately. Then you also need to do file-based backup of media content. I messed up on the SQL backup dump with Fiveforks Wiki the first time. I ran it as an experiment on our iMac which did not have database backups automated... just files.

I got a lot of work done on the project (not just the Wiki which hasn't changed much) and the code is now up to 60 pages. Here is the end result which may not look like much, but isn't too far off from what our finished sheet looked like. Here is the input form used to create the drawing.

Post a comment