.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help Associating VB.Net with AutoCad

8 REPLIES 8
Reply
Message 1 of 9
mgorecki
1429 Views, 8 Replies

Help Associating VB.Net with AutoCad

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

8 REPLIES 8
Message 2 of 9
hgasty1001
in reply to: mgorecki
Message 3 of 9
mgorecki
in reply to: hgasty1001

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

Message 4 of 9
mgorecki
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

Message 5 of 9
mgorecki
in reply to: hgasty1001

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

Message 6 of 9
VB_Autocad_guy
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

Message 7 of 9
mgorecki
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

Message 8 of 9
jeff
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
Message 9 of 9
mgorecki
in reply to: jeff

Hi Jeff,

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

 

Mark

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost