.NET

Reply
Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 1 of 9 (466 Views)

Help Associating VB.Net with AutoCad

466 Views, 8 Replies
01-17-2012 07:06 AM

Hello,

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?

 

Thanks,

Mark

Valued Mentor
gasty1001
Posts: 471
Registered: ‎04-11-2010
Message 2 of 9 (465 Views)

Re: Help Associating VB.Net with AutoCad

01-17-2012 07:11 AM in reply to: mgorecki
Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 3 of 9 (460 Views)

Re: Help Associating VB.Net with AutoCad

01-17-2012 07:37 AM in reply to: gasty1001

I forgot to add that we are using AutoCad 2010 (soon to move to 2012 hopefully) and Visual Studio 2010.

Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 4 of 9 (432 Views)

Re: Help Associating VB.Net with AutoCad

01-19-2012 07:49 AM in reply to: mgorecki

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?

 

Thanks,

Mark

Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 5 of 9 (426 Views)

Re: Help Associating VB.Net with AutoCad

01-19-2012 08:25 AM in reply to: gasty1001

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.

 

Thanks,

Mark

Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 6 of 9 (417 Views)

Re: Help Associating VB.Net with AutoCad

01-19-2012 10:44 AM in reply to: mgorecki

Check this link out: 

 

http://usa.autodesk.com/adsk/servlet/index?id=18162650&siteID=123112

 

But basically once you install the Autocad Visual Studio Wizard it gives you a standard template. 

(http://images.autodesk.com/adsk/files/AutoCAD_2010-2012_dotNET_Wizards.zip)

 

It's not really difficult. It's just seem confusing as there is a lot of new information. 

 

Good Luck!

 

 

~TEMPLATE.png

Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 7 of 9 (407 Views)

Re: Help Associating VB.Net with AutoCad

01-19-2012 01:01 PM in reply to: VB_Autocad_guy

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? 

 

Take care,

Mark

Valued Mentor
jeff
Posts: 328
Registered: ‎05-12-2009
Message 8 of 9 (399 Views)

Re: Help Associating VB.Net with AutoCad

01-19-2012 05:55 PM in reply to: mgorecki

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.

You can also find your answers @ TheSwamp
Mentor
mgorecki
Posts: 413
Registered: ‎09-23-2004
Message 9 of 9 (381 Views)

Re: Help Associating VB.Net with AutoCad

01-20-2012 06:53 AM in reply to: jeff

Hi Jeff,

Thanks for the information and the links.  I'll definately check them out.

 

Mark

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.