• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    Help Associating VB.Net with AutoCad

    315 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

    Please use plain text.
    Mentor
    Posts: 214
    Registered: ‎04-11-2010

    Re: Help Associating VB.Net with AutoCad

    01-17-2012 07:11 AM in reply to: mgorecki
    Please use plain text.
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    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.

    Please use plain text.
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    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

    Please use plain text.
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    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

    Please use plain text.
    Distinguished Contributor
    VB_Autocad_guy
    Posts: 136
    Registered: ‎07-24-2009

    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

    Please use plain text.
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    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

    Please use plain text.
    Mentor
    Posts: 241
    Registered: ‎05-12-2009

    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
    Please use plain text.
    Mentor
    Posts: 370
    Registered: ‎09-23-2004

    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

    Please use plain text.