mark's banner

Thursday, May 27, 2004

Matrix3dIsXYRotation

Heads up/Tip this guy returns True if the there is a rotation, as in

If Matrix3dXYRotation(view.Rotation, angle) Then
. . . do something . . .

But what's not obvious is that angle is a holder for the rotation angle. So angle can be initialized to 0. And if the view is rotated pi/4 radians, say, then angle is returned with that value. Like I said, not obvious. There are probably other Is type methods that do this.

Wednesday, May 26, 2004

The Code Page


I wrote about CRAB's Code Page last week. This week I made a few contributions. All VBA examples for MicroStation V8+. Here's a list,

1) Measure and Copy to Windows clipboard.
2) Primitive and Locate Command Templates
3) Project Backup automates export of all modules, forms, and classes.

Check it out. Several people have already posted code contributions. If you're learning VBA or are expert there are plenty of examples here that can help you slam code.

Tuesday, May 25, 2004

Gmail - I Signed Up for Another Email Account

Now I have four email accounts to check on a regular basis. Curiosity is the culprit. But, I have to say I like the Gmail experience, and the "targeted" adds don't really bother me.

You know it's one thing to have a computer scan something I own for information. It happens all the time now. That's why we have computers, right? To automate tedious tasks like searching? It would be another matter entirely if there was a bureaucrat at the other end passing judgment on my personal babble to my sister. Of course that's just science fiction right? Right?

Um, so here's my Google Gmail account mark.stefanchuk@gmail.com
. Spam, here it comes.

Here's a MicroStation VBA tip in case anyone other than my Mother is reading this - use the cleanup function in your Primitive and Locate classes to close VBA forms when other commands are called. Keeps the MicroStation real-estate clean.

Private Sub IPrimitiveCommandEvents_Cleanup()
formBubble.Hide
End Sub

Monday, May 24, 2004

Reverse

Still on the traversal topic - I had a situation where I needed the elements within my traverse to have a bearing opposite to that being returned in the new elements. The reverse method works perfectly for arcs and lines flipping endpoints of my chainable elements.

Set chainableElements(index) = unsortedElts(startIndex - index)
chainableElements(index).Reverse

Friday, May 21, 2004

Shape Traversal

I'm finishing up the traversal technology for ALDOT's right of way application. In fact I've simplified it considerably over the J version. All we really want to do is step through the elements in a "Clockwise" direction. When a complex shape element is created, either manually or automatically MicroStation V8 requires that the elements chain from startpoint to endpoint (as did v7). But, they can progress clockwise or counter-clockwise.

So, before I can sort the elements - in right of way the point of begining will indicate where on the shape the traverse legs will start incrementing. This of course doesn't necessarilly coincide with the first element in the shape. To compensate I recreate the shape in the order I want, and if the original shape was counter-clockwise then I also step through these elements in reverse order to add them to the new complex shape.

How do I figure out if the shape progresses clockwise or counter-clockwise? I use a summation of areas which works perfectly as long as none shape legs cross one another. Here's the equation:


for k = 1 to count-1
sumarea = sumarea + (vertices(k).x * vertices(k-1).y _
- vertices(k-1).x * vertices(k).y)
next
sumarea = sumarea/2


When sumearea is positive then the shape progresses clockwise, and when negative it progresses counter-clockwise.

Thursday, May 20, 2004

Bentley Updated Their Web Site

Very Corporate. Fresh look. Hmm. Saw a post recently on the Bentley newsgroup about spending money on icons versus product improvement. I won't name any names, but the consensus was that product evolution must take priority over gui changes especially when the change is a non-enhancement.

This is interesting - See, "I Dislike Icons" in Mr. Grabowski's recent article AutoCAD 2005 Wishlist. See, some people just don't like change especially when it interfers with design production. I know, similar topic, different product but the point is the same as that from the news group. That is, "Why change the icons when we need better help?"

So, despite my desire for "new and cool" (I like the Microsoft XP gui changes) I tend to subscribe to that ideal of don't waste money on fluff when it could be spent better some place else. New web page design to promote marketing vomit is not a productive use of resources. Hear me! WE WANT USEFUL CONTENT! All of us will deal with the marketing and maybe even absorb some of it. But we want "useful" on the home page - links, tips, guidence easily accessible from webroot. Here's an idea. How about an RSS feed from www.msmonline.com.

Crab's Code Bank

This is a great idea and I'm glad to see someone has put in the effort to make it happen. Graham Steele and other members of CRAB have started a code bank. This is a place where you can share code examples. It's the same concept as "Add a Penny - Take a Penny". You can search for code examples or upload something you have created. Check it out. Here's the link to Code Central.

Wednesday, May 19, 2004

Offshore Tech

