Author Topic: How long to be somewhat confident with Autocad API  (Read 4607 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
How long to be somewhat confident with Autocad API
« on: March 30, 2019, 12:17:47 AM »
I was told by a manager one of his interns (who mentioned he has no programming experience at all) is excited to learn the "technical stuff" (specifically programming/API of Civil 3D/Autocad) and asked if I'd be willing to help him. I messaged the kid and said "hey, when you want to dive in I can probably save you a lot of headaches".  His reply "I'm sure it's basic enough I can figure it out on my own".  People here were a ton of help, especially our old friend Oleg, but I did that and it sucked dinosaur-sized eggs that went in and came out the same size. He's an engineer so he will have to learn it the same as I did (on his own time).  For me, it took probably 3 years to get to the point I didn't feel like I was screwing things up.  I'm curious what other people's experiences are.  Please share if you're willing. 
« Last Edit: March 30, 2019, 12:23:52 AM by quaziconscience »

kpblc

  • Bull Frog
  • Posts: 396
Re: How long to be somewhat confident with Autocad API
« Reply #1 on: March 30, 2019, 09:34:34 AM »
You can learn every day all your life. And at the end of your way you can say 'i just know that I won't know anything'
Sorry for my English.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: How long to be somewhat confident with Autocad API
« Reply #2 on: March 30, 2019, 11:31:24 AM »
++
I have been using the AutoCAD .NET API extensively for over 10 years and I often feel like a beginner.
Speaking English as a French Frog

ChrisCarlson

  • Guest
Re: How long to be somewhat confident with Autocad API
« Reply #3 on: April 01, 2019, 08:56:47 AM »
The day you stop learning something new is the day you die

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: How long to be somewhat confident with Autocad API
« Reply #4 on: April 02, 2019, 08:05:33 AM »
That is true Gile, but you´re great enough...
The goal with Autodesk API is many are using and spreading knowledge here in this forum!

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: How long to be somewhat confident with Autocad API
« Reply #5 on: May 15, 2019, 09:16:29 PM »
I have been at it since ~2005 and I'm still learning and improving ... a lot. Things that will speed up your learning...
  • Wrap everything in try-catch because not only is it good practice (it keeps AutoCAD alive) but you will get info on what broke.
  • Log a lot more than seems reasonable. Log.Debug() is wonderful for travelling back in time and checking your (mistaken) assumptions.
  • You will google lots, this is normal. Multiple monitors help me a lot here.
  • the more things you build, the more you learn - build real things, exercises don't really teach you much.

https://oz-code.com/ is a great tool for debugging.

https://github.com/serilog/serilog-sinks-file is my go-to logger. Note each plugin needs to have its own logger, there is only one central static logger, the last one created. I also write to an exception reporting service @ https://docs.sentry.io/platforms/dotnet/serilog/ but that's just for shipped apps so I know when customers are having problems, they're often surprised when I email them and tell them what broke, wait a day or 2 for a fix but here's a workaround.

If Gile often feels like a beginner then this feeling is totally normal.

pjm8765

  • Guest
Re: How long to be somewhat confident with Autocad API
« Reply #6 on: May 20, 2019, 05:19:59 AM »
I'm pretty new to AutoCAD (and by that I mean I've done a couple of years programming on and off), but a very experienced software engineer/business analyst and I would back up the 2 to 3 years observation to get to the point of being reasonably comfortable with it.

I would back up what CADBloke said with a few extras: 

First and foremost, keep it simple.  If a function gets above a screens worth of code or has more than one foreach or switch/case statement, that's usually the prompt to see if you need to split code up into different functions.  Name things what they are and do not abbreviate unless you have to.  If a function is called GetThisThatAndTheOther, that's a prompt that it's doing too much and need splitting up.  The simpler the structure the easier it is to read...the easier it is to read the less debugging you do and the easier it is for others to pick up the logic of it.

Yes, wrap everything in Try/catch, but then make the error message publicly available.  It's become really fashionable to log errors and that suffers from the "what the eyes don't see the heart won't grieve" syndrome i.e. they get logged and forgotten.  If you have error handlers that shout out "sommits wrong" it keeps you honest and also helps the users develop confidence in your software...if users know you are being honest they will give you more leeway when things do go wrong.  Hide things and they will smack you when you're down.

The bulk of engineer/designer's I have worked with start off thinking that programming is trivial and easy to achieve.  They then hit various brick walls and develop a large headache.  It is an entire "profession" (and I use that word with grave reservations) in it's own right and needs to be treated with respect.  Given this lad is an intern and as green as a newly hewn branch he needs to start with the "Dummies guide to programming"...I'm not taking the mickey either.  You guys are all experienced, but i'll bet you can't name me the four principles of OOP design without looking it up....to be sure, most programmers can't either.  Without understanding those principles all programmers are condemned to writing spaghetti code.

regards, Paul

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: How long to be somewhat confident with Autocad API
« Reply #7 on: May 20, 2019, 06:36:56 PM »
About wrapping with Try/Catch, I only wrap the most top level function (say the actual 'Command' method) as a safeguard against a possible crash. Wrapping every lower subroutine is not necessary with a few exceptions such as when handling file handles or other IO code. Try/Catch isn't free and it's overuse is a code smell :)

When using Try/Catch, write meaningful catch clauses that catch the most likely exceptions rather than using a single base System.Exception as the catch parameter. Use 'throw' if you need to from subroutines and catch them at the top level and give useful messages and a stack trace to help the programmer locate the source of the exception. It helps a lot when a user rings or emails you the screenshot of the exception ;)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: How long to be somewhat confident with Autocad API
« Reply #8 on: May 20, 2019, 06:52:01 PM »
While advocated by some, I'm also not a big fan of "programming by exception" i.e. using it in place of most logic tests.  Use exceptions in the low levels to catch the once in a blue moon WTF problems that could cause serious issues, and a top-level exception to let the user know something is wrong and avoid giving them a raw AutoCAD exception.

And while I agree that programming isn't for everyone (why on earth are they trying to get everyone to learn it, like they used to for web page design...), I would argue there should be more flexibility than things like "must be able to recite all OOP principles".  A strict programmer-first approach leads to lack of knowledge about AutoCAD and how the users are expecting to use it, in turn leading to add-ins that act and perform for a programmer rather than a user.  I've seen both situations, add-ins designed without general programming principles *and* add-ins obviously designed by a programmer with little AutoCAD knowledge.  The best products are somewhere in the middle.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2120
  • class keyThumper<T>:ILazy<T>
Re: How long to be somewhat confident with Autocad API
« Reply #9 on: May 20, 2019, 07:18:51 PM »
>>>  but i'll bet you can't name me the four principles of OOP design without looking it up  <<<

regards, Paul

How much is the bet ??

I just wish it was as easy as learning the names.  :)

///===========

While advocated by some, I'm also not a big fan of "programming by exception" i.e. using it in place of most logic tests.  <<<<

Yep.

///===========

I occasionally scan through the AutoCAD dll's ... always find something new.

///===========

At my age, I'm regularly reminded of the adage "Use it or lose it". I do think that the key is the quality of time spent for experience. not the quantum.

.... and acquire a rubber duck for talking with ....
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: How long to be somewhat confident with Autocad API
« Reply #10 on: May 21, 2019, 06:12:35 AM »
.......all programmers are condemned to writing spaghetti code.

regards, Paul

I hate it when my code resembles over cooked mushy rice noodles, I have to put on my refactoring hat