.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# ActiveX

1 REPLY 1
SOLVED
Reply
Message 1 of 2
pipu123
2075 Views, 1 Reply

C# ActiveX

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);

        }

    }

}

1 REPLY 1
Message 2 of 2
pipu123
in reply to: pipu123

double[] tPkt1 = {10,10,0};
double[] tPkt2 = {20,15,0};
acLine = tMSpace.AddLine((object)tPkt1, (object)tPkt2);

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost