Precast Blog
Month: March 2016
-
-
Autocad Plug-in: Creating Order Forms Automatically
Normally creating order forms are a nightmare.
How does everyone else create order forms?
I have no idea how people do it. They would have to manually count/iterate through every single block which exists in the model space and simultaneously note down the parts’ associated panel number(s). They could do it on their PC, or they could do it on paper. And the worst part is, is that it would distract them from doing some real work. (Or work that they would rather be doing).
Trust me – I’ve been doing monkey work like this since I was a kid. Counting panels, counting beams, counting parts: it really is a crime against humanity. Not only is it painfully tedious, it’s error prone: it’s like trying to count the stars in the sky: it is very easy to lose count, to lose your place, or to make mistakes.
Automatic Order Forms Demo – The power of the Autocad API customisation
The power of the Autocad .Net API breaks the back of it for you. I begged the head boss to let me release this to the public, just to give you an idea of the cool things that the API can do. I now present to you automated order forms: no more counting. No more errors. All done in less than 5 minutes (as opposed to five hours).
-
WPF Tunnelling – Explanation by analogy
Tunnelling – What is it?
And no, I’m not referring to how El Chapo escaped.
Refresher: what is bubbling?
In the last post we talked about “bubbling”.
It’s kinda like those instances where you get a parking fine. If you don’t deal with it then, you’ll get another fine. If you don’t deal with it there, you will get a notice from the county court. Still not paying? Soon the police will come knocking – and like with all things – especially lies and drugs, things keep progressing to ever increasing heights of danger and pain and turmoil. Pretty soon you could end up going to jail simply because you didn’t pay a parking fine. But if you dealt with it properly at the time – well there would be no need to spend 2 years in prison for it. (Do you think I am kidding? Guess again. Why oh why wasn’t the “event” dealt with early before it bubbled up to become more serious? An excellent question. I suppose you would have to ask what was going through the mind of the judge.
Tunneling is the exact oppose of bubbling
Nebuchadnezzar was once the top dog in all the land. Nobody could so much as breath without obtaining his express written consent. All life, energy and glory started with him. But suppose something happens, suppose someone in the privacy of his own room refused to bow down to the great emperor. What did he do? He issues an event to find the culprit.
He has an extensive network of spies. And word travels pretty quickly so this is how they would have found the guilty culprit:
- The King asks his Prime minister who did it.
- The prime ministers ask State delegates.
- The state delegates ask the county delegates
- The county people ask local area managers.
- The local area managers ask every Tom, Dick and Harry on the street.
- And the people on the street finally identify Daniel as the guy who refuses to bow down.
In other words, an event begins at the top and works its way down the hierarchy to the control element responsible for triggering the event.
Now that was simple, wasn’t it?
-
What is a routed event?
What is a routed event?
This is the answer that is typical on Stack Overflow sites and other such forums:
A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.
It seems – with all due respect to those coders – are not applying the old programming adage:
Always write explanations as if the guy who ends up reading it is a violent psychopath who knows where you live.
Now such MSDN techno-speak just hurts everyones’ heads. Why can’t they just speak plain English? I’m no expert, but here it is explained simply so that you can understand:
Explanation By Analogy: What is a routed event?
Our judicial system employs routed events. Suppose that somebody commits a crime. This is an “event”. This event can be handled in any one of the following courts, (from the lowest court to the highest court in the land, respectively):
- Lower/Magistrate court
- County/Distruct Courts
- Supreme Court
- State/Territory Court
- The High Court
- The Privy Council
- and above that: The Supreme Court of the Galactic Republic
Now, as is the case, all courts have jurisdiction over the matter. A petty theft can be tried in the High Court – if you wanted to. The High court has jurisdiction, but is that what you really want? Most cases start off in the Lower courts, and then, if required, the matter is passed onto a higher court. And if so required, that court passes on the matter to a still higher court. It can go all the way to the top.
Or on the other hand, if you so decide: the theft can be handled at the lower court, and the matter can end there.
Routed events work the same way. If an event happens in the lower court, you, the programmer, can so choose to have the event “bubble up” and be handled by a higher court. The matter can go as high up as you wish and can be taken care of there.
Now that, in effect, is how routed events work. Something which starts in the Lower Court can be passed on and can be “handled” and heard in the Privy Council. And that’s it! So simple? Yet everyone tries to make it so complicated!
-
What is an event?
Assumed knowledge:
- Assume you know what a method is.
What is an event?
Let’s keep it simple. An event is anything which “happens”. “Oh great! That helps a lot :’( ,“ I hear you say. Examples are in order:
- The President comes to town. He could come at anytime. You don’t know when he could come. So when he comes, it’s an event.
- Somebody wins the lottery.
- A house catches fire.
- Somebody clicks a button.
All of these are events.
What happens next?
- Subscribers explained
What happens when an event happens? Anything you want!
Just say a house catches on fire. We will call this event “HouseFireEvent”. When this event is raised (i.e. when it happens), the following occur:
- People start screaming “OMMAGOD OMMAGAD!” (let’s call this the scream method)
- They call the fire department. (let’s call this the call-fire-department method)
- A fireman puts the fire out. (let’s call this the extinguish method).
In other words, the above methods are “called” when the house-fire event is raised. The house-fire event in fact maintains a list of methods which occur or are run when an event is raised. These methods are called subscribers. How can an event maintain a list of methods you ask? Good question. Usually there is a big book the fire warden in the floor of your department has tucked away in the back drawer of his desk. This book details all the protocols which must be followed when there is a fire. i.e. examples include: (i) staying calm, (ii) taking any valuables you have with you but no more, (iii) evacuating the building in an orderly and calm manner. These instructions, or “methods” are also known as “event handlers” because they are procedures which are called when a particular event occurs.
So in the above example, the event handlers would be: (i) Scream method, (ii) call-fire-department method and lastly (iii) the extinguish method.
………that’s it – it’s as simple as that!
