View Full Version : Finding AutoCAD templates in Visual Studio Pro 13
ralph.burkey
2014-08-01, 09:28 PM
OK, I'm trying to migrate all our Lisp and VBA routines to VB.net and whenever I type something in VB.net like "acadselectionset" or "ThisDrawing.selectionset" the wavy red underline pops up. Of course, VB.net doesn't understand Autocad stuff, but the VBA code did. I didn't write the VBA programs, and the guy who did is no longer with the company, but I have a feeling there was a template of some sort he used to get the Autocad commands under stood in VBA.
I have the book "VB.net programming for Autocad customization" by Jerry Winters and I downloaded the latest stuff from his website, but the book says to install the stuff, and I don't know how to do that.
I guess my question is, how do I install whatever templates Jerry may have supplied? When I start a new project, the list of templates in the New Project command in VB.net doesn't see anything Autocad related. Likewise, I can't find anything on the web when I click "Click here to go online and find templates".
What to do? I'm confident that when I get over this stumbling block I can transfer all our programming to the VB.net, but I'm really having trouble with this.
Any ideas out there?
Anybody?
Bueller?
Anybody?
-Ralphie
peter
2014-08-07, 10:15 PM
What version of visual studio are you using?
VB.net is different than VB or lisp.
It requires transactions which are covered in Jerry's book.
It is not com based although you could do com stuff with it like vba.
I can send you a visual studio file to start you out and you can make a template out of it.
It will take a full rewrite of your old code.
It is much faster at run time but slower to code.
Sorry it toook me so long to respond nbut for some reason I couldnt login.
Thanks for participating.
P=
irneb
2014-08-08, 06:23 AM
I know that VBA used to automatically reference and import acad's API. That's why you didn't need to worry about it. That's also the main reason I'd like to see VSTA in acad the same way AutoDesk did it for Revit: i.e. package the SharpDevelop IDE as a built-in development environment like the old VBA used to be (only now allowing it to use whatever DotNet language you can shake a stick at). It generates those templates for you each time you start a new project.
There's been some addon's for Visual Studio to add a acad managed (i.e. DotNet) option in the "new project" dialog. Some work well, some not so much, but all of them are relevant only to the specific version of VS (and sometimes also the specific version of acad). Do yourself a favour, download the acad SDK (it's actually intended for ObjectARX, but includes the DotNet stuff too: even one of these VS plugins).
Though I find it easier just generating my own.
First and foremost, your DotNet project (no matter the language VB/C#/F#/Python/etc.) will need to reference the relevant ACad assembly files. Those ACMGD.DLL and ACBDMGD.DLL files (and lately also AcCoreMgd.DLL). You do this by right-clicking on the project's References group in the VS project browser (after you've started a new Class Library project). Then choose Add Reference. Open the Browse tab and browse to those files in the acad installation folder (you might want to add this folder to the project's Reference Paths in the project properties).
Next, you need to import the relevant namespaces from those files. At the top of any new class file (I'm going to go with VB files here since you're asking for that) start typing Imports (the intellisense should guide you already). Then start typing AutoDesk - it should show you all the namespaces available from the referenced assemblies.
After you've got a minimal amount of stuff you like (e.g. a command method / lispfunction / whatever else you feel you'll always need) go to File --> Export Template, and name it whatever you like. You should now have template as an option in that new project dialog.
ralph.burkey
2014-08-08, 04:18 PM
OK, here's what I got:
96288
Did I put that in the wrong place? I'm using Visual Studio 13 and Autocad 2010
Thanks for the responses!
-Ralphie
BlackBox
2014-08-08, 06:05 PM
Looks like your Imports Statement is within your Class scope; try declaring your Imports Statements, then your application's Namespace, and then define your Class(es):
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Namespace FOO
Public Class BAR
'' <-- Your code here
End Class
End Namespace
[Edit] - You can declare fully qualified Namespaces within your Class, Method(s), etc but that does not require an Imports statement; just declare the fully qualified Namespace in your call.
Jeff H
2014-08-13, 10:31 AM
Start here step by step
http://usa.autodesk.com/adsk/servlet/index?id=18162650&siteID=123112
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.