Author Topic: Getting off the Ground with .NET  (Read 22630 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Getting off the Ground with .NET
« on: April 01, 2011, 10:56:23 AM »
Over the past few days I've been looking to take the plunge into the world of C# .NET and have been investigating the tools I need to get me started.

I've looked over the links in the 'Getting Started' thread, and am mainly following the advice offered by the AutoCAD .NET Developer's Guide.

I am running MS Visual Studio 2010 and AutoCAD 2010.

I have downloaded the ObjectARX SDK from here, and, following the instructions detailed in the Dev Guide here, I have attempted to run the 'ArxWizads.msi' file  --> This informs me that I need an instance of MS Visual Studio 2008 on the target machine.

Questions:

Can I develop in .NET with MSVS2010?

Are there version restrictions in C# .NET (i.e. Does an application need to be compiled to suit each version of AutoCAD?).



Your time and advice are appreciated.

Lee

LE3

  • Guest
Re: Getting off the Ground with .NET
« Reply #1 on: April 01, 2011, 11:05:10 AM »
Those are great news, good for you Lee!

- I'm still with VS2005 and VS2008, can't say anything about VS2010.

- You don't need the wizard, it is very simple to setup one without that, I have installed the one that comes with ARX/SDK 2010 and it is very helpful but for ARX apps, because of the project solution skeleton that it does.

- The .NET apps I do, I normally(have) to target for specific acad versions/32/64

Over the past few days I've been looking to take the plunge into the world of C# .NET and have been investigating the tools I need to get me started.

I've looked over the links in the 'Getting Started' thread, and am mainly following the advice offered by the AutoCAD .NET Developer's Guide.

I am running MS Visual Studio 2010 and AutoCAD 2010.

I have downloaded the ObjectARX SDK from here, and, following the instructions detailed in the Dev Guide here, I have attempted to run the 'ArxWizads.msi' file  --> This informs me that I need an instance of MS Visual Studio 2008 on the target machine.

Questions:

Can I develop in .NET with MSVS2010?

Are there version restrictions in C# .NET (i.e. Does an application need to be compiled to suit each version of AutoCAD?).



Your time and advice are appreciated.

Lee

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #2 on: April 01, 2011, 11:24:30 AM »
Those are great news, good for you Lee!

Thanks Luis! Its about time I moved on from LISP, I feel that I'm stagnating in that area...

- You don't need the wizard, it is very simple to setup one without that, I have installed the one that comes with ARX/SDK 2010 and it is very helpful but for ARX apps, because of the project solution skeleton that it does.

Thats handy since its not letting me install it at the moment...  :wink: I have installed the Help Documentation and can access the ObjectARX section through the VLIDE Help.

- The .NET apps I do, I normally(have) to target for specific acad versions/32/64

That's a shame, but I suppose I'll just have to accept it and move on with the learning :-)

LE3

  • Guest
Re: Getting off the Ground with .NET
« Reply #3 on: April 01, 2011, 11:33:21 AM »
You can simple set it up to: Any CPU (under properties - that it is by default) I have used .net apps compiled with latest assemblies and they run under previous versions, all depends (maybe) if you are not using anything new, and that will work for you.

If you need something more in specific, let me know.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Getting off the Ground with .NET
« Reply #4 on: April 01, 2011, 02:12:23 PM »
The wizard requires you to have the "Standard" or "Professional" version of Visual Studio, I believe.  You are using the "Express", I take it?  As mentioned, all is not lost and you might actually do a bit better without the wizard doing the hand-holding.  Pssst: look into templates.   :wink:

Depending on your AutoCAD version (2011 and earlier), Visual Studio 2008 *might* be the better choice.  VS2010 is a very good argument against early adoption.
If you are going to fly by the seat of your pants, expect friction burns.

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

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #5 on: April 01, 2011, 04:33:02 PM »
You are using the "Express", I take it?

Professional Version (I'm a student = free stuff  :lol:)

Depending on your AutoCAD version (2011 and earlier), Visual Studio 2008 *might* be the better choice.  VS2010 is a very good argument against early adoption.

I'm using ACAD2010 (student version, but I doubt that matters too much in this respect). So are you saying that VS2010 restricts what I can do in .NET, or that I simply cannot use it? I'm confused in how the version of the editor would play a part in the programming itself - but perhaps this is a feature of compiled code.

On another note, I've had another play with VS2010 using the C# sample code from here. I realise that I don't have the background knowledge of C# as yet, but I wanted to see if I could run some code to ensure that I have everything set up correctly (I wouldn't want to hinder myself before I've even started).

Now, I have opened VS2010 and started a New Project with type: C# Class Library (is this correct, or should I be choosing a console application?) - I have then pasted the C# code from that link to the editor window.

In the Solution Explorer, I went to 'References', 'Add References' and added AcDbMgd.dll and AcMgd.dll as described in the Dev Help (would I have to add these to every project I create?). These removed the majority of the 'warnings' I was receiving in the editor window regarding statements declaring the namespace, such as:

Code: [Select]
using Autodesk.AutoCAD.Runtime;
However I still receive errors on the following lines:

Code: [Select]
public static [color=red]void[/color] AddLine()
Code: [Select]
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.[color=red]ModelSpace[/color]], OpenMode.ForWrite) as BlockTableRecord;
Code: [Select]
Line acLine = new [color=red]Line[/color](new [color=red]Point3d[/color](5, 5, 0), new [color=red]Point3d[/color](12, 3, 0));
Are these errors in the code or something I have not set up correctly? As I say, I don't have knowledge of C# or how to manipulate AutoCAD with it, but I wanted to ensure I have my environment set up correctly to save trouble further down the line.

Thanks for your help guys, appreciated.

Lee

LE3

  • Guest
Re: Getting off the Ground with .NET
« Reply #6 on: April 01, 2011, 04:57:09 PM »
Lee,

Normally after doing your references (make sure you set Copy Local to false - click on your assembly name and go to properties and you will find that)

Then, for errors or warnings, simple go to those warnings on screen right-click and see if there is available the option of Resolve, click on that and most of the warnings will gone.

Give it a try... and see if helps

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #7 on: April 01, 2011, 04:58:14 PM »
Lee,
about time :)

The methods should be wrapped in a class

a piccy :
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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #8 on: April 01, 2011, 05:04:58 PM »
Normally after doing your references (make sure you set Copy Local to false - click on your assembly name and go to properties and you will find that)

Yup - saw that in the DevHelp - done :-)

Lee,
about time :)

Tell me about it...  :roll:


The methods should be wrapped in a class

a piccy :

A picture is worth a 1000 words - thanks Kerry!

Then, for errors or warnings, simple go to those warnings on screen right-click and see if there is available the option of Resolve, click on that and most of the warnings will gone.

Give it a try... and see if helps

Thanks Luis, I'll look into this after I've tried Kerry's suggestion and report back to you guys :-)

Thanks for the advice!

Lee

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #9 on: April 01, 2011, 05:14:16 PM »

Also :
From the menu ;  Project->Properties
Application : set Target Framework to .Net Framework 3.5
Build : Platform Target ; set for Any CPU
Debug : Set Start Action ; Start external Program -> select path to Acad.exe.


In your acad.exe folder do you have a file named acad.exe.config.

Mine reads like this
Code: [Select]
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

<!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
   <runtime>       
<generatePublisherEvidence enabled="false"/>   
   </runtime>
</configuration>
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.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #10 on: April 01, 2011, 05:19:40 PM »
Hi Lee,

Welcome to the .NET adventure...

I can understand you want to try a routine into AutoCAD, but...

I think it's a good way to first learn some .NET and C# for Windows (not related to AutoCAD), there are certainly some good tutorials and books in English...
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #11 on: April 01, 2011, 05:35:43 PM »

Also :
From the menu ;  Project->Properties
Application : set Target Framework to .Net Framework 3.5
Build : Platform Target ; set for Any CPU
Debug : Set Start Action ; Start external Program -> select path to Acad.exe.

Thanks - I wouldn't have figured that out - first time I tried to load the .dll it reported that it was built in a later framework or something along those lines (Target Framework was set to 4.0).

BTW, should I be netloading the dll in the 'bin' > 'Debug' folder?

In your acad.exe folder do you have a file named acad.exe.config.

Mine reads like this
Code: [Select]
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

<!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
   <runtime>       
<generatePublisherEvidence enabled="false"/>   
   </runtime>
</configuration>

Yes, I have that file:

Code: [Select]
<configuration>
   <startup>
<!--We always use the latest version of the framework installed on the computer. If you
are having problems then explicitly specify .NET 2.0 by uncommenting the following line.
<supportedRuntime version="v2.0.50727"/>
-->
   </startup>
