Hi Friends, in
this article I will explain about How to open new drawing using VB.NET or C#? Or
How to Connect with AutoCAD and Open A Drawing in VB.NET /C# .
In previous
article I already explained about How to add references for AutoCAD ,How to call Lisp Program from VB.NET ? || Calling AutoCAD commands from .NET.
Lets I will
explain about Open A Drawing in VB.NET /C# as shown below.
We have to add
the below references to project. I explained in the previous article How to add references for AutoCAD ,How to call Lisp Program from VB.NET ? || Calling AutoCAD commands from .NET
1. AutoCAD
2007/2010 Type Library
2. AutoCAD/ObjectDBX
Common 17.0/18.0 type Library from COM tab.
3. acdbmgd.dll
4. acmgd.dll
Double click on
the form and imports or using the below namespaces.
Imports Autodesk.AutoCAD.Interop.AcadDocumentClass
Imports
Autodesk.AutoCAD.Interop.Common
|
And write the
below code in the Form1 Class
Public AcadApp As
Autodesk.AutoCAD.Interop.AcadApplication
Public
AcadDoc As
Autodesk.AutoCAD.Interop.AcadDocuments
|
And write the
below code in Form1_Load
AcadApp = New
Autodesk.AutoCAD.Interop.AcadApplication
AcadApp.Visible
= True
|
And save the
form and Run. When you run the project then automatically form and AutoCAD new
drawing will open simultaneously.
The complete code is
as follows.
In VB.NET:
Imports Autodesk.AutoCAD.Interop.AcadDocumentClass
Imports Autodesk.AutoCAD.Interop.Common
Public Class Form1
Public AcadApp As
Autodesk.AutoCAD.Interop.AcadApplication
Public AcadDoc As
Autodesk.AutoCAD.Interop.AcadDocuments
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
AcadApp = New
Autodesk.AutoCAD.Interop.AcadApplication
AcadApp.Visible = True
End Sub
End Class
|
IN C#:
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using Autodesk.AutoCAD.Interop.AcadDocumentClass;
using Autodesk.AutoCAD.Interop.Common;
Public Class Form1
{
public Autodesk.AutoCAD.Interop.AcadApplication
AcadApp;
public Autodesk.AutoCAD.Interop.AcadDocuments
AcadDoc;
private void Form1_Load(System.Object sender,
System.EventArgs e)
{
AcadApp
= new
Autodesk.AutoCAD.Interop.AcadApplication();
AcadApp.Visible
= true;
}
Public Form1()
{
Load
+= Form1_Load;
}
}
|
I will explain
how to open existing AutoCAD drawing using VB.NET/C# in the next article.
If you like my blog Aspdotnet-Roja then why are you waiting like my blog through facebook page Aspdotnet-Roja
No comments:
Post a Comment