Exemple #1
0
        public void OpenDialogeBox()
        {
            var xmlReader = new ReadXml();

            if (xmlReader.checkXmlPath())
            {
                var drawingList = new List <string>();

                using (var _form = new PurgeAttributeForm())
                {
                    _form.SetTabIndex(1);

                    var result = _form.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        drawingList = _form.AttributeDrawingList;
                    }
                    if (result == System.Windows.Forms.DialogResult.None)
                    {
                        return;
                    }

                    ReplaceStringValue(drawingList, _form.AttBlockname, _form.LinkattAttributeName, _form.LinkAttValue, _form.ChangeattAttributeName, _form.ChangeAttValue);
                }
            }
        }
Exemple #2
0
        public void purgeMultipleFiles()
        {
            var drawingList = new List <string>();

            using (var _form = new PurgeAttributeForm())
            {
                _form.SetTabIndex(0);

                var result = _form.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    drawingList = _form.PurgeDrawingList;
                }
                if (result == System.Windows.Forms.DialogResult.None)
                {
                    return;
                }
            }

            foreach (var drawing in drawingList)
            {
                purgeDrawing(drawing);
                ;
            }
        }
Exemple #3
0
        public void GetBlockData(PurgeAttributeForm form)
        {
            form.Close();
            form.Dispose();

            Document acDoc     = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb   = acDoc.Database;
            var      blockData = new BlockData()
            {
                AttNameAndvalue = new List <AttName_Value>()
            };

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Request for objects to be selected in the drawing area

                var opt = new PromptSelectionOptions()
                {
                    SingleOnly = true
                };
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection(opt);

                // If the prompt status is OK, objects were selected
                if (acSSPrompt.Status == PromptStatus.OK)
                {
                    SelectionSet acSSet = acSSPrompt.Value;

                    // Step through the objects in the selection set
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        Entity ent = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Entity;
                        if (ent is BlockReference br)
                        {
                            blockData.BlockName = br.Name;

                            foreach (ObjectId attribute in br.AttributeCollection)
                            {
                                DBObject obj = acTrans.GetObject(attribute, OpenMode.ForRead);
                                if (obj is AttributeReference ar)
                                {
                                    blockData.AttNameAndvalue.Add(new AttName_Value {
                                        attName = ar.Tag, attValue = ar.TextString
                                    });
                                }
                            }
                        }

                        // Save the new object to the database
                        acTrans.Dispose();
                    }

                    // Dispose of the transaction
                }
            }

            using (var _form = new PurgeAttributeForm())
            {
                var drawingList = new List <string>();

                _form.SetTabIndex(1);
                _form.BlockData = blockData;
                _form.SetValueFromInput();

                var result = _form.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    drawingList = _form.AttributeDrawingList;
                }
                if (result == System.Windows.Forms.DialogResult.None)
                {
                    return;
                }

                ReplaceStringValue(drawingList, _form.AttBlockname, _form.LinkattAttributeName, _form.LinkAttValue, _form.ChangeattAttributeName, _form.ChangeAttValue);
            }
        }