Ejemplo n.º 1
0
        private void outputWeight(_Area_v2 a, int weight)
        {
            _Db.DBObject currentEntity = _c.trans.GetObject(a.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

            if (currentEntity is _Db.BlockReference)
            {
                _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                {
                    _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                    _Db.AttributeReference ar  = obj as _Db.AttributeReference;

                    if (ar != null)
                    {
                        if (ar.Tag == "SUMMA_OVRIG_ARMERING")
                        {
                            if (weight == 0)
                            {
                                write("[WARINING] Weight set to 'YYY'");
                                ar.TextString = "YYY";
                            }
                            else
                            {
                                ar.TextString = weight.ToString();
                            }
                        }
                    }
                }
            }

            _c.trans.Commit();
        }
Ejemplo n.º 2
0
        private List <T.BendingShape> getBendingData(List <_Db.BlockReference> blocks)
        {
            List <T.BendingShape> parse = new List <T.BendingShape>();

            foreach (_Db.BlockReference block in blocks)
            {
                G.Point        insp    = new G.Point(block.Position.X, block.Position.Y);
                T.BendingShape current = new T.BendingShape(insp, block.Name);

                foreach (_Db.ObjectId arId in block.AttributeCollection)
                {
                    _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                    _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                    setBendingParameters(ar, current);
                }

                current.validator();
                if (current.Valid)
                {
                    parse.Add(current);
                }
                else
                {
                    write(current.Reason);
                }
            }

            return(parse);
        }
Ejemplo n.º 3
0
        public void renameBlockFields(string find, string replace)
        {
            foreach (_Db.ObjectId btrId in _c.blockTable)
            {
                _Db.BlockTableRecord btr = _c.trans.GetObject(btrId, _Db.OpenMode.ForWrite) as _Db.BlockTableRecord;

                _Db.ObjectIdCollection blockRefIds = btr.GetBlockReferenceIds(true, true);

                foreach (_Db.ObjectId btRfId in blockRefIds)
                {
                    _Db.BlockReference br = _c.trans.GetObject(btRfId, _Db.OpenMode.ForWrite) as _Db.BlockReference;

                    if (br != null)
                    {
                        foreach (_Db.ObjectId arId in br.AttributeCollection)
                        {
                            _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                            _Db.AttributeReference ar  = obj as _Db.AttributeReference;

                            if (ar != null)
                            {
                                ar.TextString = ar.TextString.Replace(find, replace);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void setRowAttribute(_Db.AttributeReference ar, T.TableBendingRow row)
        {
            if (ar != null)
            {
                if (ar.Tag == "Klass")
                {
                    row.Material = ar.TextString;
                }
                else if (ar.Tag == "Pos")
                {
                    row.Position = ar.TextString;
                }
                else
                {
                    int temp = 99999;
                    Int32.TryParse(ar.TextString, out temp);

                    if (ar.Tag == "Diam")
                    {
                        row.Diameter = temp;
                    }
                    else if (ar.Tag == "tk")
                    {
                        row.Count = temp;
                    }
                    else if (ar.Tag == "Pikkus")
                    {
                        row.Length = temp;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 protected override bool Update()
 {
     base.Update();
     foreach (AcDb.ObjectId id in _br.AttributeCollection)
     {
         AcDb.AttributeReference att = (AcDb.AttributeReference)id.GetObject(AcDb.OpenMode.ForWrite);
         att.Rotation = _br.Rotation;
         string tag = att.Tag.ToUpper();
         if (_attInfos.ContainsKey(tag))
         {
             TextInfo ti = _attInfos[tag];
             att.Position = ti.Position.TransformBy(_br.BlockTransform);
             if (ti.IsAligned)
             {
                 att.AlignmentPoint =
                     ti.Alignment.TransformBy(_br.BlockTransform);
                 att.AdjustAlignment(_br.Database);
             }
             if (att.IsMTextAttribute)
             {
                 att.UpdateMTextAttribute();
             }
             att.Rotation = ti.Rotation + _br.Rotation;
         }
     }
     return(true);
 }
Ejemplo n.º 6
0
        public static void ReplaceAttributeBlock(AcDb.ObjectId idBlock,
                                                 string tag,
                                                 string newValue,
                                                 Boolean visible)
        {
            try
            {
                //using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
                //{
                //    DBObject dbObj = tr.GetObject(idBlock, AcDb.OpenMode.ForRead) as DBObject;
                //    AcDb.BlockReference blockReference = dbObj as BlockReference;
                //    ReplaceAttributeBlock(blockReference, tag, newValue, visible);
                //}


                using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
                {
                    AcDb.BlockTable acBlockTable = (AcDb.BlockTable)tr.GetObject(db.BlockTableId, AcDb.OpenMode.ForRead);
                    if (acBlockTable == null)
                    {
                        return;
                    }

                    AcDb.BlockTableRecord acBlockTableRecord = (AcDb.BlockTableRecord)
                                                               tr.GetObject(acBlockTable[AcDb.BlockTableRecord.ModelSpace], AcDb.OpenMode.ForRead);
                    if (acBlockTableRecord == null)
                    {
                        return;
                    }

                    //foreach (var blkId in acBlockTableRecord)
                    //{
                    AcDb.BlockReference acBlock = (AcDb.BlockReference)tr.GetObject(idBlock, AcDb.OpenMode.ForRead);
                    //if (acBlock == null) continue;
                    //if (!acBlock.Name.Equals(blockName, StringComparison.CurrentCultureIgnoreCase)) continue;
                    foreach (AcDb.ObjectId attId in acBlock.AttributeCollection)
                    {
                        AcDb.AttributeReference acAtt = (AcDb.AttributeReference)tr.GetObject(attId, AcDb.OpenMode.ForRead);
                        if (acAtt == null)
                        {
                            continue;
                        }

                        if (!acAtt.Tag.Equals(tag, StringComparison.CurrentCultureIgnoreCase))
                        {
                            continue;
                        }

                        acAtt.UpgradeOpen();
                        acAtt.TextString = newValue;
                    }
                    //}
                    tr.Commit();
                }
            }
            catch //(System.Exception exc)
            {
            }
        }
Ejemplo n.º 7
0
        public static void ManualInsertbAttribute(string nameBlock)
        {
            using (AcDb.Transaction tr = db.TransactionManager.StartTransaction())
            {
                AcDb.BlockTable blockTable = (AcDb.BlockTable)tr.GetObject(db.BlockTableId, AcDb.OpenMode.ForRead);
                if (!blockTable.Has(nameBlock))
                {
                    ed.WriteMessage("\nНезнайдено блок '{0}' у таблиці блоків креслення.", nameBlock);
                    return;
                }
                AcDb.BlockTableRecord curSpace       = (AcDb.BlockTableRecord)tr.GetObject(db.CurrentSpaceId, AcDb.OpenMode.ForWrite);
                AcDb.BlockReference   blockReference = new AcDb.BlockReference(AcGe.Point3d.Origin, blockTable[nameBlock]);
                blockReference.TransformBy(ed.CurrentUserCoordinateSystem);
                curSpace.AppendEntity(blockReference);
                tr.AddNewlyCreatedDBObject(blockReference, true);

                AcDb.BlockTableRecord btr = (AcDb.BlockTableRecord)tr.GetObject(blockTable[nameBlock], AcDb.OpenMode.ForRead);
                AcDb.DBText           text;
                foreach (AcDb.ObjectId id in btr)
                {
                    if (id.ObjectClass.Name == "AcDbAttributeDefinition")
                    {
                        AcDb.AttributeDefinition attDef =
                            (AcDb.AttributeDefinition)tr.GetObject(id, AcDb.OpenMode.ForRead);

                        text = new AcDb.DBText
                        {
                            TextString = "jig_test"
                        };

                        TextPlacementJig jig = new TextPlacementJig(text);

                        //PromptResult pr = ed.Drag(jig);

                        AcEd.PromptStatus stat = AcEd.PromptStatus.Keyword;
                        while (stat == AcEd.PromptStatus.Keyword)
                        {
                            AcEd.PromptResult pr = ed.Drag(jig);
                            stat = pr.Status;
                            if (stat != AcEd.PromptStatus.OK && stat != AcEd.PromptStatus.Keyword)
                            {
                                return;
                            }
                        }

                        AcDb.AttributeReference attRef = new AcDb.AttributeReference();
                        attRef.SetAttributeFromBlock(attDef, blockReference.BlockTransform);
                        AcDb.ObjectId attId = blockReference.AttributeCollection.AppendAttribute(attRef);
                        tr.AddNewlyCreatedDBObject(attRef, true);


                        tr.Commit();
                        //if (pr.Status != PromptStatus.OK) blockReference.Erase();
                    }
                }

                //tr.Commit();
            }
        }
Ejemplo n.º 8
0
        private string getAreaName(_Area_v2 area)
        {
            string ritn_nr = "x";

            _Db.DBObject currentEntity = _c.trans.GetObject(area.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

            if (currentEntity is _Db.BlockReference)
            {
                _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                {
                    _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                    _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                    if (ar != null)
                    {
                        if (ar.Tag == "RITN_NR")
                        {
                            ritn_nr = ar.TextString;
                        }

                        if (blockRef.Name == "KN-V23")
                        {
                            if (ar.Tag == "RITN_23_NR")
                            {
                                ritn_nr = ar.TextString;
                            }
                        }
                        else if (blockRef.Name == "KN-V27")
                        {
                            if (ar.Tag == "RITN_27_NR")
                            {
                                ritn_nr = ar.TextString;
                            }
                        }
                    }
                }

                if (blockRef.Name == "KN-V23")
                {
                    if (!ritn_nr.Contains("23"))
                    {
                        ritn_nr = "V23-" + ritn_nr;
                    }
                }
                else if (blockRef.Name == "KN-V27")
                {
                    if (!ritn_nr.Contains("73"))
                    {
                        ritn_nr = "V27-" + ritn_nr;
                    }
                }
            }

            return(ritn_nr);
        }
Ejemplo n.º 9
0
        private void get27Data(List <element> elements)
        {
            foreach (element el in elements)
            {
                _Area_v2 area = el._27;

                string date         = "xyz";
                string rev          = "xyz";
                string net_weight   = "xyz";
                string reinf_weight = "xyz";

                _Db.DBObject currentEntity = _c.trans.GetObject(area.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

                if (currentEntity is _Db.BlockReference)
                {
                    _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                    foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                    {
                        _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                        _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                        if (ar != null)
                        {
                            if (ar.Tag == "DATUM")
                            {
                                date = ar.TextString;
                            }
                            if (ar.Tag == "REVISION")
                            {
                                rev = ar.TextString;
                            }
                            if (ar.Tag == "SUMMA_NATARMERING")
                            {
                                net_weight = ar.TextString;
                            }
                            if (ar.Tag == "SUMMA_OVRIG_ARMERING")
                            {
                                reinf_weight = ar.TextString;
                            }
                        }
                    }
                }

                el._date27    = date;
                el._rev27     = rev;
                el._sum_net   = net_weight;
                el._sum_reinf = reinf_weight;
            }
        }
Ejemplo n.º 10
0
        public static void ReplaceAttributeBlock(AcDb.BlockReference blockReference,
                                                 Dictionary <string, string> tags,
                                                 Boolean visible)
        {
            using (AcDb.Transaction trAdding = db.TransactionManager.StartTransaction())
            {
                AcDb.BlockTable       btTable  = (AcDb.BlockTable)trAdding.GetObject(db.BlockTableId, AcDb.OpenMode.ForRead);
                AcDb.BlockTableRecord btrTable =
                    (AcDb.BlockTableRecord)btTable[blockReference.Name].GetObject(AcDb.OpenMode.ForRead);

                if (btrTable.HasAttributeDefinitions)
                {
                    var attDefs = btrTable.Cast <AcDb.ObjectId>()
                                  .Where(n => n.ObjectClass.Name == "AcDbAttributeDefinition")
                                  .Select(n => (AcDb.AttributeDefinition)n.GetObject(AcDb.OpenMode.ForRead));

                    foreach (AcDb.AttributeDefinition attDef in attDefs)
                    {
                        AcDb.AttributeReference attRef = new AcDb.AttributeReference();
                        attRef.SetAttributeFromBlock(attDef, blockReference.BlockTransform);

                        foreach (var tag in tags)
                        {
                            attRef.UpgradeOpen();
                            if (tag.Key.ToUpper() == attRef.Tag)
                            {
                                attRef.TextString = tag.Value;
                            }
                            else
                            {
                                attRef.TextString = "NoneValue";
                            }
                            attRef.Visible  = visible;
                            attRef.Rotation = 0;
                        }

                        blockReference.AttributeCollection.AppendAttribute(attRef);
                        trAdding.AddNewlyCreatedDBObject(attRef, false);
                    }
                }
                else
                {
                    ed.WriteMessage("\n < ERROR > ");
                }

                trAdding.Commit();
            }
        }
Ejemplo n.º 11
0
        private string getAttributeValue(_Db.BlockReference block, string[] attribute)
        {
            foreach (_Db.ObjectId arId in block.AttributeCollection)
            {
                _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                _Db.AttributeReference ar  = obj as _Db.AttributeReference;

                if (ar != null)
                {
                    if (attribute.Contains(ar.Tag))
                    {
                        return(ar.TextString);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 12
0
        private static bool GetAttributeInfos(_AcEd.Editor ed, _AcAp.Document doc)
        {
            bool ok = false;

            _BlockName      = string.Empty;
            _AttributeName  = string.Empty;
            _AttributeValue = string.Empty;

            _AcEd.PromptNestedEntityResult per = ed.GetNestedEntity("\nZu änderndes Attribut wählen: ");

            if (per.Status == _AcEd.PromptStatus.OK)
            {
                using (var tr = doc.TransactionManager.StartTransaction())
                {
                    _AcDb.DBObject           obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead);
                    _AcDb.AttributeReference ar  = obj as _AcDb.AttributeReference;
                    if (ar != null && !ar.IsConstant)
                    {
                        _AcDb.BlockReference br = Plan2Ext.Globs.GetBlockFromItsSubentity(tr, per);
                        if (br != null)
                        {
                            ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nBlockname: {0}, Attributname: {1}.", Plan2Ext.Globs.GetBlockname(br, tr), ar.Tag));
                            var prompt = new _AcEd.PromptStringOptions("\nText in Attribut: ");
                            prompt.AllowSpaces = true;
                            var prefixUserRes = ed.GetString(prompt);
                            if (prefixUserRes.Status == _AcEd.PromptStatus.OK)
                            {
                                _AttributeValue = prefixUserRes.StringResult;
                                _AttributeName  = ar.Tag;
                                _BlockName      = Plan2Ext.Globs.GetBlockname(br, tr);

                                log.InfoFormat(CultureInfo.CurrentCulture, "Block: {0}, Attribut: {1}, Wert: '{2}'", _BlockName, _AttributeName, _AttributeValue);

                                ok = true;
                            }
                        }
                    }

                    tr.Commit();
                }
            }
            return(ok);
        }
Ejemplo n.º 13
0
        private void insertBending(R.Raud _ALFA_, G.Point insertion)
        {
            string layerName = "K023TL";
            string blockName = getBendingBlockName(_ALFA_);

            _Ge.Point3d insertPointBlock = new _Ge.Point3d(insertion.X, insertion.Y, 0);

            using (_Db.BlockReference newBlockReference = new _Db.BlockReference(insertPointBlock, _c.blockTable[blockName]))
            {
                newBlockReference.Layer = layerName;
                _c.modelSpace.AppendEntity(newBlockReference);
                _c.trans.AddNewlyCreatedDBObject(newBlockReference, true);

                newBlockReference.TransformBy(_Ge.Matrix3d.Scaling(L._V_.Z_DRAWING_SCALE, insertPointBlock));

                _Db.BlockTableRecord blockBlockTable = _c.trans.GetObject(_c.blockTable[blockName], _Db.OpenMode.ForRead) as _Db.BlockTableRecord;
                if (blockBlockTable.HasAttributeDefinitions)
                {
                    foreach (_Db.ObjectId objID in blockBlockTable)
                    {
                        _Db.DBObject obj = _c.trans.GetObject(objID, _Db.OpenMode.ForRead) as _Db.DBObject;

                        if (obj is _Db.AttributeDefinition)
                        {
                            _Db.AttributeDefinition attDef = obj as _Db.AttributeDefinition;

                            if (!attDef.Constant)
                            {
                                using (_Db.AttributeReference attRef = new _Db.AttributeReference())
                                {
                                    attRef.SetAttributeFromBlock(attDef, newBlockReference.BlockTransform);
                                    attRef.Position = attDef.Position.TransformBy(newBlockReference.BlockTransform);
                                    setBendingBlockParameters(attRef, _ALFA_);
                                    newBlockReference.AttributeCollection.AppendAttribute(attRef);
                                    _c.trans.AddNewlyCreatedDBObject(attRef, true);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private List <T.TableBendingRow> getRowData(List <_Db.BlockReference> blocks)
        {
            List <T.TableBendingRow> parse = new List <T.TableBendingRow>();

            foreach (_Db.BlockReference block in blocks)
            {
                G.Point           insp    = new G.Point(block.Position.X, block.Position.Y);
                T.TableBendingRow current = new T.TableBendingRow(insp);

                foreach (_Db.ObjectId arId in block.AttributeCollection)
                {
                    _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                    _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                    setRowAttribute(ar, current);
                }

                parse.Add(current);
            }

            return(parse);
        }
Ejemplo n.º 15
0
 private void setRowParameters(_Db.AttributeReference ar, T.TableMaterialRow sumData)
 {
     if (ar != null)
     {
         if (ar.Tag == "Diam")
         {
             ar.TextString = sumData.Text;
         }
         else if (ar.Tag == "Klass")
         {
             ar.TextString = sumData.Material;
         }
         else if (ar.Tag == "Mass")
         {
             ar.TextString = sumData.Weight.ToString("F2").Replace(",", ".");
         }
         else if (ar.Tag == "Ühik")
         {
             ar.TextString = sumData.Units;
         }
     }
 }
Ejemplo n.º 16
0
        private void insertRow(G.Point insertion, T.TableBendingRow rowData, double scale, string tableBendingRow)
        {
            _Ge.Point3d insertPointBlock = new _Ge.Point3d(insertion.X, insertion.Y, 0);
            using (_Db.BlockReference newBlockReference = new _Db.BlockReference(insertPointBlock, _c.blockTable[tableBendingRow]))
            {
                newBlockReference.Layer = bendingLayer;
                _c.modelSpace.AppendEntity(newBlockReference);
                _c.trans.AddNewlyCreatedDBObject(newBlockReference, true);
                newBlockReference.TransformBy(_Ge.Matrix3d.Scaling(scale, insertPointBlock));

                _Db.BlockTableRecord blockBlockTable = _c.trans.GetObject(_c.blockTable[tableBendingRow], _Db.OpenMode.ForRead) as _Db.BlockTableRecord;
                if (blockBlockTable.HasAttributeDefinitions)
                {
                    foreach (_Db.ObjectId objID in blockBlockTable)
                    {
                        _Db.DBObject obj = _c.trans.GetObject(objID, _Db.OpenMode.ForRead) as _Db.DBObject;

                        if (obj is _Db.AttributeDefinition)
                        {
                            _Db.AttributeDefinition attDef = obj as _Db.AttributeDefinition;

                            if (!attDef.Constant)
                            {
                                using (_Db.AttributeReference attRef = new _Db.AttributeReference())
                                {
                                    attRef.SetAttributeFromBlock(attDef, newBlockReference.BlockTransform);
                                    attRef.Position = attDef.Position.TransformBy(newBlockReference.BlockTransform);
                                    setRowParameters(attRef, rowData);
                                    newBlockReference.AttributeCollection.AppendAttribute(attRef);
                                    _c.trans.AddNewlyCreatedDBObject(attRef, true);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void getSettings()
        {
            _Db.TypedValue[] filterlist = new _Db.TypedValue[2];
            filterlist[0] = new _Db.TypedValue(0, "INSERT");
            filterlist[1] = new _Db.TypedValue(2, "Reinf_program_settings");
            _Ed.SelectionFilter filter = new _Ed.SelectionFilter(filterlist);

            _Ed.PromptSelectionOptions opts = new _Ed.PromptSelectionOptions();
            opts.MessageForAdding = "\nSelect Reinf_program_settings block: ";

            _Ed.PromptSelectionResult selection = _c.ed.GetSelection(opts, filter);
            if (selection.Status != _Ed.PromptStatus.OK)
            {
                throw new DMTException("[ERROR] Reinf_program_settings - cancelled");
            }
            if (selection.Value.Count != 1)
            {
                throw new DMTException("[ERROR] Reinf_program_settings - too many in selection");
            }


            _Db.ObjectId       selectionId = selection.Value.GetObjectIds()[0];
            _Db.BlockReference selectionBR = _c.trans.GetObject(selectionId, _Db.OpenMode.ForWrite) as _Db.BlockReference;

            L._V_.Z_DRAWING_SCALE = selectionBR.ScaleFactors.X;

            foreach (_Db.ObjectId arId in selectionBR.AttributeCollection)
            {
                _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                _Db.AttributeReference ar  = obj as _Db.AttributeReference;

                if (ar != null)
                {
                    setProgramVariables(ar);
                }
            }
        }
Ejemplo n.º 18
0
        private void get23Data(List <element> elements)
        {
            foreach (element el in elements)
            {
                _Area_v2 area = el._23;

                string date = "xyz";
                string rev  = "xyz";

                _Db.DBObject currentEntity = _c.trans.GetObject(area.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

                if (currentEntity is _Db.BlockReference)
                {
                    _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                    foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                    {
                        _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                        _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                        if (ar != null)
                        {
                            if (ar.Tag == "DATUM")
                            {
                                date = ar.TextString;
                            }
                            if (ar.Tag == "REVISION")
                            {
                                rev = ar.TextString;
                            }
                        }
                    }
                }

                el._date23 = date;
                el._rev23  = rev;
            }
        }
Ejemplo n.º 19
0
        private void dump()
        {
            _Db.HostApplicationServices hs = _Db.HostApplicationServices.Current;
            string dwg_path = hs.FindFile(_c.doc.Name, _c.doc.Database, _Db.FindFileHint.Default);
            string dwg_dir  = Path.GetDirectoryName(dwg_path);
            string dwg_name = Path.GetFileNameWithoutExtension(dwg_path);

            if (!dwg_dir.EndsWith(@"\"))
            {
                dwg_dir = dwg_dir + @"\";
            }
            string csv_dir  = dwg_dir + @"temp_armering\";
            string csv_path = csv_dir + dwg_name + ".csv";

            if (total_stats == null || total_stats.Count == 0)
            {
                return;
            }

            if (!Directory.Exists(Path.GetDirectoryName(csv_path)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(csv_path));
            }
            if (File.Exists(csv_path))
            {
                File.Delete(csv_path);
            }

            StringBuilder txt = new StringBuilder();

            write(csv_path);
            txt.AppendLine("alexi programmi ajutine file");
            txt.AppendLine("shape; positsioon; kogus; diameter");
            txt.AppendLine("");
            txt.AppendLine("SUMMARY");

            foreach (_Mark u in total_stats)
            {
                if (u.Number == 0 && u.Diameter == 0)
                {
                    continue;
                }
                txt.AppendLine(u.Position_Shape.ToString() + ";" + u.Position_Nr.ToString() + ";" + u.Number.ToString() + ";" + u.Diameter.ToString());
            }

            txt.AppendLine("!---SUMMARY");

            // LOCAL

            foreach (_Area_v2 a in local_stats.Keys)
            {
                string ritn_nr = "x";

                _Db.DBObject currentEntity = _c.trans.GetObject(a.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

                if (currentEntity is _Db.BlockReference)
                {
                    _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                    foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                    {
                        _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                        _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                        if (ar != null)
                        {
                            if (ar.Tag == "RITN_NR")
                            {
                                ritn_nr = ar.TextString;
                            }

                            if (blockRef.Name == "KN-V23")
                            {
                                if (ar.Tag == "RITN_23_NR")
                                {
                                    ritn_nr = ar.TextString;
                                }
                            }
                            else if (blockRef.Name == "KN-V27")
                            {
                                if (ar.Tag == "RITN_27_NR")
                                {
                                    ritn_nr = ar.TextString;
                                }
                            }
                        }
                    }
                }


                txt.AppendLine("");
                txt.AppendLine("[" + ritn_nr + "]");
                List <_Mark> stats = local_stats[a];

                if (stats.Count == 0)
                {
                    txt.AppendLine("empty");
                }
                else
                {
                    foreach (_Mark u in stats)
                    {
                        if (u.Number == 0 && u.Diameter == 0)
                        {
                            continue;
                        }
                        txt.AppendLine(u.Position_Shape.ToString() + ";" + u.Position_Nr.ToString() + ";" + u.Number.ToString() + ";" + u.Diameter.ToString());
                    }
                }
            }

            string csvText = txt.ToString();

            File.AppendAllText(csv_path, csvText);
        }
Ejemplo n.º 20
0
        private void setBendingBlockParameters(_Db.AttributeReference ar, R.Raud _ALFA_)
        {
            if (ar != null)
            {
                if (ar.Tag == "Teraseklass")
                {
                    ar.TextString = _ALFA_.Materjal.ToString();
                }
                if (ar.Tag == "Positsioon")
                {
                    ar.TextString = _ALFA_.ToStringNoCount();
                }

                if (_ALFA_ is R.A_Raud)
                {
                    R.A_Raud _BETA_ = _ALFA_ as R.A_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                }

                if (_ALFA_ is R.B_Raud)
                {
                    R.B_Raud _BETA_ = _ALFA_ as R.B_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                    else if (ar.Tag == "B")
                    {
                        ar.TextString = _BETA_.B.ToString();
                    }
                }

                if (_ALFA_ is R.C_Raud)
                {
                    R.C_Raud _BETA_ = _ALFA_ as R.C_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                    else if (ar.Tag == "B")
                    {
                        ar.TextString = _BETA_.B.ToString();
                    }
                    else if (ar.Tag == "U")
                    {
                        ar.TextString = ((int)Math.Round(G.Converter.ToDeg(_BETA_.U), 0)).ToString();
                    }
                }

                if (_ALFA_ is R.D_Raud)
                {
                    R.D_Raud _BETA_ = _ALFA_ as R.D_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                    else if (ar.Tag == "B")
                    {
                        ar.TextString = _BETA_.B2.ToString(); // parand magic
                    }
                    else if (ar.Tag == "C")
                    {
                        ar.TextString = _BETA_.C.ToString();
                    }
                }

                if (_ALFA_ is R.E_Raud)
                {
                    R.E_Raud _BETA_ = _ALFA_ as R.E_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                    else if (ar.Tag == "B")
                    {
                        ar.TextString = _BETA_.B2.ToString(); // parand magic
                    }
                    else if (ar.Tag == "C")
                    {
                        ar.TextString = _BETA_.C.ToString();
                    }
                    else if (ar.Tag == "U")
                    {
                        ar.TextString = ((int)Math.Round(G.Converter.ToDeg(_BETA_.U), 0)).ToString();
                    }
                    else if (ar.Tag == "V")
                    {
                        ar.TextString = ((int)Math.Round(G.Converter.ToDeg(_BETA_.V), 0)).ToString();
                    }
                    else if (ar.Tag == "X")
                    {
                        ar.TextString = ((int)_BETA_.X).ToString();
                    }
                    else if (ar.Tag == "Y")
                    {
                        ar.TextString = ((int)_BETA_.Y).ToString();
                    }
                }

                if (_ALFA_ is R.U_Raud)
                {
                    R.U_Raud _BETA_ = _ALFA_ as R.U_Raud;
                    if (ar.Tag == "A")
                    {
                        ar.TextString = _BETA_.A.ToString();
                    }
                    else if (ar.Tag == "B")
                    {
                        ar.TextString = _BETA_.B.ToString();
                    }
                    else if (ar.Tag == "C")
                    {
                        ar.TextString = _BETA_.C.ToString();
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private List <element> matchAreaToArea(List <_Area_v2> areas_dimentions, List <_Area_v2> areas_reinf)
        {
            List <element> elements = new List <element>();

            foreach (_Area_v2 area_dim in areas_dimentions)
            {
                string ritn_nr_dim_a = "x";
                string ritn_nr_dim_b = "x";

                _Db.DBObject currentEntity = _c.trans.GetObject(area_dim.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

                if (currentEntity is _Db.BlockReference)
                {
                    _Db.BlockReference blockRef = currentEntity as _Db.BlockReference;

                    foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                    {
                        _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                        _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                        if (ar != null)
                        {
                            if (ar.Tag == "RITN_23_NR")
                            {
                                ritn_nr_dim_a = ar.TextString;
                            }
                            if (ar.Tag == "RITN_27_NR")
                            {
                                ritn_nr_dim_b = ar.TextString;
                            }
                            if (ar.Tag == "RITN_NR")
                            {
                                ritn_nr_dim_a = ar.TextString;
                            }
                            if (ar.Tag == "RITN_NR")
                            {
                                ritn_nr_dim_b = ar.TextString;
                            }
                        }
                    }
                }

                foreach (_Area_v2 area_reinf in areas_reinf)
                {
                    string ritn_nr_reinf_a = "x";
                    string ritn_nr_reinf_b = "x";

                    _Db.DBObject currentEntity_2 = _c.trans.GetObject(area_reinf.ID, _Db.OpenMode.ForWrite, false) as _Db.DBObject;

                    if (currentEntity_2 is _Db.BlockReference)
                    {
                        _Db.BlockReference blockRef = currentEntity_2 as _Db.BlockReference;

                        foreach (_Db.ObjectId arId in blockRef.AttributeCollection)
                        {
                            _Db.DBObject           obj = _c.trans.GetObject(arId, _Db.OpenMode.ForWrite);
                            _Db.AttributeReference ar  = obj as _Db.AttributeReference;
                            if (ar != null)
                            {
                                if (ar.Tag == "RITN_23_NR")
                                {
                                    ritn_nr_reinf_a = ar.TextString;
                                }
                                if (ar.Tag == "RITN_27_NR")
                                {
                                    ritn_nr_reinf_b = ar.TextString;
                                }
                                if (ar.Tag == "RITN_NR")
                                {
                                    ritn_nr_reinf_a = ar.TextString;
                                }
                                if (ar.Tag == "RITN_NR")
                                {
                                    ritn_nr_reinf_b = ar.TextString;
                                }
                            }
                        }
                    }


                    if (ritn_nr_dim_a == ritn_nr_reinf_a)
                    {
                        if (ritn_nr_reinf_a != "x")
                        {
                            element el = new element(area_dim, area_reinf, ritn_nr_dim_a, ritn_nr_dim_b);
                            elements.Add(el);
                            break;
                        }
                    }
                }
            }

            return(elements);
        }
Ejemplo n.º 22
0
        static public void Plan2AutoIdSelBlockAndAtt()
        {
            try
            {
                if (!OpenAutoIdPalette())
                {
                    return;
                }

                var            opts = Globs.TheAutoIdOptions;
                _AcAp.Document doc  = _AcAp.Application.DocumentManager.MdiActiveDocument;

                using (_AcAp.DocumentLock m_doclock = doc.LockDocument())
                {
                    _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager;
                    if (doc == null)
                    {
                        return;
                    }
                    _AcEd.Editor ed = doc.Editor;
#if NEWSETFOCUS
                    doc.Window.Focus();
#else
                    Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions
#endif

                    _AcEd.PromptNestedEntityResult per = ed.GetNestedEntity("\nRaumblock wählen: ");

                    if (per.Status == _AcEd.PromptStatus.OK)
                    {
                        using (var tr = doc.TransactionManager.StartTransaction())
                        {
                            _AcDb.DBObject       obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead);
                            _AcDb.BlockReference br  = obj as _AcDb.BlockReference;
                            if (br == null)
                            {
                                br = Plan2Ext.Globs.GetBlockFromItsSubentity(tr, per);
                                if (br == null)
                                {
                                    return;
                                }
                            }

                            string blockName = Plan2Ext.Globs.GetBlockname(br, tr);
                            opts.SetBlockname(Engine.RemoveXRefPart(blockName));

                            tr.Commit();
                        }

                        per = ed.GetNestedEntity("\nTürschild-Attribut wählen: ");
                        if (per.Status != _AcEd.PromptStatus.OK)
                        {
                            return;
                        }
                        using (var tr = doc.TransactionManager.StartTransaction())
                        {
                            _AcDb.DBObject           obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead);
                            _AcDb.AttributeReference ar  = obj as _AcDb.AttributeReference;
                            if (ar == null)
                            {
                                return;
                            }

                            opts.SetTuerschildAtt(ar.Tag);

                            tr.Commit();
                        }

                        per = ed.GetNestedEntity("ID-Attribut wählen: ");
                        if (per.Status != _AcEd.PromptStatus.OK)
                        {
                            return;
                        }
                        using (var tr = doc.TransactionManager.StartTransaction())
                        {
                            _AcDb.DBObject           obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead);
                            _AcDb.AttributeReference ar  = obj as _AcDb.AttributeReference;
                            if (ar == null)
                            {
                                return;
                            }

                            opts.SetIdAtt(ar.Tag);

                            tr.Commit();
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in Plan2AutoIdSelBlockAndAtt aufgetreten! {0}", ex.Message));
            }
        }
Ejemplo n.º 23
0
        //[_AcTrx.CommandMethod("SaveView")]
        //public static void SaveView()
        //{
        //    Globs.SaveView("Test");
        //}
        //[_AcTrx.CommandMethod("RestoreView")]
        //public static void RestoreView()
        //{
        //    Globs.RestoreView("Test");
        //}

        //[_AcTrx.CommandMethod("TestMakeLayer")]
        public void TestMakeLayer()
        {
            var doc      = _AcAp.Application.DocumentManager.MdiActiveDocument;
            var db       = doc.Database;
            var layerOid = CreateNewLayer(doc, db);

            using (_AcDb.Transaction trans = doc.TransactionManager.StartTransaction())
            {
                _AcDb.BlockTable blkTable = (_AcDb.BlockTable)trans.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);
                foreach (var id in blkTable)
                {
                    _AcDb.BlockTableRecord btRecord = (_AcDb.BlockTableRecord)trans.GetObject(id, _AcDb.OpenMode.ForRead);
                    //if (!btRecord.IsLayout)
                    //{
                    //Access to the block (not model/paper space)
                    System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Block: {0}", btRecord.Name));
                    //MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nBlock name: {0}", btRecord.Name));

                    btRecord.UpgradeOpen();

                    foreach (var entId in btRecord)
                    {
                        _AcDb.Entity entity = (_AcDb.Entity)trans.GetObject(entId, _AcDb.OpenMode.ForRead);

                        entity.UpgradeOpen();

                        //Access to the entity
                        //MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nHandle: {0}", entity.Handle));
                        //System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Handle: {0}, Layer: {1}", entity.Handle, entity.Layer));
                        entity.Layer = "MyTest";

                        _AcDb.BlockReference block = entity as _AcDb.BlockReference;
                        if (block != null)
                        {
                            foreach (var att in block.AttributeCollection)
                            {
                                _AcDb.ObjectId           attOid = (_AcDb.ObjectId)att;
                                _AcDb.AttributeReference attrib = trans.GetObject(attOid, _AcDb.OpenMode.ForWrite) as _AcDb.AttributeReference;
                                if (attrib != null)
                                {
                                    //attrib.UpgradeOpen();
                                    attrib.Layer = "MyTest";
                                }
                            }
                        }
                    }

                    //}
                }

                // Layouts iterieren
                _AcDb.DBDictionary layoutDict = (_AcDb.DBDictionary)trans.GetObject(db.LayoutDictionaryId, _AcDb.OpenMode.ForRead);
                foreach (var loEntry in layoutDict)
                {
                    if (loEntry.Key.ToUpperInvariant() == "MODEL")
                    {
                        continue;
                    }
                    _AcDb.Layout lo = (_AcDb.Layout)trans.GetObject(loEntry.Value, _AcDb.OpenMode.ForRead, false);
                    if (lo == null)
                    {
                        continue;
                    }
                    System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Layout: {0}", lo.LayoutName));

                    _AcDb.BlockTableRecord btRecord = (_AcDb.BlockTableRecord)trans.GetObject(lo.BlockTableRecordId, _AcDb.OpenMode.ForRead);
                    foreach (var entId in btRecord)
                    {
                        _AcDb.Entity entity = (_AcDb.Entity)trans.GetObject(entId, _AcDb.OpenMode.ForRead);

                        entity.UpgradeOpen();

                        //Access to the entity
                        //MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage(string.Format("\nHandle: {0}", entity.Handle));
                        //System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Handle: {0}, Layer: {1}", entity.Handle, entity.Layer));
                        entity.Layer = "MyTest";

                        _AcDb.BlockReference block = entity as _AcDb.BlockReference;
                        if (block != null)
                        {
                            foreach (var att in block.AttributeCollection)
                            {
                                _AcDb.ObjectId           attOid = (_AcDb.ObjectId)att;
                                _AcDb.AttributeReference attrib = trans.GetObject(attOid, _AcDb.OpenMode.ForWrite) as _AcDb.AttributeReference;
                                if (attrib != null)
                                {
                                    //attrib.UpgradeOpen();
                                    attrib.Layer = "MyTest";
                                }
                            }
                        }
                    }
                }



                trans.Commit();
            }
        }
Ejemplo n.º 24
0
        private void setProgramVariables(_Db.AttributeReference ar)
        {
            if (ar.Tag == "ARMATUURI_MARK")
            {
                L._V_.X_REINFORCEMENT_MARK = ar.TextString;
            }
            else
            {
                double number;
                string txt = ar.TextString;
                txt = txt.Replace('.', ',');
                bool parser = Double.TryParse(txt, out number);

                //A
                if (ar.Tag == "ELEMENDI_LAIUS")
                {
                    if (parser)
                    {
                        L._V_.X_ELEMENT_WIDTH = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] ELEMENDI_LAIUS - Setting invalid");
                    }
                }


                //B
                else if (ar.Tag == "KAITSEKIHT")
                {
                    if (parser)
                    {
                        L._V_.X_CONCRETE_COVER_1 = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] KAITSEKIHT - Setting invalid");
                    }
                }
                else if (ar.Tag == "KIHTIDE_ARV")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_NUMBER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] KIHTIDE_ARV - Setting invalid");
                    }
                }


                //C
                else if (ar.Tag == "PÕHIARMATUURI_DIAM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_MAIN_DIAMETER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] PÕHIARMATUURI_DIAM - Setting invalid");
                    }
                }
                else if (ar.Tag == "PÕHIARMATUURI_ANKURDUS")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_MAIN_ANCHOR_LENGTH = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] PÕHIARMATUURI_ANKURDUS - Setting invalid");
                    }
                }
                else if (ar.Tag == "PÕHIARMATUURI_ABISUURUS")
                {
                    if (parser)
                    {
                        L._V_.X_FIRST_PASS_CONSTRAINT = number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] PÕHIARMATUURI_ABISUURUS - Setting invalid");
                    }
                }


                //D
                else if (ar.Tag == "DIAGONAALI_DIAM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_DIAGONAL_DIAMETER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] DIAGONAALI_DIAM - Setting invalid");
                    }
                }
                else if (ar.Tag == "DIAGONAALI_ANKURDUS")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_DIAGONAL_ANCHOR_LENGTH = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] DIAGONAALI_ANKURDUS - Setting invalid");
                    }
                }


                //E
                else if (ar.Tag == "RANGIDE_DIAM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_STIRRUP_DIAMETER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] RANGIDE_DIAM - Setting invalid");
                    }
                }
                else if (ar.Tag == "RANGIDE_SAMM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_STIRRUP_SPACING = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] RANGIDE_SAMM - Setting invalid");
                    }
                }
                else if (ar.Tag == "RANGIDE_ABISUURUS")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_STIRRUP_CONSTRAINT = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] RANGIDE_ABISUURUS - Setting invalid");
                    }
                }


                //F
                else if (ar.Tag == "HORISONTAAL_D_IO")
                {
                    if (parser)
                    {
                        if ((int)number == 0 || (int)number == 1)
                        {
                            L._V_.X_REINFORCEMENT_SIDE_D_CREATE = (int)number;
                        }
                        else
                        {
                            throw new DMTException("[ERROR] HORISONTAAL_D_IO - Setting invalid");
                        }
                    }
                    else
                    {
                        throw new DMTException("[ERROR] HORISONTAAL_D_IO - Setting invalid");
                    }
                }
                else if (ar.Tag == "HORISONTAAL_D_DIAM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_SIDE_D_DIAMETER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] HORISONTAAL_D_DIAM - Setting invalid");
                    }
                }
                else if (ar.Tag == "HORISONTAAL_D_ANKURDUS")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_SIDE_D_ANCHOR_LENGTH = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] HORISONTAAL_D_ANKURDUS - Setting invalid");
                    }
                }
                else if (ar.Tag == "HORISONTAAL_D_SAMM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_SIDE_D_SPACING = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] HORISONTAAL_D_SAMM - Setting invalid");
                    }
                }
                else if (ar.Tag == "HORISONTAAL_D_PARAND")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_SIDE_D_FIX = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] HORISONTAAL_D_PARAND - Setting invalid");
                    }
                }


                //E
                else if (ar.Tag == "VERTIKAAL_D_IO")
                {
                    if (parser)
                    {
                        if ((int)number == 0 || (int)number == 1)
                        {
                            L._V_.X_REINFORCEMENT_TOP_D_CREATE = (int)number;
                        }
                        else
                        {
                            throw new DMTException("[ERROR] VERTIKAAL_D_IO - Setting invalid");
                        }
                    }
                    else
                    {
                        throw new DMTException("[ERROR] VERTIKAAL_D_IO - Setting invalid");
                    }
                }
                else if (ar.Tag == "VERTIKAAL_D_DIAM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_TOP_D_DIAMETER = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] VERTIKAAL_D_DIAM - Setting invalid");
                    }
                }
                else if (ar.Tag == "VERTIKAAL_D_ANKURDUS")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_TOP_D_ANCHOR_LENGTH = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] VERTIKAAL_D_ANKURDUS - Setting invalid");
                    }
                }
                else if (ar.Tag == "VERTIKAAL_D_SAMM")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_TOP_D_SPACING = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] VERTIKAAL_D_SAMM - Setting invalid");
                    }
                }
                else if (ar.Tag == "VERTIKAAL_D_PARAND")
                {
                    if (parser)
                    {
                        L._V_.X_REINFORCEMENT_TOP_D_FIX = (int)number;
                    }
                    else
                    {
                        throw new DMTException("[ERROR] VERTIKAAL_D_PARAND - Setting invalid");
                    }
                }
            }
        }
