I don’t often used VB.net but I would like to know how I can create a form with a button that will send a command to AutoCAD. I’ve goggled but get nothing near enough to what I find understandable.
Could anybody assist in this?
Solved! Go to Solution.
Solved by fxcastil. Go to Solution.
Not clearly enough for me
Do you want to create stand alone
project using .exe application or
you want to create managed API call?
And also, what the language you're prefering?
~'J'~
What I would like is to make an exe which sends a comand to autocad. I'm not all to concerned about automatically starting autocad or any of that as the exe would be called up ussing a lisp function/ command hens AutoCAD is already running otherewise you couldnt just run the exe.
Im ussing vb.net to create an application, think thats clear enougth...
Okay lets put this simple wher can I get the very basics of vb.net in relation to AutoCAD. Is it even possible to Build a form with a button as a trigger in VB.net express which is responsible for sending a command to AutoCAD, which triggers my lisp?
(the problem is theres no simple basic introduction online, it all just seams to jump in somewhere)
I will be back in a 2-3 hours back,
Wait, please, if somebody else could not
add an example you need,
Cheers 🙂
~'J'~
Okay from what I get is that I have to create a class1.vb and attach a user form by adding a usser controll from eher on im lost
create Windows Forms Application, name it "LoadLisp" or something else,
drop Button1 on form and add caption on the button, say "Load my lisp" add references to:
AutoCAD xxxx Type Library
AutoCAD ObjectDBX/Common xx.x Type Library
Add following code on form module, click Build solution
Then go to folder ///...bin/Debug select application and load
its icon on windows screen, then try it
(change lisp file name in command within the code before)
'______________________________________' Imports System.Reflection Imports Autodesk.AutoCAD.Interop Imports Autodesk.AutoCAD.Interop.Common Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Me.Hide() LoadLisp() Me.Show() End Sub Public Sub LoadLisp() Dim appver As Object = TryCast(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD", "CurVer", Nothing), Object) If appver Is Nothing Then MessageBox.Show("Out of luck, sorry, you get a problem to read Registry", "Bad for you") Return End If Dim oAcadApp As AcadApplication = New AcadApplication Try If oAcadApp Is Nothing Then oAcadApp = GetObject(, "AutoCAD.Application" + appver.ToString()) End If Catch ex As System.Exception MessageBox.Show("Working in opened document only!") Return End Try oAcadApp.Visible = True oAcadApp.WindowState = AcWindowState.acMax Dim oAcDoc = oAcadApp.ActiveDocument '' lisp with command C:SPLASH is loaded from disk C:\Test\Splash.lsp ''------------------------------------------------------'' '' Change both lines of next code block to suit: Dim command As String = "(load ""C:/Test/Splash.lsp"")" oAcDoc.SendCommand(command & "(C:SPLASH) ") ''------------------------------------------------------'' End Sub End Class ''___________________________________________________''
I can't help you other then that, coz I have very limited
skills with work from forms
~'J'~
There can't be a "simple" introduction, as there is no such thing. Even forms require a fair understanding of a number of programming concepts. Where you're at is the creation of an application, which involves tying together those various programming and IDE concepts into a working product.
dotNET is certainly *not* plug-and-play.
Well VBA seemed a lot simpler I would only need the following code.
Don’t even know where to start replicating this in vb.net?
Private Sub CommandButton1_Click() ThisDrawing.SendCommand ("(c:MYcustomLISPcommand)" & vbCr) Unload UserForm1 End Sub
How can I do this in vb.net (my apologies I wasn’t thinking it doesn’t need to be in form of an exe it may also be in form of a DLL file)
you need to get started by reaing the Autocad VB.net developers guide
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html
First you need to install MicroSoft Visual Studio VB.net (Express version is free)
Then add references to the required AutoCad files which allow Visual Studio VB to access the Autocad .net libraries. Configure Visual Studio for the right version of .NET depending on your version of AutCAD.
Create a userform and code, then compile to a DLL which is loaded into AutoCAD using "NETLOAD" AutoCAD command.
Hallex described the details to help you after you do the other things first.
Can't find what you're looking for? Ask the community or share your knowledge.