I don't really want to step into this argument, but the amount of media spew makes it hard to ignore. Reports like this one in E Commerce Times are hard to ignore.

You know you can hear the reporters eh? "Look at these poor bastards. A couple of years back they were leaving jobs for signing bonuses and stock and now they can't make the payment on their beamer."

I really doubt it's as bad as the media suggests, but don't tell that to someone who has recently lost a tech job. And we know that CAD jobs, at least at the big design builds have been worked at least in part overseas and in countries where labor costs are lower for several years now. Is it just a matter of time before they're all gone? I doubt it. But don't expect the media coverage or offshoring to go away anytime soon.

As consolation, also published in E Commerce Times last week is this article The
IT Marksman at Wal-Mart
. While mostly another article about a hard working IT executive it refers to a Wal-Mart study on outsourcing.

"Wal-Mart's preliminary studies have shown that offshoring is more expensive than writing software in-house, Dillman says. It turns out that offshore programmers tend to take more hours to complete tasks than Wal-Mart's U.S. employees do."

Wal-Mart is THE business leader. Top of Fortune 500, I'm betting that they're not making a mistake in keeping development in house. On the other hand, Wal-Mart wages are about the same as those paid in Bangalore, India.

Tuesday, May 18, 2004

An Article On Computer Security

Every now and then I visit vendor pages to see if I'm missing anything. But it's rare that I might stop at Microsoft since we all know it's simply a marketing purge. Well perhaps I'm too harsh. It appears the digerati elite discovered we need useful information.

I found an interesting article there called "The Small Business Computer Security Checklist". This is a great article for everybody. Each section begins with a "Why Your Business is At Risk". The checklist will help answer the questions like, "Why do I have to keep changing my password?" and "Why can't I download whatever I want?".

Now, a visit to www.microsoft.com can still suck you into a marketing vortex. So be careful, we don't want to have to send out a search party.

Monday, May 17, 2004

Lines and Linestrings

Don't confuse element types with interface types. I spent some time today looking for IsLineStringElement. It had occurred to me that IsLineElement probably worked for both but it didn't occur to me that I could pass a line string as a LineElement and get valid results. Turns out it works.

So the function I was working with scans a design file for lines and linestrings and then makes sure that I have the correct element type but testing for IsLineElement. Line Strings pass this test too. And I can use AsLineElement for the element in either case. So you can do this,

Dim ipts() as point3d
ipts = element.AsLineElement.GetIntersectionPoints(oTestLine, Matrix3dIdentity)

Where test line is a line that might intersect my line or line string.

In the past I might have done something like,

If .Type = msdElementTypeLine Then
. . .
elseif .Type = msdElementTypeLineString Then
. . .
end if

But then what is the element type really? It's still a LineElement to vba eventhough MicroStation's element type = 3 and type = 4 for line and line string respectively.

In this case the interface takes care of the element type. I don't know how. That's something for someone smarter than me to answer. Bottom line is that Lines and LineStrings are handled by the same interface. So stick with the interface test IsLineElement and not the type test.

Friday, May 14, 2004

Datagrids in MicroStation VBA

Datagrids. These things.



Reference Microsoft Datagrid Control 6.0 that's MSDATAGRID.OSX. It's much better than flex grid and you can bind a record set to the grid.

What's interesting here is that the recordset doesn't have to come from a database. You can build it record by record. So, consider this. If you scan a drawing for cells, you could create a record for each cell found and maybe show, level, color, weight, style, name. Maybe even make this data editable. Nice.

That's what I've done for my RTM symbols. Each parcel, remainder, structure, etc can be scanned and loaded into a datagrid. The data that I store in each of these cells is displayed as a grid record. Click on a record it highlights the cell. I do this by including in the record the element.id.low value.

So, when my form with the data grid is loaded (see image) I do something like this.

Set r = New ADOR.Recordset

r.fields.Append "Symbol", adVarChar, 255
r.fields.Append "Tract", adVarChar, 255
r.fields.Append "Type", adVarChar, 255
r.fields.Append "No/Letter", adVarChar, 255
r.fields.Append "Total", adVarChar, 255
r.fields.Append "ID", adVarChar, 255
r.CursorType = adOpenDynamic
r.Open

populateRecordSet

Then configure the datagrid

Set DataGrid1.DataSource = r
Me.DataGrid1.Caption = "Symbols"

I set the column widths and lock some of the columns too.

