Exemplo n.º 1
0
        public bool Init(ObjectId tableid)
        {
            try
            {
                Database db = HostApplicationServices.WorkingDatabase;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BOQTable table = tr.GetObject(tableid, OpenMode.ForRead) as BOQTable;
                    if (table == null)
                    {
                        return(false);
                    }
                    txtNote.Text                = table.Note;
                    txtHeader.Text              = table.Heading;
                    txtFooter.Text              = table.Footing;
                    udMultiplier.Value          = table.Multiplier;
                    txtTextHeight.Text          = table.Scale.ToString();
                    txtTableRows.Text           = table.MaxRows.ToString();
                    txtTableMargin.Text         = table.TableSpacing.ToString();
                    cbDisplayUnit.SelectedIndex = (table.DisplayUnit == BOQTable.DrawingUnits.Millimeter ? 0 : 1);
                    cbPrecision.SelectedIndex   = table.Precision;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private void BOQEdit(ObjectId tableid)
        {
            using (EditBOQForm form = new EditBOQForm())
            {
                if (!form.Init(tableid))
                {
                    return;
                }

                if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                Database db = HostApplicationServices.WorkingDatabase;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    try
                    {
                        BOQTable table = tr.GetObject(tableid, OpenMode.ForWrite) as BOQTable;
                        if (table == null)
                        {
                            return;
                        }

                        table.SuspendUpdate();

                        Point3d pt = table.BasePoint;
                        table.TransformBy(Matrix3d.Scaling(form.TextHeight / table.Scale, pt));

                        table.Note    = form.TableNote;
                        table.Heading = form.TableHeader;
                        table.Footing = form.TableFooter;

                        table.Multiplier = form.Multiplier;

                        table.MaxRows      = form.TableRows;
                        table.TableSpacing = form.TableMargin;

                        table.DisplayUnit = form.DisplayUnit;
                        table.Precision   = form.Precision;

                        table.ResumeUpdate();

                        tr.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void SetTable()
        {
            ClearItems();

            if (mTable != null)
            {
                mTable.Dispose();
            }

            mTable = new BOQTable();
            mTable.SuspendUpdate();

            string shape = "GENEL";

            if (PosShape.HasPosShape("00"))
            {
                shape = "00";
            }
            mTable.Items.Add(1, 6, 14, 240, shape, "240", "", "", "", "", "");
            if (PosShape.HasPosShape("11"))
            {
                shape = "11";
            }
            mTable.Items.Add(1, 12, 16, 320, shape, "200", "120", "", "", "", "");

            mTable.Multiplier = 2;
            mTable.Precision  = 2;
            mTable.ColumnDef  = Columns;

            mTable.PosLabel               = PosLabel;
            mTable.CountLabel             = CountLabel;
            mTable.DiameterLabel          = DiameterLabel;
            mTable.LengthLabel            = LengthLabel;
            mTable.ShapeLabel             = ShapeLabel;
            mTable.TotalLengthLabel       = TotalLengthLabel;
            mTable.DiameterListLabel      = DiameterListLabel;
            mTable.DiameterLengthLabel    = DiameterLengthLabel;
            mTable.UnitWeightLabel        = UnitWeightLabel;
            mTable.WeightLabel            = WeightLabel;
            mTable.GrossWeightLabel       = GrossWeightLabel;
            mTable.MultiplierHeadingLabel = MultiplierHeadingLabel;

            mTable.TextStyleId    = TextStyleId;
            mTable.HeadingStyleId = HeadingStyleId;
            mTable.FootingStyleId = FootingStyleId;

            mTable.ResumeUpdate();

            AddItem(mTable);
        }
Exemplo n.º 4
0
        // Refreshes given items
        public static void RefreshTable(IEnumerable <ObjectId> ids)
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    foreach (ObjectId posid in ids)
                    {
                        BOQTable table = tr.GetObject(posid, OpenMode.ForWrite) as BOQTable;
                        table.Update();
                        table.Draw();
                    }

                    tr.Commit();
                }
                catch
                {
                    ;
                }
            }
        }
Exemplo n.º 5
0
        private bool DrawBOQ()
        {
            using (DrawBOQForm form = new DrawBOQForm())
            {
                // Pos error check
                PromptSelectionResult sel = DWGUtility.SelectAllPosUser();
                if (sel.Status != PromptStatus.OK)
                {
                    return(false);
                }
                ObjectId[] items = sel.Value.GetObjectIds();

                List <PosCheckResult> errors   = PosCheckResult.CheckAllInSelection(items, true, false);
                List <PosCheckResult> warnings = PosCheckResult.CheckAllInSelection(items, false, true);

                if (errors.Count != 0)
                {
                    PosCheckResult.ConsoleOut(errors);
                }
                if (warnings.Count != 0)
                {
                    PosCheckResult.ConsoleOut(warnings);
                }

                if (errors.Count != 0)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.DisplayTextScreen = true;
                    return(false);
                }

                // Pos similarity check
                if (warnings.Count != 0)
                {
                    Autodesk.AutoCAD.ApplicationServices.Application.DisplayTextScreen = true;
                    PromptKeywordOptions opts = new PromptKeywordOptions("\nMetraja devam edilsin mi? [Evet/Hayir]", "Yes No");
                    PromptResult         res  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetKeywords(opts);
                    if (res.Status != PromptStatus.OK || res.StringResult == "No")
                    {
                        return(true);
                    }
                }

                if (!form.Init())
                {
                    return(false);
                }

                if (Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(null, form, false) != System.Windows.Forms.DialogResult.OK)
                {
                    return(true);
                }

                List <PosCopy> posList = new List <PosCopy>();
                try
                {
                    posList = PosCopy.ReadAllInSelection(items, true, PosCopy.PosGrouping.PosMarker);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (posList.Count == 0)
                {
                    MessageBox.Show("Seçilen grupta poz mevcut değil.", "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                posList = RemoveEmpty(posList);
                if (!form.HideMissing)
                {
                    posList = AddMissing(posList);
                }
                posList = SortList(posList);

                PromptPointResult result = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("Baz noktası: ");
                if (result.Status != PromptStatus.OK)
                {
                    return(true);
                }

                Database db = HostApplicationServices.WorkingDatabase;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    try
                    {
                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                        BOQTable table = new BOQTable();
                        table.SuspendUpdate();

                        Point3d pt = result.Value;
                        table.TransformBy(Matrix3d.Displacement(pt.GetAsVector()));
                        table.TransformBy(Matrix3d.Scaling(form.TextHeight, pt));
                        table.Note    = form.TableNote;
                        table.Heading = form.TableHeader;
                        table.Footing = form.TableFooter;

                        table.DisplayUnit = form.DisplayUnit;
                        table.Precision   = form.Precision;

                        table.Multiplier = form.Multiplier;

                        BOQStyle style = form.TableStyle;
                        table.ColumnDef = style.Columns;

                        table.TextStyleId    = style.TextStyleId;
                        table.HeadingStyleId = style.HeadingStyleId;
                        table.FootingStyleId = style.FootingStyleId;

                        table.PosLabel               = style.PosLabel;
                        table.CountLabel             = style.CountLabel;
                        table.DiameterLabel          = style.DiameterLabel;
                        table.LengthLabel            = style.LengthLabel;
                        table.ShapeLabel             = style.ShapeLabel;
                        table.TotalLengthLabel       = style.TotalLengthLabel;
                        table.DiameterListLabel      = style.DiameterListLabel;
                        table.DiameterLengthLabel    = style.DiameterLengthLabel;
                        table.UnitWeightLabel        = style.UnitWeightLabel;
                        table.WeightLabel            = style.WeightLabel;
                        table.GrossWeightLabel       = style.GrossWeightLabel;
                        table.MultiplierHeadingLabel = style.MultiplierHeadingLabel;

                        table.MaxRows      = form.TableRows;
                        table.TableSpacing = form.TableMargin;

                        double lengthScale = 1.0;
                        switch (table.DisplayUnit)
                        {
                        case BOQTable.DrawingUnits.Millimeter:
                            lengthScale = 1.0;
                            break;

                        case BOQTable.DrawingUnits.Centimeter:
                            lengthScale = 0.1;
                            break;

                        case BOQTable.DrawingUnits.Decimeter:
                            lengthScale = 0.01;
                            break;

                        case BOQTable.DrawingUnits.Meter:
                            lengthScale = 0.001;
                            break;
                        }

                        // Add rows
                        foreach (PosCopy copy in posList)
                        {
                            if (copy.existing)
                            {
                                string a = string.Empty;
                                string b = string.Empty;
                                string c = string.Empty;
                                string d = string.Empty;
                                string e = string.Empty;
                                string f = string.Empty;

                                if (copy.isVarA)
                                {
                                    a = (copy.minA * lengthScale).ToString("F0") + "~" + (copy.maxA * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    a = (copy.minA * lengthScale).ToString("F0");
                                }
                                if (copy.isVarB)
                                {
                                    b = (copy.minB * lengthScale).ToString("F0") + "~" + (copy.maxB * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    b = (copy.minB * lengthScale).ToString("F0");
                                }
                                if (copy.isVarC)
                                {
                                    c = (copy.minC * lengthScale).ToString("F0") + "~" + (copy.maxC * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    c = (copy.minC * lengthScale).ToString("F0");
                                }
                                if (copy.isVarD)
                                {
                                    d = (copy.minD * lengthScale).ToString("F0") + "~" + (copy.maxD * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    d = (copy.minD * lengthScale).ToString("F0");
                                }
                                if (copy.isVarE)
                                {
                                    e = (copy.minE * lengthScale).ToString("F0") + "~" + (copy.maxE * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    e = (copy.minE * lengthScale).ToString("F0");
                                }
                                if (copy.isVarF)
                                {
                                    f = (copy.minF * lengthScale).ToString("F0") + "~" + (copy.maxF * lengthScale).ToString("F0");
                                }
                                else
                                {
                                    f = (copy.minF * lengthScale).ToString("F0");
                                }

                                table.Items.Add(int.Parse(copy.pos), copy.count, double.Parse(copy.diameter), copy.length1, copy.length2, copy.isVarLength, copy.shapename, a, b, c, d, e, f);
                            }
                            else
                            {
                                table.Items.Add(int.Parse(copy.pos));
                            }
                        }

                        table.ResumeUpdate();

                        table.SetDatabaseDefaults(db);

                        btr.AppendEntity(table);
                        tr.AddNewlyCreatedDBObject(table, true);

                        tr.Commit();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        public void SetTable()
        {
            ClearItems();

            if (mTable != null) mTable.Dispose();

            mTable = new BOQTable();
            mTable.SuspendUpdate();

            string shape = "GENEL";
            if (PosShape.HasPosShape("00"))
                shape = "00";
            mTable.Items.Add(1, 6, 14, 240, shape, "240", "", "", "", "", "");
            if (PosShape.HasPosShape("11"))
                shape = "11";
            mTable.Items.Add(1, 12, 16, 320, shape, "200", "120", "", "", "", "");

            mTable.Multiplier = 2;
            mTable.Precision = 2;
            mTable.ColumnDef = Columns;

            mTable.PosLabel = PosLabel;
            mTable.CountLabel = CountLabel;
            mTable.DiameterLabel = DiameterLabel;
            mTable.LengthLabel = LengthLabel;
            mTable.ShapeLabel = ShapeLabel;
            mTable.TotalLengthLabel = TotalLengthLabel;
            mTable.DiameterListLabel = DiameterListLabel;
            mTable.DiameterLengthLabel = DiameterLengthLabel;
            mTable.UnitWeightLabel = UnitWeightLabel;
            mTable.WeightLabel = WeightLabel;
            mTable.GrossWeightLabel = GrossWeightLabel;
            mTable.MultiplierHeadingLabel = MultiplierHeadingLabel;

            mTable.TextStyleId = TextStyleId;
            mTable.HeadingStyleId = HeadingStyleId;
            mTable.FootingStyleId = FootingStyleId;

            mTable.ResumeUpdate();

            AddItem(mTable);
        }