コード例 #1
0
        private bool PosEdit(ObjectId id, Point3d pt)
        {
            bool detached = false;

            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    RebarPos pos = tr.GetObject(id, OpenMode.ForRead) as RebarPos;
                    if (pos == null)
                    {
                        return(false);
                    }

                    detached = pos.Detached;
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            if (detached)
            {
                using (EditDetachedPosForm form = new EditDetachedPosForm())
                {
                    if (form.Init(id, pt))
                    {
                        if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) == System.Windows.Forms.DialogResult.OK)
                        {
                            return(true);
                        }
                    }
                }
            }
            else
            {
                using (EditPosForm form = new EditPosForm())
                {
                    if (form.Init(id, pt))
                    {
                        if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) == System.Windows.Forms.DialogResult.OK)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: Commands_PosEdit.cs プロジェクト: oozcitak/RebarPos
        private bool PosEdit(ObjectId id, Point3d pt)
        {
            bool detached = false;

            Database db = HostApplicationServices.WorkingDatabase;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    RebarPos pos = tr.GetObject(id, OpenMode.ForRead) as RebarPos;
                    if (pos == null) return false;

                    detached = pos.Detached;
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
            }

            if (detached)
            {
                using (EditDetachedPosForm form = new EditDetachedPosForm())
                {
                    if (form.Init(id, pt))
                    {
                        if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) == System.Windows.Forms.DialogResult.OK)
                        {
                            return true;
                        }
                    }
                }
            }
            else
            {
                using (EditPosForm form = new EditPosForm())
                {
                    if (form.Init(id, pt))
                    {
                        if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) == System.Windows.Forms.DialogResult.OK)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }