my first autocad plugin

my first autocad plugin

stefanveurink68AXD
Advocate Advocate
4,509 Views
27 Replies
Message 1 of 28

my first autocad plugin

stefanveurink68AXD
Advocate
Advocate

Dear everybody, 

 

I told myself to not ask for help here and figure it out myself but it's been three days now and i still can't figure out whats going wrong. 

 

I'm trying to follow the steps from your tutorial 

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/simplecontent/content/my-first-aut...

 

I installed the four needed softwares, knowing: 

- autocad 2018

- visual studio community 2015 (and 2017 and 2019 but 2015 was needed for the wizard)

- the objectarx sdk (2018)

- the autocad.net 2018 wizard

 

however, when I'm at step two from lesson 1 (https://knowledge.autodesk.com/support/autocad/learn-explore/caas/simplecontent/content/lesson-1-the...) I can't find the 'autodesk' under 'visual basic'. 

 

strange enough I do see it under "visual c++', there are 2 templates there, but with different names (and i can only start one of them without getting some strange error). 

 

anybody know whats wrong? the lesson tells me to get the visual-basic autocad2018 vb plug-in, why don't i see this one appear?

 

thanks.

 

0 Likes
4,510 Views
27 Replies
Replies (27)
Message 2 of 28

_gile
Consultant
Consultant

Hi,

 

Assuming you start with AutoCAD .NET, I'll give you a few recommendations:

  • Learn C# instead of VB, because you'll find more examples and help in C# than VB.
  • Learn how to build a project from scratch and how to create your own templates (thanks again to @Ed__Jobe for his translation) instead of using wizards which imposes on you a version of Visual Studio.
  • Start with an AutoCAD .NET Training Lab from this page instead of "My First AutoCAD Plug-in" because the first one starts with the basics while the second irelated to the Overrule which is an advanced API.

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 28

stefanveurink68AXD
Advocate
Advocate

Thanks, I'll do this. 

 

By experiences with programming (outside Autocad) in the past I know getting started is the mostly the toughest part, so thanks for giving me some direction! 

0 Likes
Message 4 of 28

stefanveurink68AXD
Advocate
Advocate

So, like you recommended I just started the dotnet training.... 

 

Lab 1 works great. 

 

In Lab 2 however I need to install the wizard, seems like the one I referred to in the first post..... 

By the way the download link in the word-document doesn't work.

 

So still same problem. Don't see the template neither an 'Autodesk' category under the visual c# like the training says it would show. 

 

Any ideas how to solve this problem?

0 Likes
Message 5 of 28

_gile
Consultant
Consultant

The Wizard is just a way to start a new AutoCAD project from a template, i.e. a class library project with AutoCAD API references as you build from scratch in Lab 1.

So, instead of using the Wizard to create a new project, you can simply redo the same thing you did with Lab1 or, better, learn how to to create your own project template for AutoCAD which is not so difficult and let you improve your knowledge about what is a Visual Sutdio project.

When you'll have created some new project with some Commands.cs class, you should be able to go on the Lab 2 from, just after the Wizard installation part.

 

Most of us who started with AutoCAD .NET before AutoCAD 2016 have never use a Wizard to start a new project.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 28

stefanveurink68AXD
Advocate
Advocate

In some way I agree with you. It's good to be able to set up stuff yourself. 

 

Only thing I'm affraid about is that there's settings in the template that I haven't setup myself in lesson 1. To be sure the setup of the project is right I would prefer to work with the template since that is what the lesson is based on. 

 

Next to that I don't expect myself to setup the whole environment correctly (what the template should do) as long as i'm not even able to get the template work properly... it's kind of the same problem. 

 

So if there's no other options to get the template working there's no choice left then just try to figure out stuff myself but if anyone got any idea about why the installed template doesn't show up it would probably save me a lot of (unneccessary) troubles and headaches :-). 

 

thanks anyways!

 

0 Likes
Message 7 of 28

_gile
Consultant
Consultant

You can also find some 'out of the box' templates from my own here.

You can use them whatever the Visual Studio version (tested with VS2012, VS2013, VS2015, VS2017).

Do not forget to 'unblock' the downloded ZIP files.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 28

stefanveurink68AXD
Advocate
Advocate

Thanks!

 

Nice website btw! Pitty enough I don't speak french very well but I'll sure check it out very soon!

0 Likes
Message 9 of 28

Anonymous
Not applicable

On my yearly (and till now always failing) attempt to switch from VBA to NET I came across this very useful post which eventually led me to the goal of a running plugin template.

 

But I also found out that the file "Template_Csharp_Ed_Jobe.pdf" linked to create your own templates shows some little discrepancies:

 

1)  mainly, at page 9, when its says (red text to be substituted):

 



Open the My Template.vstemplate file in a text editor (it is an XML file) and replace:
<ProjectItem ReplaceParameters="false" TargetFileName="Commands.cs">Commands.cs
</ProjectItem>
With:
<ProjectItem ReplaceParameters="true" TargetFileName="Commands.cs">Commands.cs
</ProjectItem>
it should be read (green text to be adopted):


