I created windows forms , I add reference to activeX
The AutoCAD type library, acax17enu.tlb, located at <drive>:\Program Files\Common
Files\Autodesk Shared.
The AutoCAD/ObjectDBX Common 17.0 type library, axdb18enu.tlb, located at
<drive>:\Program Files\Common Files\Autodesk Shared.
It works the same way as vba built-in autocad application.
I wrote that program with autodesk help.
1) How to define Pkt1, Pkt2 to create a line ?
2) Is there any documentation for activeX C# ?
3) Which forum is appropriate for ActiveX C# and other external programming languages
Thank You In advance
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
namespace Wst_zelbet
{
public partial class wst : Form
{
public wst()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
AcadApplication objAcad;
AcadDocuments colDocs;
AcadModelSpace Mspace;
AcadLine acLine;
AcadDocument ThisDrawing;
objAcad = null;
const string strProgId = "AutoCAD.Application.17.2";
// Get a running instance of AutoCAD
try
{
objAcad = (AcadApplication)Marshal.GetActiveObject(strProgId);
}
catch // An error occurs if no instance is running
{
try
{
// Create a new instance of AutoCAD
objAcad = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(strProgId), true);
}
catch
{
// If an instance of AutoCAD is not created then message and exit
System.Windows.Forms.MessageBox.Show("Instance of 'AutoCAD.Application'" + " could not be created.");
return;
}
}
// Display the application and return the name and version
objAcad.Visible = true;
// System.Windows.Forms.MessageBox.Show("Now running " + acAppComObj.Name + " version " + objAcad.Version);
// Get the active document
ThisDrawing = objAcad.ActiveDocument;
ThisDrawing.SendCommand("MyCommand ");
Mspace = ThisDrawing.ModelSpace;
object Pkt1;
object Pkt2;
// please define these points
Pkt1 = ....
Pkt2 = ....
acLine = Mspace.AddLine(pk1, pk2);
ThisDrawing.Application.ZoomAll();
ThisDrawing.Regen(AcRegenType.acAllViewports);
}
}
}
Solved! Go to Solution.
Solved by pipu123. Go to Solution.