mark's banner

Wednesday, June 30, 2004

More Detail Regarding Locate Filter

I received an email from Paul wanting to know a little more about locate filters. Here's my reply.

You can find the complete pie example on my website in the C-A-D section. The download is called pie.zip and there is an article there that explains how to create pie.mvba. This article demonstrates how to develop a placement and edit (locate) command.

In this example command you will see that I didn't change the locate filter (see the class module classEdit). So it looks like this.



In this case the end user can select any element and the command will attempt to run.

But, since we only want the user to select pie symbols (in this case cells called PIE) we can use the filter to make this cell the only element in the design file the user can click on and accept. All other elements will do nothing when selected. The new filter might look something like this. . .



So, it makes the code a little more complicated, but it forces the end user to click on elements that only apply to your command. And you don't have to test the element type in the accept or in the dynamics functions because you already know what the element type is.

I hope that's not too much detail. I don't think this filter mechanism is obvious. It took me quite some time to recognize what it could do for my end user work flow. In fact, until recently I was only using it to prompt users to accept or reject. So, if you decide to ignore it for the moment your commands will work ok, but you may want to make a note to revisit the commands later after you have more experience with VBA. Good luck. Let me know if there is anything else I can do for you.

Tuesday, June 15, 2004

Control-Alt-Delete Next Article

Just sent my latest article to C-A-D. Subscribers can look forward to a follow up to my previous article on Graphic Command Design. In the new article I demonstrate how to add leaders to a right of way pie symbol. I'll post the code for the article later this month so it's available when the magazine comes out.

And don't forget downloads for older articles are available here - http://www.markstefanchuk.com/cad.aspx.

Friday, June 04, 2004

Ick Germs!

As if the germs our co-workers spread throughout the office when sick aren't bad enough, now it seems our computers are an oozing toxic trap and you know we can't avoid contact with either menace. Ok, yes I've spread my share of the plague.

Now, I provide a link to the wired news article, but I've found headlines in several places. Just check google newswith its 12 bazillion links that are similar.

I'll let you read the article on your own of course, but I know for sure that I'll be back at work next week leaning a couple of inches away from my flat screen (just read the article) and will have forgotten all about the neurological disorder I am developing.

Another headline also caught my attention today. double click patent was issued to Microsoft for its hand held computers. Wow, that was patentable?

Alabama State employees get another holiday on Monday. Enjoy it. You may not get it next year. ;-)

Wednesday, June 02, 2004

Snappy Link Works Now

I fixed the link to snappy.zip on thecadgurus page. Snappy is a v7 basic macro written by Robert McCartney. Apparently there are a few people visiting the site each day attempting to download a file or several.

Hellooooo, is anybody there?

Thanks to James. He noticed that the snappy link was broken - file was missing, and sent me an email.

So, if you notice a link is broken feel free to send me an email. Thanks.

Combine Locate And Primitive Interfaces

I realized recently that maybe I don't have to build my own locate tools in VBA. Here's the tip.

Instead of rolling your own locate logic into a primitive command interface build a locator interface to locate an element, save the element globally in a public variable. Do this in the locate filter. And on accept call a primitive command that implements the primitive interface to draw new elements based on the original.

I did this recently. Upon locating the element, a cell I saved it globally and then called a primitive command to draw new elements. These elements were then added to a new cell, along with elements from the original cell. When the primitive command is finished instead of

CommandState.StartPrimitive Me

do

CommandState.StartLocate New classTheLocateClassModule

This will allow you select another element just like a MicroStation edit command would allow you to do.

Tuesday, June 01, 2004

Locate Filter

Have you ever looked at something a thousand times and then look at it again one more time and discover something new? That's how I feel today about ILocateCommandEvents_LocateFilter.

How many times have I looked at the locate filter and never noticed the Accepted parameter? Has it always been there? Well ok, here's the deal. Accepted is true when the filter method is called. And as long as Accepted is still True after this method has run the ILocateCommandEvents_Accept method runs. And of course if Accepted is False then the located failed method is run. So, umm, no need to restart the command if the filter fails since that's taken care of by the locate failed method. And, the coolest thing about filter is that it only allows you to select and highlight elements that pass the filter. That means you can't select the wrong element and you don't need to build a filter into the Accept method.

Ok, here's an example.



Accepted is set to False - assume failure. If a cell named Structure is clicked then the location passes, else Accepted remains false and locate failed is called.