<!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
   <runtime>       
<generatePublisherEvidence enabled="false"/>   
   </runtime>
</configuration>

Hi Lee,

Welcome to the .NET adventure...

I can understand you want to try a routine into AutoCAD, but...

I think it's a good way to first learn some .NET and C# for Windows (not related to AutoCAD), there are certainly some good tutorials and books in English...

Thanks Gile :-)

That is my intention - starting from the ground up. But I just wanted to ensure I had my environment set up correctly before I delved too deeply to save some headaches in the future.

Thanks for your support :-)

Lee

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #12 on: April 01, 2011, 05:37:46 PM »
Just tried loading the example code and, after loading, typed 'AddLine' and all worked correctly! I'm off the ground  8-)

I noticed it was slightly slow to create the line though (when I say slow, I mean 0.2 secs) would this be because it has to load some dll's when called for the first time?

sinc

  • Guest
Re: Getting off the Ground with .NET
« Reply #13 on: April 01, 2011, 05:38:33 PM »
I can understand you want to try a routine into AutoCAD, but...

I think it's a good way to first learn some .NET and C# for Windows (not related to AutoCAD), there are certainly some good tutorials and books in English...

I'd say the exact opposite...

Since Lee's already quite familiar with Autocad and Autocad customization using other languages, I think it would be a lot faster/easier to just start doing things in Autocad, as opposed to starting with exercises that create unwanted stand-alone apps.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #14 on: April 01, 2011, 05:45:29 PM »
as opposed to starting with exercises that create unwanted stand-alone apps.

That's the route I took with C++ (also taking a module as part of my Maths degree), but this resulted in many console applications and hit a road-block as to how to progress.

I think I'll follow a mixture of the two, learn the C# syntax, and see how to use it for applications in AutoCAD - that way I have a 'purpose' for my code.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #15 on: April 01, 2011, 05:46:11 PM »
One thing I would note...

C#  ~  41 lines

LISP:

Code: [Select]
(defun c:AddLine nil
  (entmakex '((0 . "LINE") (10 5 5 0) (11 12 3 0)))
  (princ)
)

 :lol:

I think I've been spoiled with LISP

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #16 on: April 01, 2011, 05:47:03 PM »
< .. >
BTW, should I be netloading the dll in the 'bin' > 'Debug' folder?

Yes, If you want to debug ( build can be set to either Debug or Release)


Just tried loading the example code and, after loading, typed 'AddLine' and all worked correctly! I'm off the ground  8-)

I noticed it was slightly slow to create the line though (when I say slow, I mean 0.2 secs) would this be because it has to load some dll's when called for the first time?

Good !

Yes ... you will come across the term JIT ( 'Just in Time' Compilation)

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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #17 on: April 01, 2011, 05:51:22 PM »
< .. >
BTW, should I be netloading the dll in the 'bin' > 'Debug' folder?

Yes, If you want to debug ( build can be set to either Debug or Release)

Gotcha, Debug when debugging, Release when releasing  :-)

Just tried loading the example code and, after loading, typed 'AddLine' and all worked correctly! I'm off the ground  8-)

I noticed it was slightly slow to create the line though (when I say slow, I mean 0.2 secs) would this be because it has to load some dll's when called for the first time?

Good !

Yes ... you will come across the term JIT ( 'Just in Time' Compilation)

Cool, thanks Kerry for all your help  8-)

sinc

  • Guest
Re: Getting off the Ground with .NET
« Reply #18 on: April 01, 2011, 05:58:12 PM »
I think I've been spoiled with LISP

As you get into it, I think you'll discover the opposite...

Little things might be simpler in Lisp.  But as you get into larger efforts, .NET code tends to be far more readable than LISP.  The tools in your .NET IDE are far superior to the VLIDE.  And .NET has a wealth of pre-existing classes that encapsulate hundreds (maybe thousands) of tasks that you typically would have to code yourself in Lisp (if the task can even be done in Lisp).

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #19 on: April 01, 2011, 06:01:55 PM »
You're welcome.
...

Regarding the Wizard.
Personally I'd forgo it's use.
<You> need to understand what's going on, not just accept what's thrown.
The time taken to setup manually is minor ... considerably less than the time it takes to clear out all the bumpf the wizard adds.
[/personal opinion]

