Example #1
0
        public void UpdateAcadBlockAttributes(string blockName, IndustryName prtNo)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            ObjectId msObjectId, psObjectId;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                msObjectId = bt[BlockTableRecord.ModelSpace];
                psObjectId = bt[BlockTableRecord.PaperSpace];

                tr.Commit();
            }

            //Convert PartNumber object to dictionary
            Dictionary <string, string> attributeTagValue = new Dictionary <string, string>();

            attributeTagValue.Add("IdDesigner", prtNo.DesignedBy);
            attributeTagValue.Add("IdDeveloper", prtNo.DevelopedBy);
            attributeTagValue.Add("IdVerifier", prtNo.VerifiedBy);
            attributeTagValue.Add("IdIndustry", prtNo.GetIndustryName);

            UpdateAttributesInBlock(msObjectId, blockName, attributeTagValue);
            UpdateAttributesInBlock(psObjectId, blockName, attributeTagValue);
        }
Example #2
0
        public void FillTablesWithIndustryNames()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;

            //Prompts for each industry
            PromptStringOptions prOpNum = new PromptStringOptions("Choose industry type Electrical/Sanitary/Road<Electrical>: ")
            {
                AllowSpaces     = true,
                DefaultValue    = IndustryEnum.ELECTRICAL.ToString(),
                UseDefaultValue = true
            };

            //Add keywords when prompting for position
            prOpNum.Keywords.Add(IndustryEnum.ELECTRICAL.ToString());
            prOpNum.Keywords.Add(IndustryEnum.SANITARY.ToString());
            prOpNum.Keywords.Add(IndustryEnum.ROAD.ToString());


            PromptResult industryType = doc.Editor.GetString(prOpNum);

            ///manualy initialize local member
            IndustryName indType = null;

            var selectedIndustry = industryType.StringResult.ToUpper();

            try
            {
                if (selectedIndustry == IndustryEnum.ELECTRICAL.ToString())
                {
                    indType = new Electrical().IndustryCreate();
                }

                if (selectedIndustry == IndustryEnum.SANITARY.ToString())
                {
                    indType = new Sanitary().IndustryCreate();
                }

                if (selectedIndustry == IndustryEnum.ROAD.ToString())
                {
                    indType = new Road().IndustryCreate();
                }

                //edit block atributes
                //updtade block with hardcoded id value
                BlockAttributes.Use(blkAtt => { blkAtt.UpdateAcadBlockAttributes("A$C70146EFE", indType); });
            }
            catch (Exception)
            {
                ed.WriteMessage("exception error or user canceled");
            }
        }