Exemplo n.º 1
0
        public void PlusIndex()
        {
            Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            var peo = new PromptEntityOptions("\n选择一个编号");

            peo.SetRejectMessage("选择块");
            peo.AddAllowedClass(typeof(BlockReference), true);
            var per = ed.GetEntity(peo);

            if (per.Status == PromptStatus.OK)
            {
                Database db = HostApplicationServices.WorkingDatabase;

                using (var tr = db.TransactionManager.StartTransaction())
                {
                    var indexBlock = (BlockReference)per.ObjectId.GetObject(OpenMode.ForRead);

                    string currIndex = indexBlock.ObjectId.GetAttributeInBlockReference("编号");

                    try
                    {
                        indexBlock.ObjectId.UpdateAttributesInBlock("编号",
                                                                    (Convert.ToInt32(currIndex) + 1).ToString());
                    }
                    catch (System.Exception)
                    {
                        AcadApp.ShowAlertDialog("\n当前内容不支持序号加 1");
                    }
                    tr.Commit();
                }
            }
        }
Exemplo n.º 2
0
        public void ChangeCarType()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                List <BlockReference> cars = db.GetSelectionOfBlockRefs("\n选择车", false, carBlockName);

                if (cars.Count == 0)
                {
                    AcadApp.ShowAlertDialog("选中数量为0");
                }
                else
                {
                    foreach (var car in cars)
                    {
                        var currCarType = car.ObjectId.GetDynBlockValue("类型");

                        switch (currCarType)
                        {
                        case "微型车位":
                            car.ObjectId.SetDynBlockValue("类型", "普通车位");
                            break;

                        case "普通车位":
                            car.ObjectId.SetDynBlockValue("类型", "微型车位");
                            break;
                        }
                    }
                }

                tr.Commit();
            }
        }
Exemplo n.º 3
0
        public static ObjectId GetArrowObjectId(string arrow, string newArrName)
        {
            var Return = ObjectId.Null;

            string oldArrName = Application.GetSystemVariable(arrow).ToString();

            Application.SetSystemVariable(arrow, newArrName);

            if (oldArrName.Length != 0)
            {
                Application.SetSystemVariable(arrow, oldArrName);
            }

            using (Transaction t = AC.DB.TransactionManager.StartTransaction())
            {
                var BT = t.GetObject(AC.DB.BlockTableId, OpenMode.ForWrite) as BlockTable;

                //ObjectId d = new ObjectId(new IntPtr(165522592));
                //var A = t.GetObject(d, OpenMode.ForRead) as BlockTableRecord;
                //MessageBox.Show(A.Name);

                Return = BT[newArrName];
                t.Commit();
            }

            return(Return);
        }
Exemplo n.º 4
0
        public void PolylineHatch()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                //Polyline pl = new Polyline();
                ////pl.CreatePolyline(Point2d.Origin, new Point2d(0, 50), new Point2d(50, 50));
                ////pl.Closed = true;
                ////pl.CreateRectangle(Point2d.Origin, new Point2d(50, 50));
                //pl.CreatePolygon(Point2d.Origin, 6, 50);
                //db.AddToCurrentSpace(pl);

                var tsId = db.AddTextStyle("test", "sceie.shx", "sceic.shx", 0.7);
                if (tsId != ObjectId.Null)
                {
                    DBText text = new DBText()
                    {
                        TextStyleId = tsId,
                        //Position = new Point3d(25, 25, 0),
                        Height         = 20,
                        TextString     = "文字",
                        HorizontalMode = TextHorizontalMode.TextCenter,
                        VerticalMode   = TextVerticalMode.TextVerticalMid,
                        AlignmentPoint = new Point3d(25, 25, 0),
                    };
                    db.AddToCurrentSpace(text);
                }
                else
                {
                    AcadApp.ShowAlertDialog("字体样式添加失败。");
                }
                tr.Commit();
            }
        }
