Tutorial - How to create a Visual Studio template

ed57gmc
Mentor
Mentor

Tutorial - How to create a Visual Studio template

ed57gmc
Mentor
Mentor

Hi @_gile  I updated your tutorial for AutoCAD 2023 and Visual Studio 2022. See attached.

 

For others, this tutorial is based upon one that @_gile created on his website. It is also helpful for learning how to create a new project, since it contains the code for the classes necessary for a plugin to work. After you create your template, you can use it to create your first plugin.

 

**Updated for 2024.

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

Reply
Accepted solutions (1)
3,019 Views
24 Replies
Replies (24)

kdub_nz
Advisor
Advisor

To @ joshuaW5HNW

(sorry for the tag Ed )

 

Just curious, 

Which AutoCAD build are you using ?

Which AutoCAD builds are installed ?
Which Template ( and from where ) did you use ?

 

Have you had memory issues ?
Have you had a recent unsucessful windows update ?



Can you run an ACAD session normally ?
Can you load and run a previously build DLL ( that you built ) for that version ?


Can you make a new project without the template ?

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

class keyThumper<T> : Lazy<T>;      another  Swamper

0 Likes

Yehoshua18
Enthusiast
Enthusiast

- Civil 3d as AutoCAD 2021,

- I have installed: Civil 3D 2021, Civil 3D, 2022, and AutoCAD 2020
- I used the template creation instructions provided here. They used to work fine apart from the 

- I haven't noticed any memory issues

- Windows Updates are all installed properly

- I can run AutoCAD outside of Visual Studio normally

- When compiling the project, it successfully compiles. Just it wont successfully open AutoCAD anymore.  When I start a separate instance of AutoCAD outside of Visual Studio, i can netload the DLL just fine, and it runs perfectly. 

- I can make a new project without the template. 

* I restarted my computer and the problem went away. But this is still occurring intermittently. Meaning I can go a day now and the project will refuse to open AutoCAD, and it's only resolved by restarting the computer. 

 

Thanks!

0 Likes

_gile
Mentor
Mentor

Maybe the fact that the error occurs intermittently is due to the product started (Civil3d or AutoCAD).

You should try to force the start of a specific product. This can be done by modifying the command line arguments either from Visual Studio in the Debug tab; or by directly modifying the StartArguments tag in the .csproj file of the template (see this topic).

<StartArguments>/nologo /product ACAD /b "start.scr"</StartArguments>

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

john9XGED
Contributor
Contributor

@ed57gmc this is incredible! Are there any sources that would show a newbie how to modify this for Civil 3D? Is that even necessary?

0 Likes

ed57gmc
Mentor
Mentor

Sure, once you create the project in VS, just add code to the project's Commands.cs file for C3D, as shown on page 6, e.g. references and using statements. Then finish creating your template. Since I don't have C3D, I can't tell you what base dll's it loads that you might want to reference. Maybe another user can tell you. You can also get a clue by looking at what gets reported when C3D loads by looking at the command line history F2. Your possible choices would be the files included in the C3D sdk.

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