Author Topic: Rice, wine and sake, or how to migrate your DotNet AutoCAD applications for 2013  (Read 30649 times)

0 Members and 1 Guest are viewing this topic.

Patriiick

  • Mosquito
  • Posts: 11
An article by Serge Camiré, automatic translation from french. (french original  article here, login required)
(Since the article was put in private mode after this thread was started, here is a public screen capture of the english translation)
« Last Edit: June 10, 2012, 12:08:04 PM by Patriiick »

TheMaster

  • Guest
An article by Serge Camiré, automatic translation from french.

Regarding this:



The Open() method is an extension method in 2013, but it is
not in a different namespace. It would seem that the author
has namespaces and classes confused.

If that's so, it should continue to work as it did previously (or at
least, in C# it should, but I'm not sure about VB), and none of
what he shows above should be necessary.


BlackBox

  • King Gator
  • Posts: 3770
Out of curiosity, is that not necessary because of the ApplicationServices Class for each version (AcMgd), or does Core Console in 2013 present a Reference hurdle given the stated intent for plug-in ambiguity  (where the same plug-in would work for R18* & R19*)?

I'm only now teaching myself to code in .NET, so forgive me if I am oblivious to the fundamentals.

** Edit - iPhone typos fixed. Also, I really like the Rice, Wine, Sake analogy.
« Last Edit: April 28, 2012, 10:24:09 PM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Out of curiosity, is that not neccesary because of the ApplicationServices Class for each version (AcMgd), or does Core Console in 2013 present a Reference hurdle given the stated intent for plug-in ambiguity  (where the same plug-in would work for R18* & R19*)?

I'm only now teaching myself to code in .NET, so forgive me if I am obvlivious to the fundamentals.

ApplicationServices is a namespace, not a class.

I'm just guessing that there'd need to be code changes for plugins that
are designed specifically to run in the core console, but in those cases,
there are probably many other dependencies that would also require
different code streams.


BlackBox

  • King Gator
  • Posts: 3770