Open the My Template.vstemplate file in a text editor (it is an XML file) and replace:
<ProjectItem ReplaceParameters="false" TargetFileName="start.scr">start.scr
</ProjectItem>
With:
<ProjectItem ReplaceParameters="false" TargetFileName="start.scr">start.scr
</ProjectItem>

 


 2) moreover it also shows:

 


TargetFileName="ThisProject.cs">ThisProject.cs</ProjectItem>
</Project>.

    of which it'd be fine to know the use of

0 Likes
Message 10 of 28

_gile
Consultant
Consultant

Here's my translation of the original French version.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 11 of 28

Anonymous
Not applicable

Which confirms the revisions needed to Ed Jobe’s pdf of which you attacched a link in a post of yours

0 Likes
Message 12 of 28

Anonymous
Not applicable

Anyway, all that back and forth from VS to Autocad is really nerves consuming...

 

I’d be happy to know if there is any way to avoid:

- manual calling of the “command” you’re debugging

- exiting Autocad and stopping programm ececution in order to make any code fixing

- launching Autocad everytime (wouldn’t it be possibile to use a running instance of Autocad?)

0 Likes
Message 13 of 28

Ed__Jobe
Mentor
Mentor

@Anonymous wrote:

Which confirms the revisions needed to Ed Jobe’s pdf of which you attacched a link in a post of yours


Thanks for catching that mistake. Attached is a revised version.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 14 of 28

_gile
Consultant
Consultant

@Anonymous 

First, you have to keep in mind C# is a compiled language, not an interpreted language as AutoLISP or VBA.

 


@Anonymous wrote:

I’d be happy to know if there is any way to avoid:

- manual calling of the “command” you’re debugging


Simply add a call to the concerned command at the end of the start.scr file.

 

 


@Anonymous wrote:

I’d be happy to know if there is any way to avoid:

- exiting Autocad and stopping programm ececution in order to make any code fixing

- launching Autocad everytime (wouldn’t it be possibile to use a running instance of Autocad?)


You could use Edit & Continue feature, but some issues with Mtexts maight occur (see here). By my side I never used Edit & Continue this is why I use this kind of template.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 15 of 28

Anonymous
Not applicable

thanks Ed

 

It'd be great you could explain the meaning of the following lines:

 

<ProjectItem ReplaceParameters="true"
TargetFileName="ThisProject.cs">ThisProject.cs</ProjectItem>.



which doesn't show in my "My Template.vstemplate" file

 

BTW, should you be interested in further "polishing" your pdf, you could also:

- check all AutoCAD 2017-> 2018 references 

- check "AutoCAD2018Plugin" -> "Acad2018Plugin"

 

 

0 Likes
Message 16 of 28

Anonymous
Not applicable

Thanks Gile for your answers

 

 

1) "Simply add a call to the concerned command at the end of the start.scr file."

 

I "suspected" that, but neither you nor Ed mentioned it: is it because of some annoying side effect?

 

 

2) "By my side I never used Edit & Continue this is why I use this kind of template."

 

so, to code for AutoCAD in NET you must suffer from all that "to and through" AutoCAD

this is the very reason of my yearly failures till now

 

0 Likes
Message 17 of 28

Ed__Jobe
Mentor
Mentor

@Anonymous wrote:

thanks Ed

 

It'd be great you could explain the meaning of the following lines:

 

<ProjectItem ReplaceParameters="true"
TargetFileName="ThisProject.cs">ThisProject.cs</ProjectItem>.



They typical acad plugin is divided into two logical blocks, an area for Project specific code and and area for acad commands. ThisProject.cs is a file that adds methods for your project. It has an Initialize method and a Terminate method. This is where you can add code that applies to the project level. e.g. reading a registry value upon initialization or setting a reg var upon termination. You may not need it for every project, but the template should add it. You can also use it to store other methods and functions. Some create another "toolbox" class for this type of code.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 18 of 28

_gile
Consultant
Consultant

@Anonymous wrote:

Thanks Gile for your answers

 

 

1) "Simply add a call to the concerned command at the end of the start.scr file."

 

I "suspected" that, but neither you nor Ed mentioned it: is it because of some annoying side effect?


I didn't mention that because I supposed someone starting with .NET already knows how works an AutoCAD script.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 19 of 28

Ed__Jobe
Mentor
Mentor

I should have mentioned that the template that Gilles created doesn't include project.cs. The screenshot shows my project file. I need to update the pdf so it is consistent. I included it in my project as a carryover from the original ones supplied by the Autodesk installer. For now, I'll attach the file so you can include it in your project. Attached is my template, you can extract it from there.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 20 of 28

Anonymous
Not applicable

I didn’t know autocad scripts are necessary for NET coding

In this case, I’m out of the game since I know nothing about autocad scripts (except “test.scr”...)

 

Thanks for clearing that out

0 Likes