The recordset is populated in this manner. (watch the line wraps, my blogger style isn't really designed for code. need to do something about that.)

Private Sub PopulateRecordSet()
Dim oScanCriteria As ElementScanCriteria
Set oScanCriteria = New ElementScanCriteria

oScanCriteria.ExcludeAllTypes
oScanCriteria.IncludeType _
msdElementTypeCellHeader

Dim oScanEnumerator As ElementEnumerator
Set oScanEnumerator = _
ActiveModelReference.Scan(oScanCriteria)

Dim oElement As element, oCell As CellElement

Do While oScanEnumerator.MoveNext
Set oCell = oScanEnumerator.Current
Dim sym As String, tract As String
Dim sType As String, num As String
Dim total As String
If ReadDataFromCell(oCell, _
sym, tract, sType, num, total) Then
r.AddNew
r.fields(0).Value = sym
r.fields(1).Value = tract
r.fields(2).Value = sType
r.fields(3).Value = num
r.fields(4).Value = total
r.fields(5).Value = _
Str(oCell.FilePosition)
End If
Loop
End Sub

I've used this in several places now. It's easy to configure and works well with MicroStation scans.

Thursday, May 13, 2004

Bugs or Not?

Bugs, bugs, bugs, bugs . . .

Is an incomplete feature really a bug? I've been working through the latest version of Right of Way Tract Manager (RTM). For those that don't know I've been working contract for ALDOT the past 18 months and much of that time has been developing tools for Right of Way map and deed management.

The idea is to simplify the workflow. Reduce the steps from Right of Way map to deed description to a minimum with the overall goal to eliminate duplicate data entry. Still not with me? That's ok. Just think that every time a designer types a bearing and direction - in the map, in a property sketch, in a spreadsheet, and then in a deed there are multiple places where data could be entered incorrectly. Turns out all of the information needed is in the map - just need some tools to automate the extraction and presentation of the data. There's an avi on my portfolio page if you're interested.

So, I'm working through the version for MicroStation 2004 and discovering that I've missed a few things that were in the J version. If there's any advice I can give you about migrating code to V8* it's to consider how the previous commands are built. In this case I built both but it was really easy to take to VBA in V8 and blow through the command development. But here's the advice - make sure you use the same cell names and make sure that you build the elements in the same order! Ugg. You'd think I would know better. I'm having to go back and step through all my edit code to make sure that I haven't made some assumption about element order (of course I have) and now I have to suffer the consequences. That is go back through my code and fix it.

Now, if you have no concerns about old drawings (from J) then you don't have to worry about it. But how many of us can say they don't have files from J they want to edit in V8. Yup, I know no one.

So, I'd have to say this is an incomplete feature and not a bug. On the other hand when my users attempt to edit a parcel symbol and the data is displayed in the wrong location what do you think they will call it?

Wednesday, May 12, 2004

Point3d in MicroStation VBA

I use to do this,

Dim yAxis as Point3d
yAxis.X = 0
yAxis.Y = 1
yAxis.Z = 0

What this represents doesn't matter. What I want to show you is that you can also define the point coordinates this way,

Dim yAxis as Point3d
yAxis.X = 0: yAxis.Y = 1: yAxis.Z = 0

See, nice and compact and still readable. I like readable.

Tuesday, May 11, 2004

News and Recent Posts on Home Page

The News + Recent Posts section on MarkStefanchuk.com is more of an experiment than anything else. I wanted to test some assumptions about news feeds. And at the moment it's simply a collection of feeds (including my feed) from websites I found interesting. There are several articles on News Feeds and Aggregators so I'll leave it up to you to do your own google search.

This technology has certainly not caught the attention of the MicroStation community. I noticed however, that Autodesk encourages their employees to create web logs and publish them. I'd really like to see the same from Bentley someday.

Yes, yes, the newsgroups are excellent sources for help and information. But, these are reactionary. User in trouble, post a solution. Web logs on the other hand are proactive. Bit head gets cool and amazing idea and tells the world about it. Discovery is not hidden away until some poor sucker attempts to draw a wheel but can't so he emails Bentley and support tells him, "No, our software doesn't draw wheels, only circles." But wait, user does a google search and discovers a web log on drawing wheels with links to examples. Problem solved, customer happy.

Monday, May 10, 2004

Emailing Blog Posts

Blogger supports posts by email. I thought I should test the process because you never know when I might need to communicate with the entire planet. So, here it is. The Test.  

 

Xml and MicroStation VBA

Looking for a way to manage your application and design automation settings? What if you could set your standards and put them on any web enabled computer in the world? What if when you changed the standard that all of your users received the update immediately?

Well that's what we did with the latest version of ALDOT's right of way tools. By referencing Microsoft XML 4.0 (msxml4.dll) I can now read settings using http.

Let's Try This

Blogger just recently updated it's tools to include comments, Atom feeds, and other very useful tools for bloggers. A month ago these features were not available so I abandoned plans to move to blogger, but since these features are here now it makes more sense versus trying to maintain my own web logging tools.