added:
besides, I find the mental process involved in a manual setup rather cathartic.
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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #20 on: April 01, 2011, 06:17:23 PM »
I think I've been spoiled with LISP

As you get into it, I think you'll discover the opposite...

Little things might be simpler in Lisp.  But as you get into larger efforts, .NET code tends to be far more readable than LISP.  The tools in your .NET IDE are far superior to the VLIDE.  And .NET has a wealth of pre-existing classes that encapsulate hundreds (maybe thousands) of tasks that you typically would have to code yourself in Lisp (if the task can even be done in Lisp).

That's good to hear. Being a complete beginner in this area, I definitely have a lot to discover (even with VS itself!).

Regarding the Wizard.
Personally I'd forgo it's use.
<You> need to understand what's going on, not just accept what's thrown.
The time taken to setup manually is minor ... considerably less than the time it takes to clear out all the bumpf the wizard adds.
[/personal opinion]

added:
besides, I find the mental process involved in a manual setup rather cathartic.

I think I'll take your advice. To be honest, I need all the advice I can get at this point to avoid following the wrong route in my learning and to prevent myself from developing bad habits early on. I distinctly remember when I first learnt LISP that it was about a month before I discovered the VLIDE, don't know how I coped with Notepad...

With regard to the 'bumpf' that is added by the wizard - I'm surprised by the quantity of files in a VS Project! I write a single .cs file and receive a whole directory!

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Getting off the Ground with .NET
« Reply #21 on: April 01, 2011, 06:29:00 PM »
That is good news,
I have been debating learning Lisp so I could see how you guys think but this way I do not have to look at
Code: [Select]
(12 34((sset 34 34(56) 66 (entgo 67 )
(setq l (35 wathma '34')
......................


and think uh????

great news.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #22 on: April 01, 2011, 06:40:25 PM »
 :-D

Thanks Jeff  :-)

LE3

  • Guest
Re: Getting off the Ground with .NET
« Reply #23 on: April 01, 2011, 06:50:37 PM »
i tried on my early c# days to port my lisp routines, that help me but very little, until i started to think just in c# (same happen when learned c++) so forget all about lisp right now  :evil:  :-P

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #24 on: April 01, 2011, 07:25:38 PM »
Even playeng with .NET, you may keep on LISPing (see this thread)
Speaking English as a French Frog

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Getting off the Ground with .NET
« Reply #25 on: April 01, 2011, 10:37:44 PM »
I have attempted to run the 'ArxWizads.msi' file  --> This informs me that I need an instance of MS Visual Studio 2008 on the target machine.

Those wizards are ObjectArx(C++) and you can not use or build with VS 2010 until 2012 I think but does not matter since you are using .NET.
For .NET wizards go here and download AutoCAD 2011 .Net Wizards.zip ---(Compatible with AutoCAD 2011 and 2012)  
I had problems with 64-bit but make sure before you un-zip right-click and select properties and click unblock button if available.

DOH! I noticed you are using 2010 I still have the zip file downloaded for 2010 .NET wizards if needed

This will be way more useful MgdDbg


LE3

  • Guest
Re: Getting off the Ground with .NET
« Reply #26 on: April 02, 2011, 01:05:13 PM »
Even playeng with .NET, you may keep on LISPing (see this thread)

That it is for sure Gile!

I was joking on: so forget all about lisp right now  :lol:

I'm still use lisp once in a while, not that much, but it is there :)

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #27 on: April 02, 2011, 02:08:42 PM »
i tried on my early c# days to port my lisp routines, that help me but very little, until i started to think just in c# (same happen when learned c++) so forget all about lisp right now  :evil:  :-P

I'll definitely never be able to forget LISP - that shall haunt me for life I think  ;-)

Even playeng with .NET, you may keep on LISPing (see this thread)

Thanks Gile - another great thread to link the two languages :-)

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #28 on: April 19, 2011, 08:11:38 AM »
Over the past few days I've been delving into this a little more: following a C# tutorial and also trying a few programs from the .NET forum. Inevitably, I have a few more (novice) questions if you have time  :-)

After browsing the .NET Geometry Routine thread, I thought I'd try this code from Gile (works great BTW).

This is the procedure I followed:

1) Open VS2010, created a New Project (Visual C# Class Library) named 'ConvexHull'.

2) Copied Gile's code to a '.cs' file called 'ConvexHull.cs' within said project.

3) Added 'AcDbMgd.dll' and 'AcMgd.dll' to the list of References and set 'Copy Local' to false.