Ejemplo n.º 25
0
        private bool Import(List <Excelizer.ImportedRow> importedRows)
        {
            bool errorOccured = false;

            var doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;

            using (_AcDb.Transaction trans = doc.TransactionManager.StartTransaction())
            {
                var perBlockName = importedRows.GroupBy(x => x.BlockName);
                foreach (var pbn in perBlockName)
                {
                    int nrOfChangedBlocks = 0;

                    string blockName = pbn.Key;
                    if (blockName == null || string.IsNullOrEmpty(blockName.Trim()))
                    {
                        log.WarnFormat("Es gibt Zeilen ohne Blocknamen!");
                        continue;
                    }

                    var attNames = Plan2Ext.Globs.GetBlockAttributeNames(blockName);
                    log.InfoFormat("Import für Block '{0}' mit {1} Attribut(en): ", blockName, attNames.Count.ToString());
                    int cnt = 0;
                    foreach (var record in pbn)
                    {
                        try
                        {
                            int changedAttributes = 0;

                            long ln = Convert.ToInt64(record.Handle, 16);
                            // Not create a Handle from the long integer
                            _AcDb.Handle hn = new _AcDb.Handle(ln);
                            // And attempt to get an _AcDb.ObjectId for the Handle
                            _AcDb.ObjectId id = db.GetObjectId(false, hn, 0);

                            _AcDb.BlockReference br = (_AcDb.BlockReference)trans.GetObject(id, _AcDb.OpenMode.ForWrite);

                            cnt++;

                            foreach (var attName in attNames)
                            {
                                _AcDb.AttributeReference attRef = null;
                                attRef = GetBlockAttribute(attName, br, trans);
                                if (attRef != null)
                                {
                                    attRef.UpgradeOpen();
                                    string attVal = record.GetAttribute(attName);
                                    if (attVal != null)
                                    {
                                        if (string.Compare(attRef.TextString, attVal) != 0)
                                        {
                                            if (_CreateChangeLines)
                                            {
                                                Plan2Ext.Globs.InsertFehlerLines(new List <_AcGe.Point3d> {
                                                    attRef.Position
                                                },
                                                                                 "Plan2BlockAttribChanged",
                                                                                 50.0,
                                                                                 Math.PI * 1.25,
                                                                                 _AcCm.Color.FromRgb((byte)255, (byte)0, (byte)0));
                                            }

                                            changedAttributes++;
                                        }
                                        attRef.TextString = attVal;
                                    }
                                }
                            }
                            if (changedAttributes > 0)
                            {
                                log.DebugFormat("Block mit Referenz '{0}': Anzahl geänderter Attribute: {1}", record.Handle, changedAttributes.ToString());
                                nrOfChangedBlocks++;
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Warn(string.Format("Fehler beim Import von Block mit Handle '{0}'! {1}", record.Handle, ex.Message));
                            errorOccured = true;
                        }
                    }

                    log.InfoFormat("Anzahl geänderter Blöcke namens '{0}': {1}/{2}", blockName, nrOfChangedBlocks, cnt);
                }
                trans.Commit();
            }
            return(!errorOccured);
        }
Ejemplo n.º 26
0
 private void setRowParameters(_Db.AttributeReference ar, T.TableBendingRow rowData)
 {
     if (ar != null)
     {
         if (ar.Tag == "Pos")
         {
             ar.TextString = rowData.Position.ToString();
         }
         else if (ar.Tag == "Klass")
         {
             ar.TextString = rowData.Material.ToString();
         }
         else if (ar.Tag == "Diam")
         {
             ar.TextString = rowData.Diameter.ToString();
         }
         else if (ar.Tag == "tk")
         {
             ar.TextString = rowData.Count.ToString();
         }
         else if (ar.Tag == "Pikkus")
         {
             ar.TextString = rowData.Length.ToString();
         }
         else if (ar.Tag == "a")
         {
             if (rowData.A != -1)
             {
                 ar.TextString = rowData.A.ToString();
             }
         }
         else if (ar.Tag == "b")
         {
             if (rowData.B != -1)
             {
                 ar.TextString = rowData.B.ToString();
             }
         }
         else if (ar.Tag == "c")
         {
             if (rowData.C != -1)
             {
                 ar.TextString = rowData.C.ToString();
             }
         }
         else if (ar.Tag == "d")
         {
             if (rowData.D != -1)
             {
                 ar.TextString = rowData.D.ToString();
             }
         }
         else if (ar.Tag == "e")
         {
             if (rowData.E != -1)
             {
                 ar.TextString = rowData.E.ToString();
             }
         }
         else if (ar.Tag == "f")
         {
             if (rowData.F != -1)
             {
                 ar.TextString = rowData.F.ToString();
             }
         }
         else if (ar.Tag == "g")
         {
             if (rowData.G != -1)
             {
                 ar.TextString = rowData.G.ToString();
             }
         }
         else if (ar.Tag == "u")
         {
             if (rowData.U != "")
             {
                 ar.TextString = rowData.U;
             }
         }
         else if (ar.Tag == "v")
         {
             if (rowData.V != "")
             {
                 ar.TextString = rowData.V;
             }
         }
         else if (ar.Tag == "R")
         {
             if (rowData.R != -1)
             {
                 ar.TextString = rowData.R.ToString();
             }
         }
         else if (ar.Tag == "x")
         {
             if (rowData.X != -1)
             {
                 ar.TextString = rowData.X.ToString();
             }
         }
         else if (ar.Tag == "y")
         {
             if (rowData.Y != -1)
             {
                 ar.TextString = rowData.Y.ToString();
             }
         }
     }
 }
Ejemplo n.º 27
0
        private void ReplaceLayerInEntities(Dictionary <string, string> substDict, _AcDb.Transaction trans, _AcDb.Database db)
        {
            //string oldLayer = linfo.OldLayer;
            //string newLayer = linfo.NewLayer;

            _AcDb.BlockTable blkTable = (_AcDb.BlockTable)trans.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead);
            foreach (var id in blkTable)
            {
                _AcDb.BlockTableRecord btRecord = (_AcDb.BlockTableRecord)trans.GetObject(id, _AcDb.OpenMode.ForRead);
                //System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Block: {0}", btRecord.Name));

                //btRecord.UpgradeOpen();

                foreach (var entId in btRecord)
                {
                    _AcDb.Entity entity = (_AcDb.Entity)trans.GetObject(entId, _AcDb.OpenMode.ForWrite);

                    CheckSetLayer(substDict, entity);
                    //if (string.Compare(entity.Layer, oldLayer, StringComparison.OrdinalIgnoreCase) == 0)
                    //{
                    //    entity.Layer = newLayer;
                    //}

                    _AcDb.BlockReference block = entity as _AcDb.BlockReference;
                    if (block != null)
                    {
                        // sequend correction
                        string saveLay = block.Layer;
                        block.Layer = "0";
                        block.Layer = saveLay;

                        foreach (var att in block.AttributeCollection)
                        {
                            _AcDb.ObjectId           attOid = (_AcDb.ObjectId)att;
                            _AcDb.AttributeReference attrib = trans.GetObject(attOid, _AcDb.OpenMode.ForWrite) as _AcDb.AttributeReference;
                            if (attrib != null)
                            {
                                CheckSetLayer(substDict, attrib);
                                //if (string.Compare(attrib.Layer, oldLayer, StringComparison.OrdinalIgnoreCase) == 0)
                                //{
                                //    attrib.Layer = newLayer;
                                //}
                            }
                        }
                    }
                }

                //}
            }

            // Layouts iterieren
            _AcDb.DBDictionary layoutDict = (_AcDb.DBDictionary)trans.GetObject(db.LayoutDictionaryId, _AcDb.OpenMode.ForRead);
            foreach (var loEntry in layoutDict)
            {
                if (loEntry.Key.ToUpperInvariant() == "MODEL")
                {
                    continue;
                }
                _AcDb.Layout lo = (_AcDb.Layout)trans.GetObject(loEntry.Value, _AcDb.OpenMode.ForRead, false);
                if (lo == null)
                {
                    continue;
                }
                //System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Layout: {0}", lo.LayoutName));

                _AcDb.BlockTableRecord btRecord = (_AcDb.BlockTableRecord)trans.GetObject(lo.BlockTableRecordId, _AcDb.OpenMode.ForRead);
                foreach (var entId in btRecord)
                {
                    _AcDb.Entity entity = (_AcDb.Entity)trans.GetObject(entId, _AcDb.OpenMode.ForWrite);

                    CheckSetLayer(substDict, entity);

                    //if (string.Compare(entity.Layer, oldLayer, StringComparison.OrdinalIgnoreCase) == 0)
                    //{
                    //    entity.Layer = newLayer;
                    //}

                    _AcDb.BlockReference block = entity as _AcDb.BlockReference;
                    if (block != null)
                    {
                        string saveLay = block.Layer;
                        block.Layer = "0";
                        block.Layer = saveLay;

                        foreach (var att in block.AttributeCollection)
                        {
                            _AcDb.ObjectId           attOid = (_AcDb.ObjectId)att;
                            _AcDb.AttributeReference attrib = trans.GetObject(attOid, _AcDb.OpenMode.ForWrite) as _AcDb.AttributeReference;
                            if (attrib != null)
                            {
                                CheckSetLayer(substDict, attrib);
                                //if (string.Compare(attrib.Layer, oldLayer, StringComparison.OrdinalIgnoreCase) == 0)
                                //{

                                //    //attrib.UpgradeOpen();
                                //    attrib.Layer = newLayer;
                                //}
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 28
0
        private void setBendingParameters(_Db.AttributeReference ar, T.BendingShape bending)
        {
            if (ar != null)
            {
                if (ar.Tag == "Positsioon")
                {
                    bending.Position = ar.TextString;
                }
                else if (ar.Tag == "Teraseklass")
                {
                    bending.Material = ar.TextString;
                }
                else if (ar.Tag == "U")
                {
                    bending.U = ar.TextString;
                }
                else if (ar.Tag == "V")
                {
                    bending.V = ar.TextString;
                }
                else
                {
                    int temp = 99999;
                    Int32.TryParse(ar.TextString, out temp);

                    if (ar.Tag == "A")
                    {
                        bending.A = temp;
                    }
                    else if (ar.Tag == "B")
                    {
                        bending.B = temp;
                    }
                    else if (ar.Tag == "C")
                    {
                        bending.C = temp;
                    }
                    else if (ar.Tag == "D")
                    {
                        bending.D = temp;
                    }
                    else if (ar.Tag == "E")
                    {
                        bending.E = temp;
                    }
                    else if (ar.Tag == "F")
                    {
                        bending.F = temp;
                    }
                    else if (ar.Tag == "G")
                    {
                        bending.G = temp;
                    }
                    else if (ar.Tag == "R")
                    {
                        bending.R = temp;
                    }
                    else if (ar.Tag == "X")
                    {
                        bending.X = temp;
                    }
                    else if (ar.Tag == "Y")
                    {
                        bending.Y = temp;
                    }
                }
            }
        }