Exemplo n.º 5
0
        public static void OpenSaveDwgFiles()
        {
            List <Sheet> dict = new List <Sheet>();

            try
            {
                var           path  = @"C:\Users\yusufzhon.marasulov\Desktop\test";
                DirectoryInfo d     = new DirectoryInfo(path);
                FileInfo[]    Files = d.GetFiles("*.dwg");
                foreach (FileInfo file in Files)
                {
                    var    fileName  = Path.GetFileName(file.FullName);
                    string dwgFlpath = file.FullName;
                    using (Database db = new Database(false, true))
                    {
                        db.ReadDwgFile(dwgFlpath, FileOpenMode.OpenForReadAndAllShare, false, null);
                        using (Transaction tr = db.TransactionManager.StartTransaction())
                        {
                            ObjectId           mSpaceId = SymbolUtilityServices.GetBlockModelSpaceId(db);
                            ObjectIdCollection idArray  = Utils.SelectDynamicBlockReferences(mSpaceId);
                            GetSheetsFromBlocks(Active.Editor, dict, tr, idArray);
                            tr.Commit();
                        }
                        db.SaveAs(dwgFlpath, DwgVersion.Current);
                    }
                }
                Application.ShowAlertDialog("All files processed");
            }
            catch (System.Exception ex)
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString());
            }
        }
Exemplo n.º 6
0
        public void ListAttributes()
        {
            Dictionary <string, string> attrList = new Dictionary <string, string>();

            MainWindow window = new MainWindow(new BlockViewModel(attrList));

            Application.ShowModalWindow(window);

            if (window.isClicked == true)
            {
                //var objectIds = Utils.GetAllCurrentSpaceBlocksByName(window.NameBlock.Text);
                ObjectId           mSpaceId  = SymbolUtilityServices.GetBlockModelSpaceId(Active.Database);
                ObjectIdCollection objectIds = Utils.SelectDynamicBlockReferences(mSpaceId);

                List <Sheet>      dict        = new List <Sheet>();
                List <PrintModel> printModels = new List <PrintModel>();

                BlockAttribute objectNameEn = window.ComboObjectNameEn.SelectedItem as BlockAttribute;
                BlockAttribute objectNameRu = window.ComboObjectNameRu.SelectedItem as BlockAttribute;

                BlockAttribute position     = window.ComboBoxPosition.SelectedItem as BlockAttribute;
                BlockAttribute nomination   = window.ComboBoxNomination.SelectedItem as BlockAttribute;
                BlockAttribute comment      = window.ComboBoxComment.SelectedItem as BlockAttribute;
                BlockAttribute trItem       = window.ComboBoxTrItem.SelectedItem as BlockAttribute;
                BlockAttribute trDocNumber  = window.ComboBoxTrDocNumber.SelectedItem as BlockAttribute;
                BlockAttribute trDocTitleEn = window.ComboBoxTrDocTitleEn.SelectedItem as BlockAttribute;
                BlockAttribute trDocTitleRu = window.ComboBoxTrDocTitleRu.SelectedItem as BlockAttribute;

                AttributModel attributModel = new AttributModel(objectNameEn, objectNameRu, position, nomination,
                                                                comment, trItem, trDocNumber, trDocTitleEn, trDocTitleRu);

                using (Transaction tr = Active.Database.TransactionManager.StartTransaction())
                {
                    MyCommands.GetSheetsFromBlocks(Active.Editor, dict, tr, objectIds);
                    string selAttrName = "НОМЕР_ЛИСТА";
                    MyCommands.GetPrintParametersToPdf(Active.Editor, printModels, tr, objectIds, selAttrName);

                    if (window.transmittalCheckBox.IsChecked == true)
                    {
                        Utils utils = new Utils();
                        utils.CreateOnlyVed(dict);
                        utils.CreateOnlytrans(dict);
                        foreach (var printModel in printModels)
                        {
                            PlotCurrentLayout(printModel.DocNumber, printModel);
                        }
                    }
                    else
                    {
                        //Utils utils = new Utils();
                        //utils.CreateOnlyVed(dict);
                        foreach (var printModel in printModels)
                        {
                            //PlotCurrentLayout(printModel.DocNumber, printModel.BlockExtents3d, printModel.StampViewName);
                        }
                    }
                    tr.Commit();
                }
            }
        }
