Wednesday, February 3, 2010

Autodesk Map3d 2010 with WCF (III)

Author: Jonio, Dennis

The snippets below are an example for a client. It did take some time to research the parameters required for a long lived(8 hour) service. It turned out to be that two(2) parameters have to be set, InactivityTimeout and ReceiveTimeout. Needless to say these should match the service’s ServiceEndpoint configuration.

In general the way the service works is that you can send it data with any one(1) of three(3) different methods. I only employ one(1) of those methods in this case. If your application has “Subscribed” you will be sent via the callback method any and all output from the service. I really do not attempt to track the “state” of anything. As the book explains, and to say the least, state tracking is probably not the best way to expend your time and energy.

From Map3d's perspective the new, improved DataBridge is really a non issue. For all intent and purpose Map3d will see things the same way. I am sure that as time moves on the complexity of "if" and "case" statements will grow.
I plan on following this article with the complete DataBridge Version II.
Source code snippets for a client(C#):

Monday, February 1, 2010

Autodesk Map3d 2010 with WCF (II)

Author: Jonio, Dennis

I make absolutely no attempt here to explain why I have done the things the way I have done them in relationship to the grand scheme of WCF. There is just too much to explain and you really should get the book and improve on what I have done. I stopped a long time ago in trying to force Map3d to do multi-threading. As it turns out this is not debilitating at all, just use a Form.
The following are my concrete classes for the WCF interfaces found in the previous article. Making no value judgments, you do have to be impressed with how much Microsoft has done in producing the “behind the scenes” transport functionality. Since I wanted “required, reliable sessions with binary transport” I have coded towards the NetTcpBinding and the NetNamedPipeBinding.
As you can see there are two(2) methods for getting data to the service and the service has one(1) method to send data back to the client. During research I happened upon this multiple client subscription concept with a simple Guid identifier. I desperately wanted some kind of "session identifier" that was all ready in place, generic and robust. If you do the reading you will discover WCF has the concept of SessionId but in my mind's eye it is too crippled to be of any use for my purpose. This subscription paradigm struck me as a good, simple and straightforward idea.
The service itself.
Source code (C#):


You will discover as I did that the communications piece is really all about the client. Nothing much happens without them.
Now for the Client the callback class.
Source code (C#):

Autodesk Map3d 2010 and WCF (I)

Author: Jonio, Dennis

Well, I finally finished my first Windows Communication Foundation(WCF) project. Ever since .NET Framework 3.0 came out I had been curious but until now the chance to delve into it just never appeared. The prompt was to get some flexibility into the IPC chores between my custom Autodesk application modules(netloads) and my .NET applications.
First off, I certainly join the chorus that promotes getting Juval Lowy’s work Programming WCF Services (in my case 2nd Edition). There is a multitude of nuance and subtlety that would be left to chance without reading this work. In addition I do not have a clue where else a person would go to get his kind of depth of understanding. A real "must have" if you are serious about WCF.
As I spent more time with WCF I certainly learned of some of its strengths and weakness’. I really did waiver a lot concerning implementing the callback interface versus just using the simplest of operation contracts with each executable acting as a hosting service and likewise a client. This would have made this new interface very similar to my previous NamedPipe interface in that both sides act as host and client. In the end I choose the WCF DuplexChannel/callback paradigm because I figured out the rather straightforward way to keep the session(s) alive over an extended period of time.
If you are at all familiar with my previous work with IPC you know that I pass serialized datasets around as opposed to passing more granular objects. I do not stray from this paradigm. It has served me well and I cannot think of any reason to change.

The following are my interface definitions for the service and callback. I will leave the class implementation for a follow up.
Source code (C#):

Thursday, November 19, 2009

(VII) New SDO_GEOMETRY <-> Autodesk Map3d 2010

Author: Jonio, Dennis

The next and last items on the list ...
  • Given one or more Autodesk/Map3d objects decompose it(them) into “Drawable(s)”.
  • Given a “DrawAble” compose a Autodesk/Map3d object.

    This is the class that interacts with Autodesk Map3d. (I have removed a few things that are not importtant to the discussion here.)
    First, as time has gone on I have grown weary of parseing out Autodesk/Map3d objects and manipulating them. I gravitated toward AppendLoopFromBoundary() and BalanceTree() for MPolygon construction. Just a lot less code on my part. If it isn't a Point type I force just about everything to a Polyline at one time or the other. If you really need true 3D objects you shouldn't be reading this anyway.
    Just some things of note:
  • I never output an Oracle Circle
  • I never output an Oracle Rectangle
  • I never output an Oracle SDO_POINT
    I will read them and write them as Autdesk objects but after this they loose their identity as such.

    This is the last post on this topic. I have decided NOT to post the working source and project. If you are interested in the final work leave a comment with your email address.

    Since I produce only VALIDATED geometry I will be working on the post of my latest iteration of my IO class for doing validation against the database.
    Source code (C#):
  • Tuesday, November 17, 2009

    (VI) New SDO_GEOMETRY <-> Autodesk Map3d 2010

    Author: Jonio, Dennis

    The next on the list ...
  • Given some “DrawAble(s)” compose a NetSdoGeometry.sdogeometry.
    The method signature:
    public static sdogeometry SdoGeometryFromDrawAble(List _drawables, int _lrs, int _srid)
    If you recall the DrawAble holds the dimensionality so the Measure and the SRID had to be injected somewhere.
    Frankly the simplest of all the methods. Very straight forward implementaion.
    Maybe somewhat unusual here is that I made this a static method within the static utility class.

    Source code (C#):
  • Sunday, November 15, 2009

    (V) New SDO_GEOMETRY <-> Autodesk Map3d 2010

    Author: Jonio, Dennis

    As I stated in the last post:
  • Given a NetSdoGeometry.sdogeometry decompose it into a “DrawAble(s)”.
    As you would suspect this is mostly code. This is the actor that gets invoked every time DrawAbleSdoGeometry gets instantiated via DrawAbleSdoGeometry(sdogeometry aSDO_GEOMETRY) or the Geometry within an existing DrawAbleSdoGeometry gets changed.

    The todo here is to breakdown and pair SDO_ELEM_INFO elements with SDO_ORDINATES elements. The end result will be at least one DrawAble(s).
    Source code (C#):
  • Friday, November 13, 2009

    (IV) New SDO_GEOMETRY <-> Autodesk Map3d 2010

    Author: Jonio, Dennis

    Before I begin to discuss additional detail I will briefly illustrate what it looks like to materialize an Autodesk/Map3d object from a NetSdoGeometry.sdogeometry with this approach. The other class DrawAbleDwg shown below has not been discussed at all to this point. This is in fact the simplest pattern that can be used when dealing with the MULTI type.
    Source code (C#):

    The following illustrates just the opposite, a NetSdoGeometry.sdogeometry from multiple Autodesk/Map3d objects. The three(3) in this case will capture the Z axis. Actually I don't know what I am going to do with it but I have it if it is necessary.
    Source code (C#):

    DrawAbleSdoGeometryUtil.SdoGeometryFromDrawAble(drawList, 0, 2236); Passing in the DrawAble, the LRS, and the SRID produces a sdogeometry!

    Here is the list of things that remain to be shown:
  • Given a NetSdoGeometry.sdogeometry decompose it into a “DrawAble(s)”.
  • Given some “DrawAble(s)” compose a NetSdoGeometry.sdogeometry.
  • Given one or more Autodesk/Map3d objects decompose it(them) into “Drawable(s)”.
  • Given a “DrawAble” compose a Autodesk/Map3d object.
    To be continued ...
  •