A while back I bought a book that has helped me to learn VB.Net programming for AutoCad. The book came with a CD that had a template that I would use to create my programs for AutoCad.
I would like to be able to:
1. Create my own template to use when writing code for AutoCad, and
2. Associate the template with my Visual Studio tool so I can then pick the template when I start a new project.
I would also like to know if there is anything else involved (like adding the AcDbMgd.dll and AcMgd.dll files to the reference).
Does anyone know of a place where I can find this info?
Ok, I've created a template, it looks like this:
Imports Autodesk.AutoCAD Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.ApplicationServices.Application Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.LayerManager Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Windows Imports System.Runtime.InteropServices Public Class Class1 <CommandMethod("COMMAND_NAME_HERE")> _ Public Sub COMMAND_NAME_HERE() MsgBox("Hello World!") End Sub End Class
It's in Class1.vb
In the references I've added the AcDbMgd.dll and the AcMgd.dll from C:\ObjectARX 2010\inc-x64.
I picked File > Export template and it did it, but when I try to use it, I get the following errors:
"Namespace or type specified in the Imports 'Autodesk.AutoCAD' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."
I get that error for the first 9 Imports.
Obviously I've left something out. Can anyone tell me what else I need to do to get my template to work?
Thank you for the link. I checked it out, downloaded and ran the wizrd. It creates a plugin. Will I use that to create my individual programs? It contains "myCommands.vb" and "myPlugins.vb". Is this the template or do I need to export a template from this? Like I said, I'm new at this template thing, so you'll have to forgive my ignorance.
Check this link out:
But basically once you install the Autocad Visual Studio Wizard it gives you a standard template.
It's not really difficult. It's just seem confusing as there is a lot of new information.
Thanks for the link. I had downloaded the dotNet Wizards file earlier and ran it. I saw the two vb files in the project. I wasn't used to seeing both I guess. The template that came with the book I bought only had one .vb file.
So I'm curious, is there a way to manually create a template to use with AutoCad without the use of a wizard or does everyone use something like this wizard? If you can create one manually, do you know what the steps are?
You can create Project Templates and Item templates(Adding new class, etc....).
They are contained in the ProjectTemplate or ItemTemplate folder in VS install folder, So you can see examples.
If you have the Autodesk wizards installed and VS installed to default location then autodesk wizard is
(Will be a little different if 32bit system)
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Autodesk
New item templates for Windows Forms
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\VisualBasic\Windows Forms\1033
Notice the pattern by comparing the two for Project or Item, Programming Language, and Project Types
Creating Project and Item Templates shows an overview
It explains How to: Substitute Parameters in a Template example is Autodesk template uses 'namespace $safeprojectname$' and all $safeprojectname$ are replaced with your namspace defined.
How to: Use Wizards with Project Templates shows how to have a form open to enter data to pass to the newly created project.
The first link is the base overview and can get to other links mentioned plus many more for deployment and othe more advanced topics.
Start with some of our most frequented solutions to get help installing your software.