Exemplo n.º 7
0
        /* Sends the pdf into AutoCAD and runs -PDFIMPORT then quits the program
         * Calls: NewDrawing, SaveActiveDrawing
         * Called by: Main
         * Returns: none
         */
        //[CommandMethod("PdfImport")]
        public void ImportPdf(string userfile, int userpage, string usersave, int pageend)
        {
            var dwg = CadApp.DocumentManager.MdiActiveDocument;
            //var ed = dwg.Editor;
            int    fileDia = Convert.ToInt32(CadApp.GetSystemVariable("FILEDIA"));
            string save;

            for (int page = userpage; page <= pageend; page++)
            {
                //Start command -PDFIMPORT with pdf file name supplied
                var cmd = "-PDFIMPORT f\r";
                dwg = NewDrawing();
                dwg.SendStringToExecute(cmd, true, false, false);
                dwg.SendStringToExecute(userfile + "\r", true, false, false);
                // supply page input
                dwg.SendStringToExecute(page + "\r", true, false, false);
                // supply insertion location inputset
                dwg.SendStringToExecute("10.0,10.0\r", true, false, false);
                // supply scale input
                dwg.SendStringToExecute("1.0\r", true, false, false);
                // supply rotation input
                dwg.SendStringToExecute("0.0\r", true, false, false);
                save = SaveActiveDrawing(usersave, page, dwg);
                dwg.SendStringToExecute("SAVE\r", true, false, false);
                dwg.SendStringToExecute(save + "\r", true, false, false);
            }
            dwg.SendStringToExecute("_QUIT\r", true, false, false);
        }
 private void InitExportOptions(Document doc)
 {
     base.ExportOptions.AcadDocument = doc;
     if (base.BoundaryExtent != null)
     {
         base.ExportOptions.BoundingBox = new Extent(base.BoundaryExtent);
     }
     else
     {
         base.ExportOptions.BoundingBox = new Extent(doc);
     }
     try
     {
         System.Drawing.Size size = Application.ToSystemDrawingSize(doc.Window.DeviceIndependentSize);
         base.ExportOptions.Width  = size.Width;
         base.ExportOptions.Height = size.Height;
     }
     catch
     {
         base.ExportOptions.Width  = 1280;
         base.ExportOptions.Height = 1280;
     }
     base.ExportOptions.DPI    = 96;
     base.ExportOptions.Format = "PNG24";
 }
Exemplo n.º 9
0
        private static bool SetMapScale(Document document)
        {
            // http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-4fff.htm,topicNumber=d0e346024
            var dynmode = AcadApplication.GetSystemVariable("DYNMODE");

            AcadApplication.SetSystemVariable("DYNMODE", 2); // 2 means "Dimensional input on"

            int    defaultScale = 500;
            string strPrompt    = String.Format("\n设置绘图比例尺为1:<{0}>", defaultScale);
            var    pScaleOpts   = new PromptIntegerOptions(strPrompt)
            {
                AllowNone = true,
                AllowZero = false
            };

            var pScaleRes = document.Editor.GetInteger(pScaleOpts);

            AcadApplication.SetSystemVariable("DYNMODE", dynmode);
            if (pScaleRes.Status == PromptStatus.OK || pScaleRes.Status == PromptStatus.None)
            {
                double scale = defaultScale;
                if (pScaleRes.Status == PromptStatus.OK)
                {
                    scale = pScaleRes.Value;
                }
                MapScaleUtils.SetApplicationMapScale(scale);

                return(true);
            }
            return(false);
        }
Exemplo n.º 10
0
        public static void WrapUpOperations(Timer tm)
        {
            try
            {
                TotalDWGs = 0;
                MaxDWGs   = 0;
                MaxDXFs   = 0;
                tm.Stop();
                myTimer.Stop();
                myTimer.Enabled = false;
                myTimer.Tick   -= TimerEventProcessor;
                Application.SetSystemVariable("FILEDIA", 1);
                COMS.MessengerManager.AddLog("Stopped Watcher!");

                Application.SetSystemVariable("PROXYNOTICE", 1);
                Application.SetSystemVariable("PROXYGRAPHICS", 1);
                Application.SetSystemVariable("FILEDIA", 1);

                COMS.MessengerManager.AddLog("Set Exit Variables!");

                OpenandCloseDwgs.CloseDocuments();
            }
            catch (Exception ex)
            {
                COMS.MessengerManager.LogException(ex);
            }
        }
Exemplo n.º 11
0
        public void Call()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            string   line;

            // Local do arquivo de dados: O diretório do .dwg onde está sendo
            // executado o programa.
            string curDwgPath = AcAp.GetSystemVariable("DWGPREFIX").ToString();

            var commandsFile = new StreamReader(curDwgPath + "\\commands.txt");

            while (!commandsFile.EndOfStream)
            {
                line = commandsFile.ReadLine();
                if (line != "")
                {
                    try
                    {
                        ed.Command(line);
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }

            commandsFile.Close();
        }
Exemplo n.º 12
0
        public static void ResetVars()
        {
            try
            {
                using (DatabaseCommands cmd = new DatabaseCommands())
                {
                    TotalDWGs = 0;
                    MaxDWGs   = 0;
                    MaxDXFs   = 0;
                    myTimer.Stop();
                    myTimer.Enabled = false;
                    myTimer.Tick   -= TimerEventProcessor;
                    COMS.MessengerManager.AddLog("Stopped Watcher!");

                    if (Active.Document != null)
                    {
                        Application.SetSystemVariable("FILEDIA", 1);
                        Application.SetSystemVariable("PROXYNOTICE", 1);
                        Application.SetSystemVariable("PROXYGRAPHICS", 1);
                        Application.SetSystemVariable("FILEDIA", 1);
                    }
                }
            }
            catch (Exception ex)
            {
                COMS.MessengerManager.LogException(ex);
            }
        }
Exemplo n.º 13
0
        public void PokretanjeForme()
        {
            //inicijalizacija forme
            PlovniPutApp win = new PlovniPutApp();

            AcAp.ShowModalDialog(win);
        }
Exemplo n.º 14
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            int    num;
            string str;

            this.TypeFlag = (
                from kvp in this._chkBoxes
                where kvp.Value.Checked
                select kvp.Key).Sum();
            this.EntityTypeFlag = (
                from kvp in this._chkEntTypes
                where kvp.Value.Checked
                select kvp.Key).Sum();
            this.StartValue = this.txtValue.Text;
            this.Separator  = this.txtSeparator.Text;
            if (this.TypeFlag == 0)
            {
                AcAp.ShowAlertDialog("Tidak ada Block.");
                return;
            }
            if (!this.IsValidString(this.StartValue, this.Separator))
            {
                AcAp.ShowAlertDialog("Invalid Nilai");
                this.txtValue.Select();
                return;
            }
            if (this.TypeFlag == 16 && int.TryParse(this.StartValue, out num))
            {
                this.StartValue = ((Romawi)num).ToString();
            }
            base.DialogResult = DialogResult.OK;
            //base.Close();
        }
Exemplo n.º 15
0
        [CommandMethod("GetIntegerOrKeywordFromUser")]//提示用户输入一个非零的正整数或一个关键字
        public static void GetIntegerOrKeywordFromUser()
        {
            Document             acDoc    = Application.DocumentManager.MdiActiveDocument;
            PromptIntegerOptions pIntOpts = new PromptIntegerOptions("");

            pIntOpts.Message = "\nEnter the size or ";
            // 限制输入必须大于0
            pIntOpts.AllowZero     = false;
            pIntOpts.AllowNegative = false;
            // 定义合法关键字并允许直接按Enter键
            pIntOpts.Keywords.Add("Big");
            pIntOpts.Keywords.Add("Small");
            pIntOpts.Keywords.Add("Regular");
            pIntOpts.Keywords.Default = "Regular";
            pIntOpts.AllowNone        = true;
            // 获取用户键入的值
            PromptIntegerResult pIntRes = acDoc.Editor.GetInteger(pIntOpts);

            if (pIntRes.Status == PromptStatus.Keyword)
            {
                Application.ShowAlertDialog("Entered keyword: " +
                                            pIntRes.StringResult);
            }
            else
            {
                Application.ShowAlertDialog("Entered value: " +
                                            pIntRes.Value.ToString());
            }
        }
Exemplo n.º 16
0
        private void chkSelBlock_CheckedChanged(object sender, EventArgs e)
        {
            bool flag;

            if (!chkSelBlock.Checked)
            {
                ComboBox combobox = this.cbxSelBlk;
                int      num      = 0;
                flag = Convert.ToBoolean(num);
                this.cbxSelTag.Enabled = Convert.ToBoolean(num);
                combobox.Enabled       = flag;
                return;
            }
            if (this.cbxSelBlk.Items == null || this.cbxSelBlk.Items.Count <= 0)
            {
                AcAp.ShowAlertDialog("None block with attributes in this drawing.");
                this.chkSelBlock.Checked = false;
                return;
            }
            ComboBox combobox1 = this.cbxSelBlk;
            int      num1      = 1;

            flag = Convert.ToBoolean(num1);
            this.cbxSelTag.Enabled = Convert.ToBoolean(num1);
            CheckBox checkbox = this.chkMtext;
            int      num2     = 0;

            flag = Convert.ToBoolean(num2);
            this.chkSelText.Checked = Convert.ToBoolean(num2);
            checkbox.Checked        = flag;
        }
Exemplo n.º 17
0
        public static void ShowWCSAndUCS(Point3d p)
        {
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                Point3d pPt3dWCS = p;
                Point3d pPt3dUCS = p;

                ViewportTableRecord acVportTblRec;
                acVportTblRec = acTrans.GetObject(acDoc.Editor.ActiveViewportId,
                                                  OpenMode.ForWrite) as ViewportTableRecord;

                Matrix3d newMatrix = new Matrix3d();
                newMatrix = Matrix3d.AlignCoordinateSystem(Point3d.Origin,
                                                           Vector3d.XAxis,
                                                           Vector3d.YAxis,
                                                           Vector3d.ZAxis,
                                                           acVportTblRec.Ucs.Origin,
                                                           acVportTblRec.Ucs.Xaxis,
                                                           acVportTblRec.Ucs.Yaxis,
                                                           acVportTblRec.Ucs.Zaxis);

                pPt3dWCS = pPt3dWCS.TransformBy(newMatrix);

                Application.ShowAlertDialog("The WCS coordinates are: \n" +
                                            pPt3dWCS.ToString() + "\n" +
                                            "The UCS coordinates are: \n" +
                                            pPt3dUCS.ToString());

                acTrans.Commit();
            }
        }
Exemplo n.º 18
0
        public void womanPants()
        {
            FormNew form = new FormNew();

            //WomanPants form = new WomanPants();
            AcadApp.ShowModalDialog(form);
        }
        public void AutoDwgAndSave()
        {
            //通过系统变量获取样板的路径
            string sLocalRoot    = AcadApp.GetSystemVariable("LOCALROOTPREFIX") as string;
            string sTemplatePath = sLocalRoot + "Template\\acad.dwt";


            //新建一个文档
            Document m_doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add(sTemplatePath);

            Database acCurDb = m_doc.Database;

            //初始化类 并且更新需要在哪个document生成图形
            this.OperatingCadInitialize(m_doc);  //这里一定要初始化赋值

            //操作非当前文档,建立先锁定文档
            using (DocumentLock docLock = m_doc.LockDocument())
            {
                Database db = doc.Database;
                // 新建表格
                Table table = new Table();
                table.SetSize(10, 5);                                     // 表格大小
                table.SetRowHeight(10);                                   // 设置行高
                table.SetColumnWidth(50);                                 // 设置列宽
                table.Columns[0].Width       = 20;                        // 设置第一列宽度为20
                table.Position               = new Point3d(100, 100, 0);  // 设置插入点
                table.Cells[0, 0].TextString = "测试表格数据统计";                // 表头
                table.Cells[0, 0].TextHeight = 6;                         //设置文字高度
                Color color = Color.FromColorIndex(ColorMethod.ByAci, 3); // 声明颜色
                table.Cells[0, 0].BackgroundColor = color;                // 设置背景颜色
                color = Color.FromColorIndex(ColorMethod.ByAci, 1);
                table.Cells[0, 0].ContentColor = color;                   //内容颜色
                //开启事务处理
                using (Transaction trans = acCurDb.TransactionManager.StartTransaction())
                {
                    BlockTable       bt  = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
                    BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    btr.AppendEntity(table);
                    trans.AddNewlyCreatedDBObject(table, true);
                    trans.Commit();
                }
            }

            //判断该文件是否存在
            string strCableName = "Testdoc"; // 保存文件名

            if (!File.Exists("D:" + "\\" + strCableName + ".dwg"))
            {
                //然后另存为并且关闭
                m_doc.Database.SaveAs("D:" + "\\" + strCableName + ".dwg", DwgVersion.Current);  //另存为 这里需要命名
                m_doc.CloseAndDiscard();                                                         //关闭
            }
            else
            {
                File.Delete("D:" + "\\" + strCableName + ".dwg");
                m_doc.Database.SaveAs("D:" + "\\" + strCableName + ".dwg", DwgVersion.Current);
                m_doc.CloseAndDiscard();
            }
        }
Exemplo n.º 20
0
 private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (System.Windows.Forms.Control.MouseButtons == System.Windows.Forms.MouseButtons.Left)
     {
         //start dragDrop operation, MyDropTarget will be called when the cursor enters the AutoCAD view area.
         AcadApp.DoDragDrop(this, "Drag & drop successful!!!", System.Windows.Forms.DragDropEffects.All, new MyDropTarget());
     }
 }
Exemplo n.º 21
0
 TestDb()
 {
     MgdDbg.Test.TestForm dbox = new MgdDbg.Test.TestForm(MgdDbgTestFuncs.RegisteredTestFuncs());
     if (AcadApp.ShowModalDialog(dbox) == DialogResult.OK)
     {
         dbox.DoTest();
     }
 }
Exemplo n.º 22
0
        /// <summary> 以非模态、不阻塞的方式显示窗口 </summary>
        public new void Show()
        {
            Application.ShowModelessDialog(null, this);
            //
            Application.DocumentManager.MdiActiveDocument.CommandWillStart += MdiActiveDocumentOnCommandWillStart;

            StartCommand();
        }
Exemplo n.º 23
0
 private static void initProgressBar()
 {
     progressbar      = new ProgressBarFunc();
     progressbar.Left = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Left + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2 - progressbar.Width / 2;
     progressbar.Top  = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Top + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2 - progressbar.Height / 2;
     Application.ShowModalWindow(null, progressbar, false);
     progressbar.Visibility = System.Windows.Visibility.Collapsed;
 }
Exemplo n.º 24
0
        private void LoadMyCui(string cuiFile)
        {
            Document doc        = Application.DocumentManager.MdiActiveDocument;
            object   oldCmdEcho = Application.GetSystemVariable("CMDECHO");

            Application.SetSystemVariable("CMDECHO", 0);
            doc.SendStringToExecute("(command \"_.CUILOAD\" \"" + cuiFile + "\")(setvar \"CMDECHO\" " + oldCmdEcho + ")(princ) ", false, false, false);
        }
