We can write the programs For AutoCAD in
VBA, AutoLISP, DCL and VB.NET etc....
In previous article I already explained how to write programs in
AutoLISP for AutoCAD, How to write programs in VBA
for AutoCAD.How to draw line in AutoCAD using VB.NET | Draw AutoCAD with VB.Net 2005 | Code to add a line to AutoCAD drawing using VB.NET
Let we will discuss about how to write programs in VB.NET
for AutoCAD.
First of all open Visual Studio 2005/2008/2010 what you have, otherwise downloaded the Microsoft Visual Studio.
Add project:
File—new—project—class library---enter the class library name—ok
Select show all:
On the right in the Solution
Explorer select the Show All button. (If the
Solution Explorer is not visible then hit CTRL+ALT+L).
Add reference to classlibrary :
Add the reference in the COM Add reference to AutoCAD Type Library (acax17enu.tlb), AutoCAD /
ObjectDBX Common Type Library (axdb17enu.tlb)
Add the reference in
the Browse C:\Program
Files\AutoCAD 2007 add acdbmgd.dll and acmgd.dll.
After that write the below code in
the class library code.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Public Class Class1
<CommandMethod("MyCircle")> _
Public Shared Sub CreateCircle()
Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Dim acaddoc As Autodesk.AutoCAD.Interop.AcadDocument
Dim pt As Object
Dim pt1 As Object
AcadApp = GetObject(, "Autocad.Application")
acaddoc = AcadApp.ActiveDocument
pt =
acaddoc.Utility.GetPoint(, "Pick
point:")
acaddoc.ModelSpace.AddCircle(pt, 50)
End Sub
End Class |
Build the solution:
Go to Browse tab—Build then .dll file
is created in the bin\debug folder of the project.
Go to AutoCAD in the command
enter netload then
one popup will come. select the yours .dll file and click Open .
Give the MyCircle then it will ask
the pick point and then draw the circle automatically.
The below figure will show the process of how to load .dll file.
Thank you for Reading My Blog.If you like my blog then please share with your friends.
Yes intercad.
ReplyDelete