4) Set the Project Properties to '.NET Framework 3.5' and Build for 'Active (Any CPU)'.

5) Build the Solution (F6)

6) Opened AutoCAD to a Drawing, NetLoad'ed the 'bin > Debug > ConvexHull.dll' file

7) Typed 'ch' to start the program ==> All worked fine.


Now for the Questions:

*  Firstly, am I following the correct procedure to test the code I linked to?

*  Are the Project/File names arbitrary?

*  In Step (3):

     i)  Is there a way to automatically have those DLLs added as References?

    ii)  How does one know which DLL's are required, i.e. would I always need both AcDbMgd and AcMgd?

   iii)  VS2010 automatically adds quite a few other References:

       

        Are these needed?

*  In Step (4):  Is is possible to automatically set these properties?

*  In Step (5):  What is the difference between Building the Solution (F6) and Building using (Shift+F6)?



Sorry for the long post - It seems the more I delve into this, the more questions I have...

Thanks for your time and advice.

Lee


gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #29 on: April 19, 2011, 09:15:52 AM »
Quote
*  Firstly, am I following the correct procedure to test the code I linked to?

Yes it's correct, but you can do it easier (not sure about translations, but may be closed to):
- right click the Project and choose 'Properties', in the 'Debug' tab hit 'Start external program' and browse to the acad.exe you want to start.

- you can also automate the NETLOADing adding this LISP expression to an acaddoc.lsp or MNL file :

Code: [Select]
;; Check if debugging .NET & load the DLL if so
(defun DebugNET (/ path fn)
  (setq path (getvar "DWGPREFIX"))
  (if (wcmatch (strcase path) "*bin\\DEBUG*")
    (foreach fn (vl-directory-files path "*.DLL" 1)
        (if (wcmatch (strcase path) (strcat "*\\" (vl-filename-base (strcase fn)) "\\*"))
          (command "._NetLoad" fn)
        )
      )
  )
  (princ)
)

Another way to automate NETLOADing on debugging is to add a script file to your project:
- right click the project > Add > New element > Text file
- copy the following string in the file and save it as "start.scr" (take care it finish with a space):
Code: [Select]
netload "..\..\bin\debug\ConvexHull.dll" - in the (now well known) project 'Property' > Debug tab, add to 'Arguments of the command line':
Code: [Select]
/nologo /b "..\..\bin\debug\start.scr"
Using the LISP way or the script way when you type F5 in Visual Studio AutoCAD starts and the dll is NETLOADed.
More, you can add a specific filename in the 'Arguments of the command line' so that AutoCAD starts and open this file:
Code: [Select]
"D:\Some test drawing\ConvHull.dwg" /nologo /b "..\..\bin\debug\start.scr".

Quote
*  Are the Project/File names arbitrary?
Yes.

Quote
*  In Step (3):
I recommand you to save some projects as Templates (after removing unusefull code):
File menu -> 'Export the template'
All references, properties, script file, and so on wil be saved with this template and Visual Studio will purpose you to choose it ine the New project window.
« Last Edit: April 24, 2016, 12:42:37 PM by gile »
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #30 on: April 19, 2011, 09:18:37 AM »
Fantastic - many thanks for your time Gile.

I shall take some time to look into implementing some of your suggestions.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Getting off the Ground with .NET
« Reply #31 on: April 19, 2011, 10:25:15 AM »
Gile, I am having trouble getting the scr to load, it keeps saying cant find.  Did you set a working directory on debug tab?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #32 on: April 19, 2011, 10:40:17 AM »
I forgot something when using the script route:
In the 'start.scr' properties, set 'Copy to Output Directory' to 'Copy always' or 'Copy if newer' (see first picture).
If a script file is saved with your template, you'll only have to change the Assembly name in the script.

As I see my VS 2008 F# module is in English, i add a screenshot of the the project property window too.
The 'ConvHull.dwg' file is in the same folder as the solution so I used a relative path. Notice the path is within quotes and a space between the path and the command line arguments is required.
Speaking English as a French Frog

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Getting off the Ground with .NET
« Reply #33 on: April 19, 2011, 10:41:58 AM »
I've had so many problems trying to go the scripted netload route I gave up.  Now I just manually netload.  Not *that* much more work, since I usually have to do some set up in a test drawing anyways.
If you are going to fly by the seat of your pants, expect friction burns.

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

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Getting off the Ground with .NET
« Reply #34 on: April 19, 2011, 10:46:33 AM »
yea, this is beginning to be a PITA.  I was just trying it because it was a new way to netload
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Getting off the Ground with .NET
« Reply #35 on: April 19, 2011, 10:47:10 AM »
What is weird is it trys to load the dll file, but cancels out.  If I manually type in what is in the scr file, it loads fine.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #36 on: April 19, 2011, 11:12:22 AM »
Now for the Questions:

Here's where I am so far:

*  Firstly, am I following the correct procedure to test the code I linked to?

Confirmed (Gile)

*  Are the Project/File names arbitrary?

Yes (Gile)

i)  Is there a way to automatically have those DLLs added as References?

Using Template (Gile)

ii)  How does one know which DLL's are required, i.e. would I always need both AcDbMgd and AcMgd?

Unresolved.

iii)  VS2010 automatically adds quite a few other References:


Are these needed?

Unresolved.

*  In Step (4):  Is is possible to automatically set these properties?

Using Template (Gile)

*  In Step (5):  What is the difference between Building the Solution (F6) and Building using (Shift+F6)?

Unresolved.



With regards to using the Script for NetLoading - for the moment I think I shall stick to manually NetLoading the DLLs into AutoCAD, since I shall only be doing so to test code and not for working purposes. And, although the Script may be more streamline with fewer steps - I think I'll wait til I'm more confident in what I'm doing at the moment.

Thanks once again guys!

Lee

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #37 on: April 19, 2011, 11:39:00 AM »
First, it's curious you have issues with the script way, I use it many times per day and don't have no problem.
IMO, if the script is launched (see the command line when AutoCAD starts) and the dll isn't found, maybe the script isn't correct (wrong assembly name...)
If the script isn't launched, maybe the command line arguments are wrong.

Anayway, the LISP solution works too (I used it a long time).

Quote
ii)  How does one know which DLL's are required, i.e. would I always need both AcDbMgd and AcMgd?
Yes, AcDbMgd.dll and AcMgd.dll have to be referenced (and copy local set to false) for every AutoCAD .NET project.
Some projects may require some other(s) one(s).

Quote
VS2010 automatically adds quite a few other References:
<snip>
Are these needed?
That depends what uses your project.
In a first time don't care about these, they're all set to 'copy flase' and allow you to access to many libraries you 'may' need, if you don't use them, they won't interact with your program.

Quote
*  In Step (5):  What is the difference between Building the Solution (F6) and Building using (Shift+F6)?
A solution may contains many projects 'Building the Solution (F6)' build the whole solution (every project it contains) 'Building (Shift+F6)' only build the selected project in the Solution Explorer.
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #38 on: April 19, 2011, 11:43:55 AM »
Excellent!

Thanks for your explanations Gile - your time is appreciated.

Now, time for more studying  :-)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Getting off the Ground with .NET
« Reply #39 on: April 19, 2011, 02:21:01 PM »
i figured it out, I needed a return at end of line in scr file
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

StykFacE

  • Guest
Re: Getting off the Ground with .NET
« Reply #40 on: April 19, 2011, 02:35:39 PM »
This thread makes me drool since Lee is about to be more awesomer of a programmer.  :laugh:

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting off the Ground with .NET
« Reply #41 on: April 19, 2011, 02:41:18 PM »
i figured it out, I needed a return at end of line in scr file
I'm glad you got it.
A space (equals a return in the cryptic script langauge) was missing at the end of the line, I correct the message.
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #42 on: April 19, 2011, 03:56:22 PM »
This thread makes me drool since Lee is about to be more awesomer of a programmer.  :laugh:

Thanks Styk, although I think it'll be some time before I am anywhere near the level of Kerry or Gile to name a few.  :kewl:

StykFacE

  • Guest
Re: Getting off the Ground with .NET
« Reply #43 on: April 19, 2011, 04:44:49 PM »
I'm sure that's true but given the fact that I've chosen my career path to be CAD related, I'll be around for awhile. I'm more wanting to see what nifty program you create more from curiosity than anything. You've always had such a good creative forecast when developing your programs that I respectively admire.  8-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #44 on: April 19, 2011, 06:55:06 PM »

