Author Topic: .NET newbie question  (Read 4743 times)

0 Members and 1 Guest are viewing this topic.

surveyor_randy

  • Guest
.NET newbie question
« on: March 03, 2008, 04:03:47 PM »
I'm a longtime VB6 and VBA programmer and I've recently started looking at .NET.  I'm just curious, why would anyone want to write in .NET??  I understand that Autodesk is moving towards .NET only but when I've looked at ways to accomplish things using the API with Autodesk.AutoCAD.Geometry versus using the COM object with Interop, things are 100% harder.  A good example would be offsetting a line. 

To offset a line 50', with COM, you could just:

Dim oTmpLine as AcadObject
Dim oOffsetLine as AcadLine

Set oTmpLine = ThisDrawing.ModelSpace.AddLine(vStart,vEnd)
Dim vObjectArray as Variant
vObjectArray = oTmpLine.offset(50)
set oOffsetLine = vObjectArray(0)

How would you do this with .NET?  I'm sure it couldn't be done in as few lines of code.  Other then speed, why would anyone want to start using .NET or am I making it more complicated then it is?

 

Nathan Taylor

  • Guest
Re: .NET newbie question
« Reply #1 on: March 03, 2008, 05:47:48 PM »
The .NET API is more powerful than the ActiveX API. For example when you want to insert a block you can use a jig to display the block while the user selects a point. This can not be done with the ActiveX API. VBA users have developed complex kludges using SendCommand to try and acheive it.

surveyor_randy

  • Guest
Re: .NET newbie question
« Reply #2 on: March 03, 2008, 06:33:48 PM »
I understand that it has more power and I really like some of the new objects that have been exposed.  What I don't understand though, is why it is now more difficult to accomplish tasks that used to be simple.  Offsetting a line, creating a new layer, drawing a line, etc...  Maybe I only *THINK* that because I am new to .NET.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: .NET newbie question
« Reply #3 on: March 03, 2008, 06:46:49 PM »
Maybe its because now you have more control of it.  Like you only write one line of code to use the ActiveX libraries, but what happens behind the screens is a lot of code, and now instead of using those default libraries, you create you own.

/guess
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sinc

  • Guest
Re: .NET newbie question
« Reply #4 on: March 03, 2008, 08:52:03 PM »
I don't think you're complaining about a .NET thing, I think you are complaining about an Autodesk API thing.

The .NET API is little more than a wrapper around the ObjectARX classes.  As such, it is almost at the same level as the C++ code.  The big difference is you have all the niceties of a managed language, as well as the large and powerful core .NET framework.  The tradeoff is that, as something that is hardly above the level of the C++ core, it is grungy to deal with.

This is completely an artifact of the API design, however.  The API could be expanded with objects that encapsulate and simplify a lot of this stuff.  And maybe in time, it will.

In the meantime, the best thing is to encapsulate the "messy" stuff inside of reusable components that you only write once.  Then just keep reusing those components in your code.  The code I posted at http://www.quux.biz illustrates this concept.

Bryco

  • Water Moccasin
  • Posts: 1850
Re: .NET newbie question
« Reply #5 on: March 03, 2008, 08:55:59 PM »
I'm writing in net only because they are basically doing away with vba,
it's hard enough without decent help files and if it wasn't for the pioneers on this site I would have given up on it.
I'm kinda hooked now but still like grumbling about it.
As Nathan says, it does give better access to different things.
And an example of what Tim is saying may be something like; driving the vba car you give it some gas and it goes, .net needs to know how much gas and when to fire the cylinder

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6965
  • AKA Daniel
Re: .NET newbie question
« Reply #6 on: March 03, 2008, 09:00:00 PM »
Donít forget, itís fairly easy to party on the ActiveX API from .NET

surveyor_randy

  • Guest
Re: .NET newbie question
« Reply #7 on: March 04, 2008, 07:10:37 AM »
Donít forget, itís fairly easy to party on the ActiveX API from .NET

Yeah, but I don't want to be the last guy at the party with the ugly woman, if you know what I mean!  Everyone else is switching to .NET.  I might as well just use this as an opportunity to learn C# while I'm at it.  So it seems that the best idea is to create "re-useable" components that I can just plug into my projects as I need them?  My only other gripe would be the inability to unload/reload a .DLL in AutoCAD while you are beta testing new code.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6965
  • AKA Daniel
