private void AUTOCAD2006ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string progID = "AutoCAD.Application";

            Autodesk.AutoCAD.Interop.AcadApplication CADAPP = null;
            try
            {
                CADAPP = (Autodesk.AutoCAD.Interop.AcadApplication)Marshal.GetActiveObject(progID);
            }
            catch
            {
                try
                {
                    Type SType = Type.GetTypeFromProgID(progID);
                    CADAPP         = (Autodesk.AutoCAD.Interop.AcadApplication)Activator.CreateInstance(SType, true);
                    CADAPP.Visible = true;
                }
                catch
                {
                    this.Close();
                }
            }
            if (CADAPP != null)
            {
                CADAPP.Visible = true;
                CADAPP.ActiveDocument.SendCommand("filedia\r0\r");
                CADAPP.ActiveDocument.SendCommand("netload\r" + Application.StartupPath + "\\MYCAD.dll" + "\r");
                CADAPP.ActiveDocument.SendCommand("filedia\r1\r");
                this.Close();
            }
        }
 public static void YCRO_menu()
 {
     try
     {
         AdeskInter.AcadApplication   acadApp  = (AdeskInter.AcadApplication)AdeskAppSvr.Application.AcadApplication;
         AdeskInter.AcadPopupMenu     mYCRO    = acadApp.MenuGroups.Item(0).Menus.Add("YCRO");
         AdeskInter.AcadPopupMenuItem mDigital = mYCRO.AddMenuItem(mYCRO.Count + 1, "电子签名", "ShowDigital ");
         AdeskInter.AcadPopupMenuItem mFrame   = mYCRO.AddMenuItem(mYCRO.Count + 1, "电子图框", "ShowFrame ");
         mYCRO.InsertInMenuBar(acadApp.MenuBar.Count + 1);
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
Пример #3
0
 static void Main()
 {
     Autodesk.AutoCAD.Interop.AcadApplication AcadApp = new Autodesk.AutoCAD.Interop.AcadApplication();
     AcadApp.Application.WindowState = Autodesk.AutoCAD.Interop.Common.AcWindowState.acMax;
     AcadApp.Application.Visible = true;
     int menu_count = AcadApp.Application.MenuBar.Count;
     for (int i = 0; i < menu_count; ++i)
     {
         MessageBox.Show(AcadApp.Application.MenuBar.Item(i).Name);
     }
     int group_count = AcadApp.Application.MenuGroups.Count;
     for (int i = 0; i < group_count; ++i)
     {
         MessageBox.Show(AcadApp.Application.MenuGroups.Item(i).Name);
     }
 }
Пример #4
0
        internal static void FindPolyline(string polylineId)
        {
            try
            {
                Autodesk.AutoCAD.Interop.AcadApplication acadApplication = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
                Document doc = Application.DocumentManager.MdiActiveDocument;
                Editor   ed  = doc.Editor;
                Database db  = doc.Database;

                DocumentLock m_DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument();

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    ObjectId newObjectId = db.GetObjectId(false, new Handle(Convert.ToInt64(polylineId)), 0);
                    Entity   entity      = tr.GetObject(newObjectId, OpenMode.ForWrite) as Entity;
                    var      sdfasd      = entity.GeometricExtents;
                    if (entity == null)
                    {
                        return;
                    }
                    //根据实体的范围对视图进行缩放
                    entity.TransformBy(ed.CurrentUserCoordinateSystem.Inverse());

                    double[] doubles1 = new double[3] {
                        sdfasd.MinPoint.X, sdfasd.MinPoint.Y, sdfasd.MinPoint.Z
                    };
                    double[] doubles2 = new double[3] {
                        sdfasd.MaxPoint.X, sdfasd.MaxPoint.Y, sdfasd.MaxPoint.Z
                    };
                    //参数要求是双精度的数组
                    if (acadApplication != null)
                    {
                        acadApplication.ZoomWindow(doubles1, doubles2);
                    }
                    //acadApplication.ZoomWindow(sdfasd.MinPoint, sdfasd.MaxPoint);
                    entity.Highlight();
                    tr.Commit();
                }
                m_DocumentLock.Dispose();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
Пример #5
0
        public static void closeapp()
        {
            string progID = "AutoCAD.Application";

            AdeskInter.AcadApplication CADAPP = null;
            try
            {
                CADAPP = (AdeskInter.AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(progID);
                CADAPP.Quit();
            }
            catch
            {
                try
                {
                    Type SType = Type.GetTypeFromProgID(progID);
                    CADAPP = (AdeskInter.AcadApplication)System.Activator.CreateInstance(SType, true);
                    CADAPP.Quit();
                }
                catch
                {
                }
            }
        }
Пример #6
0
        private void CallBack(IAsyncResult tag)
        {
            AsyncResult result = (AsyncResult)tag;
            dels        del    = (dels)result.AsyncDelegate;

            del.EndInvoke(tag);

            try
            {
                MessageBox.Show("电子签名插件更新成功,重新启动Auto CAD", "更新成功");
                string progID = "AutoCAD.Application";
                AdeskInter.AcadApplication CADAPP = null;
                try
                {
                    Type SType = Type.GetTypeFromProgID(progID);
                    CADAPP         = (AdeskInter.AcadApplication)System.Activator.CreateInstance(SType, true);
                    CADAPP.Visible = true;
                }
                catch
                {
                    MessageBox.Show("fail");
                }

                System.Diagnostics.Process[] processName = System.Diagnostics.Process.GetProcessesByName("UpdateSoftProgram");
                foreach (System.Diagnostics.Process p in processName)
                {
                    if (!p.HasExited)
                    {
                        p.Kill();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public static void re_YCRO_menu()
 {
     AdeskInter.AcadApplication acadApp = (AdeskInter.AcadApplication)AdeskAppSvr.Application.AcadApplication;
     acadApp.MenuGroups.Item(0).Menus.RemoveMenuFromMenuBar("YCRO");
 }