Quote
*  In Step (3):
    iii)  VS2010 automatically adds quite a few other References:
    Are these needed?
   
   The references are needed if the referenced dll's are used.
   If the References are not used having them listed will not cause any undue overhead.
   ... They are just references needed to resolve class definitions   

   //------------
Quote
*  In Step (5):  What is the difference between Building the Solution (F6) and Building using (Shift+F6)?
   F6 Builds the Solutuion ( may be several Projects).
   SHIFT-F6 Builds the specific current Project.   
   Building using F6 and SHIFT-F6 just build the assembly, and do not interactively start and link to AutoCAD.
   The benefit of a debug build is primarily that you can create a link between the IDE and AutoCAD.
   This can only be achieved by starting the process from the IDE.
   To achieve this, press F5 not F6. F5 will allow the use of code breakpoints and  perusal of variable values via the Intermediate and Locals windows.
   ... very helpfull in understanding what is going in in wour methods.
   
   //------------
   Script files are also handy for writing a reminder to the AutoCAD CommandLine regarding Command Names and descriptions
   .. a little easier than having an initialiser class for each project.
   
   Keep in mind that if you DO use netload from the CommandLine a History Folder will be available from the NetLoad Dialog after the initial load.
   
   //------------
   
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.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Getting off the Ground with .NET
« Reply #45 on: April 19, 2011, 07:20:00 PM »
Many thanks for those clarifications Kerry - appreciated. With regards to the Referenced DLL's, I realise such references are needed if they contain class definitions for classes called by the code, but the question really was - how do you know which class definitions are contained in which DLL. But as you say, I might as well include them all and the let the compiler grab what's needed.

I meant to ask you also - in the picture you attached earlier in the thread, how do you obtain the dotted lines matching the curly braces?

Thanks once again!

Lee

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting off the Ground with .NET
« Reply #46 on: April 19, 2011, 07:55:48 PM »
< .. >

I meant to ask you also - in the picture you attached earlier in the thread, how do you obtain the dotted lines matching the curly braces?

Thanks once again!

Lee

One of these does the trick.
 CodeRush Xpress
http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/

Productivity Power Tools
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

PowerCommands for Visual Studio 2010
http://visualstudiogallery.msdn.microsoft.com/e5f41ad9-4edc-4912-bca3-91147db95b99/

added:
or
StructureAdornm​ent
http://visualstudiogallery.msdn.microsoft.com/203f22f4-3e9f-4dbb-befc-f2606835834e/

AllMargins 
http://visualstudiogallery.msdn.microsoft.com/465a0d53-5133-4edd-a0cd-94484fe3d853/
Quote
Introduction:
     This is a compilation of the OverviewMargin and several other extensions that use the OverviewMargin. The OverviewMargin shows
     a margin on the right side of the editor that logically maps to the entire file (similar the the vertical scroll bar). Unlike
     the scroll bar, it maps to the entire file and can contain other margins that provide more information about the file.
 

Included extensions:
         CaretMargin         http://visualstudiogallery.msdn.microsoft.com/en-us/a893687b-f488-49eb-ad91-c59d86daad34.
         ErrorsToMarks       http://visualstudiogallery.msdn.microsoft.com/en-us/0fc52c83-0ab3-485d-a917-2006966eec7a.
         MarkersToMarks      http://visualstudiogallery.msdn.microsoft.com/en-us/89deee06-0ed0-4347-81a6-942a3f2874af.
         OverviewMarginImpl  http://visualstudiogallery.msdn.microsoft.com/en-us/2e9f37b7-5a1f-4c47-930b-379b2d0fd596.
         StructureAdornment  http://visualstudiogallery.msdn.microsoft.com/en-us/203f22f4-3e9f-4dbb-befc-f2606835834e.
         StructureMargin     http://visualstudiogallery.msdn.microsoft.com/en-us/fe432eb5-c538-47a9-9919-fba1a8f5b261.
 
        BlockTagger         The definition of an API to get the structure of a code file.
         BlockTaggerImpl     An implementation of the BlockTaggerAPI for C/C# and VB files.
 
        OverviewMargin      The definition of an API for creating margins that map to the entire file.
 
        SettingsStore       The definition of an API to load and save editor options across sessions.
         SettingsStoreImpl   An implementation of the SettingStore API that uses IVsSettingsStore to access the system registry.


or if you fancy browsing
http://visualstudiogallery.msdn.microsoft.com/

« Last Edit: April 19, 2011, 08:23:31 PM by Kerry »
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.