Exemplo n.º 25
0
Arquivo: Ac.cs Projeto: 15831944/Geo7
        private static void DoEvents()
        {
            //Db.TransactionManager.QueueForGraphicsFlush();

            Editor.UpdateScreen();
            AcApp.UpdateScreen();
            //System.Windows.Forms.Application.DoEvents();
        }
Exemplo n.º 26
0
        private void cmdBalanceSite_Click(object sender, RoutedEventArgs e)
        {
            App.ShowModelessDialog(EW.EW_Forms.ewFrms.fBalanceSite);

            if (EW.EW_Forms.ewFrms.fBalanceSite.getExcelData())
            {
                EW.EW_Forms.ewFrms.fBalanceSite.initForm();
            }
        }
Exemplo n.º 27
0
        public static void CreateACPoint()
        {
            var AcDoc  = AcApp.DocumentManager.MdiActiveDocument;
            var AcEdit = AcDoc.Editor;
            var AcDb   = AcDoc.Database;
            var OSnapZ = Convert.ToBoolean(AcApp.TryGetSystemVariable("OSnapZ"));

            if (OSnapZ)
            {
                var ret = MessageBox.Show("Objects will be placed at elevation 0. Continue?", "OSnapZ is on", MessageBoxButtons.YesNo);
                if (ret == DialogResult.No)
                {
                    AcEdit.WriteMessage("Command exited per user input.");
                    return;
                }
            }

            AcEdit.WriteMessage("\nPlease select a point " + (OSnapZ ? "[2D]: " : "[3D]: "));


            PromptPointOptions pointOptions = new PromptPointOptions("\nPlease select a point: ")
            {
                AllowNone    = true,
                UseBasePoint = false
            };

            bool continueCommand = true;

            while (continueCommand)
            {
                var point = AcEdit.GetPoint(pointOptions);
                if (point.Status == PromptStatus.Cancel)
                {
                    break;
                }
                Point3d endPt = point.Value;
                if (OSnapZ)
                {
                    endPt = new Point3d(endPt.X, endPt.Y, 0);
                }

                using (Transaction tr = AcDb.TransactionManager.StartTransaction())
                {
                    // Open the Block table record for read
                    BlockTable acBlkTbl = tr.GetObject(AcDb.BlockTableId, OpenMode.ForRead) as BlockTable;

                    // Open the Block table record Model space for write
                    BlockTableRecord acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                    DBPoint          acPoint     = new DBPoint(endPt);
                    acPoint.SetDatabaseDefaults();
                    acBlkTblRec.AppendEntity(acPoint);
                    tr.AddNewlyCreatedDBObject(acPoint, true);
                    tr.Commit();
                }
            }
        }
Exemplo n.º 28
0
        public static void Attach()
        {
            conMenuExt = new acw.ContextMenuExtension();
            acw.MenuItem mi = new acw.MenuItem("Total Length");
            mi.Click += new EventHandler(OnTotalLength);
            conMenuExt.MenuItems.Add(mi);
            RXClass rxc = Entity.GetClass(typeof(Entity));

            AcAp.AddObjectContextMenuExtension(rxc, conMenuExt);
        }
Exemplo n.º 29
0
        public void Execute(object parameter)
        {
            Application.ShowAlertDialog("실행");

            //if (parameter is RibbonButton)
            //{
            //    RibbonButton button = parameter as RibbonButton;
            //    CallBack(button.Id);
            //}
        }
Exemplo n.º 30
0
 private void InitExportOptions()
 {
     base.ExportOptions.AcadDocument = base.ParentDataset.ParentDocument;
     base.ExportOptions.BoundingBox  = new Extent(base.BoundaryExtent);
     System.Drawing.Size size = Application.ToSystemDrawingSize(base.ParentDataset.ParentDocument.Window.DeviceIndependentSize);
     base.ExportOptions.Width  = size.Width;
     base.ExportOptions.Height = size.Height;
     base.ExportOptions.DPI    = 96;
     base.ExportOptions.Format = "PNG24";
 }