Hi Friends, in this article I will explain about how to draw line in AutoCAD using VB.NET.
Select show all:
In previous article I already explained how to write programs in AutoLISP for AutoCAD, How to write programs in VBA for AutoCAD.
Let we will discuss about how to write programs in VB.NET for AutoCAD.
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:
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)
After that write the below code in the class library code.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Public Class Class1
<CommandMethod("MyLine")> _
Public Shared Sub CreateLine()
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:")
pt1 = acaddoc.Utility.GetPoint(pt, "Pick second point:")
acaddoc.ModelSpace.AddLine(pt, pt1)
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 your .dll file and click Open .
Give the MyLine then it will ask the pick point and second pick point and draw the line.
Little Help need here , i could not find the AutoCAD Library
ReplyDeleteHi Ganesh if u install AutoCAD in your system then it will show in COM tab.
DeleteDo you have an example on how to draw a horizontal line starting from a given point (known coordinates) and ending automatically when intersecting with another line
ReplyDelete