Jump to content

AutoCAd and VB.net


rahulp

Recommended Posts

i have an application where i need to create autoCAD drawing on a button click event.

i did some search and found that we can do this using

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common

 

but i am not able to find exact example of how to create a new drawing.

i had got a nice article which gave the entire code in VB6, can i convert it to vb.net, if so how?

the following is vb6 code

Sub Main()

Dim xAP As Excel.Application

Dim xWB As Excel.Workbook

Dim xWS As Excel.Worksheet

Set xAP = Excel.Application

Set xWB = xAP.Workbooks.Open("C:\A2K2_VBA\IUnknown.xls")

Set xWS = xWB.Worksheets("Sheet1")

MsgBox "Excel says: """ & Cells(1, 1) & """"

 

Dim A2K As AcadApplication

Dim A2Kdwg As AcadDocument

Set A2K = CreateObject("AutoCAD.Application")

Set A2Kdwg = A2K.Application.Documents.Add

MsgBox A2K.Name & " version " & A2K.Version & _

" is running."

 

Dim Height As Double

Dim P(0 To 2) As Double

Dim TxtObj As AcadText

Dim TxtStr As String

Height = 1

P(0) = 1: P(1) = 1: P(2) = 0

TxtStr = Cells(1, 1)

Set TxtObj = A2Kdwg.ModelSpace.AddText(TxtStr, _

P, Height)

 

A2Kdwg.SaveAs "C:\A2K2_VBA\IUnknown.dwg"

A2K.Documents.Close

A2K.Quit

Set A2K = Nothing

 

xAP.Workbooks.Close

xAP.Quit

Set xAP = NothingEnd Sub

Please Help me :huh:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...