Re: .NET newbie question
« Reply #8 on: March 04, 2008, 10:18:37 AM »
Think of it this way. C++/CLI, C#, VB.NET etc. are platforms that you can design applications on. Autodesk has provided you with a .NET API that is essentially ObjectARX wrapped to be compatible with .NET. The good news is .NET is also compatible with ActiveX, and as you already know Autodesk has an ActiveX API.  So now you can party with the ugly one and the pretty one at the same time. w00t.  :wink:


PS. Thank you for considering C#.

sinc

  • Guest
Re: .NET newbie question
« Reply #9 on: March 04, 2008, 04:04:08 PM »
In fact, with Civil-3D, you MUST use ActiveX, because there is no .NET API for C3D.

It often isn't pleasant mixing them, however.  It can get confusing keeping track of which is which, and knowing when and how to convert objects from one to the other.  Quite messy, in fact.  But it can be done.

Nathan Taylor

  • Guest
Re: .NET newbie question
« Reply #10 on: March 04, 2008, 04:29:43 PM »
I'm writing in net only because they are basically doing away with vba,
it's hard enough without decent help files and if it wasn't for the pioneers on this site I would have given up on it.
I'm kinda hooked now but still like grumbling about it.
As Nathan says, it does give better access to different things.
And an example of what Tim is saying may be something like; driving the vba car you give it some gas and it goes, .net needs to know how much gas and when to fire the cylinder

I found your statement in the Autodesk groups about taking 4 hours to learn a C# Select Case interesting given my strong opinion on language choice most here would know about in regards to moving from VBA to .NET. Do you think it has been worthwhile learning C#? If so what are the reasons?

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: .NET newbie question
« Reply #11 on: March 04, 2008, 04:43:15 PM »
Nathan,

Well, my 'biggie', if you will (in the context of VBA to .NET), would be you have, at the very least, a readability of the following:

C/C++/Java and of course C#, in relation to your question and at the end of the day, VB is VB is VB...that's it.

Couple this with the fact that C# is a brand new (and often quoted as the premier MS .NET) language and it's a win win situation IMHO.
Not to mention the fact, that .NET 'features' have historically, to this date, been implemented in C# before VB...remember operator overloading. Admittedly, some of these are syntactic shortcuts, but the point is valid I think.

Cheers,
Glenn.
Me

sinc

  • Guest
Re: .NET newbie question
« Reply #12 on: March 04, 2008, 05:43:55 PM »
I've been enjoying C#.  I miss Objective-C categories, but other than that, I find it a pretty nice language to work with.

It might have been nice if Microsoft had taken another page from the Python book and gotten rid of the curly braces, but oh well.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: .NET newbie question
« Reply #13 on: March 04, 2008, 06:43:45 PM »

I find the C# curly braces help me breathe when reading code .. differentiating code blocks unambiguously.

... and my opinion of vb is known I think :-)

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

--> Donate to theSwamp<--

Bryco

  • Water Moccasin
  • Posts: 1850
Re: .NET newbie question
« Reply #14 on: March 04, 2008, 09:52:30 PM »
Nathan I found the jump to net (maybe this is because I didn't go straight to vb.net) to be a  way bigger jump than the jump from c# to vb, I haven't done any vb.net but I can read it fairly well as I see it as the same structure as my C# coding using vba words. The reason I did decide to go C# is that the help base here and other places seemed to be better in that direction. (And then there was the $5 I spent on a second hand book, there's just no going back from there.) As far as was it a good decision, I'm happy staying with c# but the differences mean less to me than others. I like the repetative End Sub, I end up typing something similar after the curly thangs anyway just to keep them straight. I like not having to worry about caps, but that's because I'm a bit sloppy, I can see why some coders like it more. I also like some of the ways you write C# better than the vb methods.
I feel I do know how to code in vba, which may mean I know about about the activeX api (I'm not sure what that is.), so when I have a problem in C# I would have thought I was having a net problem, not a problem in how to draw a line, perhaps someone can explain what the net.api and activex api are. (There is a bit of a row going on at the autodesk vba site about this)