Sorry for my confusion; I know that AutoCAD.ApplicationServices is being used as a Namespace, be it with "using" (C#), or "Imports" (VB), I just (incorrectly) assumed that ApplicationServices was a Class of AutoCAD.

Again, I am very new to .NET; your clarification is much appreciated.
"How we think determines what we do, and what we do determines what we get."

Serge

  • Guest
Thanks to Patrick for having published on this web site my article about the migration of DotNet solutions to work with AutoCAD 2013. It’s an honor for me to introduce myself in this first thread. I will certainly read other articles.

I also want to thank the ones who read my article. It’s unbelievable how today a text can be translated with so few glitches.  I do hope that you found useful tips. You may find that, unlike articles in a Playboy magazine, the text parts it contains are at least as much important as the images.

There is a thing I can’t close my eyes. I would like TheMaster that he kindly clarifies what he meant by saying "It would seem that the author has namespaces and classes confused." If I don’t react to that statement, this would suggests that anyone can write anything to discredit someone else's work without foundation.

I spent hours to write with the most accurate information possible aiming people to ease their work. The image invoked is about reusing the source code in different versions of Visual Studio. I never mentioned the word Class or Namespace nearby. In fact, there are only 3 occurrences of the word Namespace in the whole article and it is at the very end where I explain how to export Type Libraries for those who want to create skins in a context of managing Cad standards with MEF.

I'm sure TheMaster will now give a fair try by reading the article at least once and come back with something more constructive. For me, an opinion comes with impersonal facts, some solid arguments and a possible way to rectify the situation. There are now 3 possibilities for him: 1) he clarifies what he wrote; 2) he retracts himself or 3) he let things go and loose its own credibility and I’m sure it’s not what he wants.

This was not in my article but yes indeed, there are some changes in the Namespaces. We can read an article by Kean Walmsley in this topic in "Migrating .NET applications to work with AutoCAD 2013": http://augifr.ning.com/profiles/blogs/migration-de-solution-dotnet-pour-autocad-2013?commentId=6456585%3AComment%3A10055&xg_source=msg_com_blogpost or you can read the C:\\ObjectARX 2013\docs\arxmgd.chm help file.

TheMaster

  • Guest
There is a thing I can’t close my eyes. I would like TheMaster that he kindly clarifies what he meant by saying "It would seem that the author has namespaces and classes confused." If I don’t react to that statement, this would suggests that anyone can write anything to discredit someone else's work without foundation.

This is a direct quote from your article:

Quote

    The error is caused by a displacement of the function to another name space.


That is not true.

The function was not moved ("displaced") to another namespace, it was moved to another class, and was made an extension method of the class it was moved out of.

None of the code changes you show are necessary because the Open() method is an extension method, which means that it can continue to be used as if it were still a method of the DocumentCollection, and the same code that used it in 2012 or earlier will work in 2013.

If your 2013 code does not compile and generates the error stating that the Open() method is not a member of the DocumentCollection class, there are two possible reasons for it: One is because you do not reference the namespace containing the extension methods (which in this case, is Autodesk.AutoCAD.ApplicationServices), and the second potential cause (and the likely cause in your particular case), is that you've not added a reference to the assembly containing the extension method.

If you are not familiar with extension methods (as your article clearly suggests), then visit MSDN and read more about them, and how they are used.
« Last Edit: May 01, 2012, 12:02:42 AM by TheMaster »

TheMaster

  • Guest
This was not in my article but yes indeed, there are some changes in the Namespaces. We can read an article by Kean Walmsley in this topic in "Migrating .NET applications to work with AutoCAD 2013": http://augifr.ning.com/profiles/blogs/migration-de-solution-dotnet-pour-autocad-2013?commentId=6456585%3AComment%3A10055&xg_source=msg_com_blogpost or you can read the C:\\ObjectARX 2013\docs\arxmgd.chm help file.

Perhaps you've been mislead by the somewhat confusing way Kean expressed the changes in AutoCAD 2013 in the above referenced article, or perhaps the translation from English was the problem, but what Kean says is not factually accurate in several ways.

From that article:

Quote

Along with API implementations moving from acad.exe to AcCore.dll (and their public declarations moving from AcMgd.dll to AcCoreMgd.dll), we’ve also added some namespaces to house extension methods for API capabilities that need to be used in full (rather than core) applications: DocumentExtension, DocumentCollectionExtension, EditorExtension, WindowExtension. You will find that certain methods can’t be found when you reference the AutoCAD 2013 DLLs – in most cases it’s a simple matter of adding the right namespace to your project, but in a few cases you’ll find properties/methods have been renamed – mostly to make them more descriptive.

For instance, the existing property to get AutoCAD’s status bar is:

     Autodesk.AutoCAD.ApplicationServices.Document.StatusBar

In AutoCAD 2013, this has been changed to:

     Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetStatusBar()

So a little different, but hopefully not to find to track down and manage. The ObjectARX SDK contains migration information that will help identify and make these changes.


Specifically, where he says:

Quote
we’ve also added some namespaces to house extension methods for API capabilities that need to be used in full (rather than core) applications: DocumentExtension, DocumentCollectionExtension, EditorExtension, WindowExtension.

They didn't add namespaces, they added classes to house extension methods. The identifiers he cites above are the names of classes, not namespaces.

In addition, he shows GetStatusBar() as being a method of DocumentExtension (which it is) but what is confusing about that is that because GetStatusBar() is an extension method that targets Autodesk.AutoCAD.ApplicationServices.Document, the method can be called as if it were a method of the Document class (e.g., myDocument.GetStatusBar() ), so that is also misleading.

« Last Edit: April 30, 2012, 10:36:14 AM by TheMaster »

Serge

  • Guest
No one has answered RenderMan yet so I’ll open a parenthesis for him now then continue with TheMaster.

A namespace is an organize way to store information. You may see it as folders. Like folders, they can be organized with a hierarchy (many levels). They may contain objects such as classes, structures, enumerations, delegate function and so on. On the other part, classes are complex objects that contain data, functions, events and so on. You may see them as a file. A structure is a special case of class as they essentially contain only data and they do not support encapsulation. Like a directory, a namespace is a container and could contain all the above objects; they do not have to be in a class (although Autodesk usually organize them in classes).

If you open the arxmgd.chm file from the C:\ObjectARX 2013\docs directory, you’ll find a section called “Moved API”. In there, you will find a list of all the objects that have been moved. The first item is the EventHandler Idle. It is mentioned that it has been moved from Autodesk.AutoCAD.ApplicationServices.Application to Autodesk.AutoCAD.ApplicationServices.Core.Application. The class here is Application and everything before is the namespace.

So, to answer your question, AutoCAD.ApplicationServices is indeed a namespace and Application is the class.

If someone likes to play with words, yes you can always say that if you move a file from a disk to another, it is not the same file anymore and so, if you move a class from one namespace to another, it is not the same class anymore. I don’t think anyone has being confused up to now.
Here is a modified PrintSCreen of the Object Browser that you can open with the F2 key. In the left pane, you’ll find symbol names with their respective icon, on the upper right pane is the content of the symbol and finally, in the lower right pane if the definition. I’ve used Visual Studio 2008 for the example because it is a version I own in English.
 
To return to TheMaster, I don’t want to extend this discussion about whether or not I’m confusing classes or namespace because I find this trivial but:
  • There were absolutely no link between the image and the declaration you’ve used.
  • Kean and I were absolutely correct when we stated that some declarations have been moved from one namespace to another. You can always read the arxmgd.chm file or continue that topic on Kean’s blog.
  • I didn’t realize that you’ve mentioned that the Open method is an extension. Sorry for the delay. This is something that we have to talk about.
  • I’ll be very glad to talk about other subjects then confusing namespace and classes since I feel that it is a privilege to be able to exchange idea on this site.
   
Here is a first quote of yours: “The Open() method is an extension method in 2013, but it is
not in a different namespace. It would seem that the author has namespaces and classes confused. » and this other quote: “If you are not familiar with extension methods (as your article clearly suggests), then visit MSDN and read more about them, and how they are used.”. These are 2 misleading affirmations that I’m sure I’ll take time to analyze.

About Extension method, please first, read this link to learn more about them: http://msdn.microsoft.com/en-us/library/bb383977.aspx.
Extension methods have been introduced in C # 3.0 as a solution to allow the mapping syntax to run correctly with LINQ IEnumerable, without having to change the IEnumerable itself (which would cause enormous problems existing code). Unfortunately if they are convenient for this case (and are actually the best solution), 95% of cases, they pose serious problems of versioning, and should be used with extreme caution. Extension methods are also mainly aimed to those who do not currently own the source code. I don’t think that this is the problem at Autodesk.

In my article, I was not talking about extension methods but rather about new things in AutoCAD 2013, and indirectly what’s new in the Framework 4.0, hence the Managed Extensibility Framework (or MEF).

Many of the Microsoft’s technologies overlap. Sometime, it happens when a new paradigm arises. But they are never 100% equal. According to Glenn Block (PM for the MEF in .Net 4.0) MEF is the preferred way for building composable apps.

Again, to avoid confusing technologies, I suggest learning about:

TheMaster

  • Guest

No one has answered RenderMan yet ....


Sorry, your first sentence (quoted above) is incorrect, So I will not waste my time with anything else you've written, other than to reiterate that Your original mistake of calling an extension method directly as a static method, rather than correctly calling it as an extension method is entirely self-evident, and yet you almost completely ignored that in a rambling reply/lecture.

The first lesson you have to learn before any lesson related to programming, is how to find the courage to admit to your own mistakes, rather than trying to trivialize and marginalize them with posts like this, and attacking the one who points them out.

« Last Edit: May 21, 2012, 11:10:36 PM by TheMaster »

Serge

  • Guest
Again, I feel this is a privilege that all of us being able to participate to this site. This discussion should be focused for those who want to discuss about the article.

I hope you are not blaming me because I gave information to RenderMan. I also hope that it's not too late and that he has seen it. If you read his very last sentence, you'll see that it was "Again, I am very new to .NET; your clarification is much appreciated."

I think we should not confuse courage and humility.

For me, courage was to take the time to write the article. If you copy-paste it into Word, you'll end up having about 35 pages of fully condensed information. I never heard you saying that you liked it or that you've learned something, although you didn't have to. On the contrary, you emitted a negative opinion for which I asked you kindly to elaborate. The rest is known and I've turn the page. If I must admit I made a mistake because I used the exact same words as Kean and the official Autodesk's documentation, then I don't feel so bad.

Humility is something else. You don't know me but if you did, you'll be the first to seen that I'm the first to laugh at myself. I usually try to make my best but since I'm human, it can happen (and it does happen) that I say something that is not clear enough or incomplete. Again, if you'd read me in other newsgroups, you'll see that I am always glad to be criticized because it creates a positive dynamics and everybody win.

Humility implies that I never gave myself any conceited attributes or nicknames. I believe that the other ones should decide if I am good or not.

I think the real problem is that you never thought the author would find your comments because of the language barrier and ask for justifications. Rather than admit yourself that your opinions were exaggerated, you continued to see problems where there were none, pushing further the reasoning by including Kean in your justification. Why wear dark glasses? Worse, you started talking about extensibility, a subject you have not defended yourself yet and for which you made 2 important misleading declarations and for which I gave you references. Instead of explaining yourself on that topic, you've diverted the attention by accusing me of lack of courage, making me the moral and complaining because I wanted to help Renderman. Are you the only one who can intervene on this site?

I feel very sorry the way this thread is evolving because that's spoiling the work I've done writing the article. I'm also sad the way that our first contact begun. Can we raise the white flag?

TheMaster

  • Guest

I hope you are not blaming me because I gave information to RenderMan.


No, Only for ignoring the fact that RenderMan's question was answered, long before you replied.

Quote

I think we should not confuse courage and humility.


I have no problem not confusing the two.  I also know egomania when I see it.

So far, you've only shown that you are incapable of admitting your mistake. 

Quote

Rather than admit yourself that your opinions were exaggerated...


There was no exaggeration. 

You are confusing exaggeration with your inability to admit to mistakes.

« Last Edit: May 25, 2012, 01:48:55 PM by TheMaster »

Jeff H

  • Needs a day job
  • Posts: 6144
I have not tried testing it but I am still a little confused how it would work.
 
Among others DocumentCollection was ripped out and placed in Autodesk.AutoCAD.ApplicationServices from accoremgd.dll
 
How do you tell which dll to load or which dll you would be using?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

I am confused by your confusion grasshopper ..

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>

Has the article been made private, or is my access being affected by public wifi ??

.... decided to read the article and can't :(



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.