예제 #1
0
 /// <summary>
 /// Returns the active project
 /// </summary>
 /// <returns>Active Project</returns>
 public static Project GetCurrentProject()
 {
    SelectionSet selectionSet = new SelectionSet();
    selectionSet.LockProjectByDefault = true;
    selectionSet.LockSelectionByDefault = true;
    return selectionSet.GetCurrentProject(true);
 }
예제 #2
0
 public void Init()
 {
     for (int i = 0;i < 12;++i) {
         if (sceneCameras[i] == null) sceneCameras[i] = new SceneCameraTransform();
         if (selectionSet[i] == null) selectionSet[i] = new SelectionSet();
     }
 }
 public ChangeAttributeValuesToUpper(SelectionSet ss)
 {
     if (ss != null)
     {
         selectionSetIds = BlockUtility.GetAllIDsFromSS(ss);
     }
 }
        /// <summary>
        /// Execution of the Action.  
        /// </summary>
        /// <returns>True:  Execution of the Action was successful</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            SelectionSet sel = new SelectionSet();

            List<Line> lines = sel.Selection.OfType<Line>().ToList();

            foreach (Line l in lines)
            {
                l.EndArrow = !l.EndArrow;
            }

            return true;
        }
        public ChangeAttributeValuesToUpper()
        {
            // gets only block inserts
            SelectionFilter sf = GetSelectionFilter();

            // now we want a selection set out of this
            ss = BlockUtility.GetSS(sf);

            if (ss != null)
            {
                selectionSetIds = BlockUtility.GetAllIDsFromSS(ss);
            }
        }
        /// <summary>
        /// Execution of the Action.  
        /// </summary>
        /// <returns>True:  Execution of the Action was successful</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            using (UndoStep undo = new UndoManager().CreateUndoStep())
            {
                SelectionSet sel = new SelectionSet();

                //Make sure that terminals are ordered by designation
                var terminals = sel.Selection.OfType<Terminal>().OrderBy(t => t.Properties.FUNC_PINORTERMINALNUMBER.ToInt());
                if (terminals.Count() < 2)
                    throw new Exception("Must select at least 2 Terminals");

                //Create a list of terminals for each level. Those lists get added to a dictionnary
                //with the level as the key.
                Dictionary<int, List<Terminal>> levels = new Dictionary<int, List<Terminal>>();

                //Fill the dictionnary
                foreach (Terminal t in terminals)
                {
                    int level = t.Properties.FUNC_TERMINALLEVEL;

                    if (!levels.ContainsKey(level))
                        levels.Add(level, new List<Terminal>());

                    levels[level].Add(t);
                }

                var keys = levels.Keys.OrderBy(k => k);

                //Make sure that all levels have the same number of terminals
                int qty = levels.First().Value.Count;
                if (!levels.All(l => l.Value.Count == qty))
                    throw new Exception("There must be the same number of Terminals on each level");

                //Assign sort code by taking a terminal from each level in sequence
                int sortCode = 1;
                for (int i = 0; i < qty; i++)
                {
                    foreach (int j in keys)
                    {
                        levels[j][i].Properties.FUNC_TERMINALSORTCODE = sortCode++;
                    }
                }

            }

            return true;
        }
        /// <summary>
        /// That is the function that is called to the event processing.  
        /// </summary>
        /// <param name="iEventParameter">Event parameter</param>
        private void PlaceHolderAssign_EplanEvent(IEventParameter iEventParameter)
        {
            //Check the selection, and if we have one or more placeholders selected,
            //iterate over their "assigned objects", and when we find cables,
            //call "Reassign All" on them.

            SelectionSet sel = new SelectionSet();

            var PHs = sel.Selection.OfType<PlaceHolder>();
            if (PHs.Count() == 0)
                return;

            CableService CblService = new CableService();

            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                foreach (PlaceHolder ph in PHs)
                {

                    var cables = ph.AssignedObjects.OfType<Cable>().Where(c => c.IsMainFunction);

                    foreach (Cable cbl in cables)
                    {
                        CblService.DoReassignWires(cbl, true, null);
                    }
                }
            }
            catch (Exception)
            {
                //Do nothing
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
예제 #8
0
        public static void activatePoly3ds(string nameLayer = "", Object idPoly3d = null)
        {
            using (BaseObjs._acadDoc.LockDocument()) {
                using (Transaction TR = BaseObjs.startTransactionDb()) {
                    if (idPoly3d == null)
                    {
                        Type         type = typeof(Polyline3d);
                        TypedValue[] TVs  = new TypedValue[2];
                        TVs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(type).DxfName), 0);
                        TVs.SetValue(new TypedValue((int)DxfCode.LayerName, nameLayer), 1);
                        SelectionSet ss = Select.buildSSet(TVs);

                        if (ss != null)
                        {
                            foreach (ObjectId id in ss.GetObjectIds())
                            {
                                Entity ent = (Entity)TR.GetObject(id, OpenMode.ForWrite);
                                if (ent.GetType() == typeof(Polyline3d))
                                {
                                    poly3d           = (Polyline3d)ent;
                                    poly3d.Modified += new EventHandler(poly3d_Modified);
                                    poly3d.Erased   += new ObjectErasedEventHandler(poly3d_Erased);
                                    poly3ds.Add(poly3d.ObjectId); poly3ds.TrimExcess();
                                }
                            }
                        }
                    }
                    else
                    {
                        poly3d           = (Polyline3d)TR.GetObject((ObjectId)idPoly3d, OpenMode.ForWrite);
                        poly3d.Modified += new EventHandler(poly3d_Modified);
                        poly3d.Erased   += new ObjectErasedEventHandler(poly3d_Erased);
                        poly3ds.Add((ObjectId)idPoly3d); poly3ds.TrimExcess();
                    }
                    TR.Commit();
                }
            }
        }
예제 #9
0
        public void TableCopy()
        {
            Document doc    = Application.DocumentManager.MdiActiveDocument;
            Database db     = doc.Database;
            Editor   editor = doc.Editor;

            try
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    // 获取PickFirst选择集
                    PromptSelectionResult psr = editor.SelectImplied();

                    // 如果提示状态OK,说明启动命令前选择了对象;
                    if (psr.Status != PromptStatus.OK)
                    {
                        editor.WriteMessage("没有选中对象\n");
                        return;
                    }
                    SelectionSet sset  = psr.Value;
                    Table        table = AcTableParser.ParseTable(sset.GetObjectIds());

                    if (table == null || table.RowCount == 0)
                    {
                        editor.WriteMessage("\n无法识别表格");
                    }

                    //ShowConsoleTable(editor, table);
                    SaveToExcel(table);

                    trans.Commit();
                }
            }
            catch (System.Exception e)
            {
                editor.WriteMessage(e.ToString());
            }
        }
예제 #10
0
파일: EW_Utility2.cs 프로젝트: 15831944/EM
        getLimits(int intInterval)
        {
            SelectionSet objSSet = EW_Utility1.buildSSetGradingLim();

            if (objSSet.Count == 0)
            {
                Application.ShowAlertDialog("Grading Limit not found - should be on layer GRADING LIMIT - exiting....");
                return(null);
            }
            else if (objSSet.Count > 1)
            {
                Application.ShowAlertDialog("More than one Project Boundary found - exiting....");
                return(null);
            }

            ObjectId[] ids = objSSet.GetObjectIds();

            Polyline objPlineBndry = (Polyline)ids[0].getEnt();

            Extents3d ext3d    = (Extents3d)objPlineBndry.Bounds;
            Point3d   pnt3dMin = new Point3d(ext3d.MinPoint.X - 100, ext3d.MinPoint.Y - 100, 0.0);
            Point3d   pnt3dMax = new Point3d(ext3d.MaxPoint.X + 100, ext3d.MaxPoint.Y + 100, 0.0);

            double dblDeltaX = pnt3dMax.X - pnt3dMin.X;
            double dblDeltaY = pnt3dMax.Y - pnt3dMin.Y;


            int iMax = (int)System.Math.Truncate(dblDeltaX / intInterval);
            int jMax = (int)System.Math.Truncate(dblDeltaY / intInterval);

            object[] varLimits = new object[4];
            varLimits[0] = pnt3dMin.X;
            varLimits[1] = pnt3dMin.Y;
            varLimits[2] = iMax;
            varLimits[3] = jMax;

            return(varLimits);
        }
예제 #11
0
        /// <summary> 点击界面中的点以生成对应的标高 </summary>
        private ExternalCmdResult PlaceElevation(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;
            // 以只读方式打开块表   Open the Block table for read
            var acBlkTbl =
                docMdf.acTransaction.GetObject(docMdf.acDataBase.BlockTableId, OpenMode.ForRead) as BlockTable;

            // 以写方式打开模型空间块表记录   Open the Block table record Model space for write
            var acBlkTblRec =
                docMdf.acTransaction.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as
                BlockTableRecord;

            var pt     = GetElevationPoint(docMdf);
            var ucsOri = docMdf.acEditor.CurrentUserCoordinateSystem.Translation;

            while (pt != null)
            {
                var ele = pt.Value.Y;
                var txt = new DBText
                {
                    TextString  = ele.ToString("###.000"),
                    Position    = pt.Value.Add(ucsOri),
                    Height      = 1,
                    WidthFactor = 0.7
                };
                // txt.SetDatabaseDefaults();

                // 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
                acBlkTblRec.AppendEntity(txt);
                docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true);

                txt.Draw();

                pt = GetElevationPoint(docMdf);
            }

            return(ExternalCmdResult.Commit);
        }
        //public static void SubDMeshTest()
        //{
        //    Document activeDoc = Application.DocumentManager.MdiActiveDocument;
        //    Database db = activeDoc.Database;
        //    Editor ed = activeDoc.Editor;

        //    TypedValue[] values = { new TypedValue((int)DxfCode.Start, "MESH") };

        //    SelectionFilter filter = new SelectionFilter(values);
        //    PromptSelectionResult psr = ed.SelectAll(filter);
        //    SelectionSet ss = psr.Value;
        //    if (ss == null)
        //        return;

        //    using (Transaction trans = db.TransactionManager.StartTransaction())
        //    {
        //        for (int i = 0; i < ss.Count; ++i)
        //        {
        //            SubDMesh mesh = trans.GetObject(ss[i].ObjectId, OpenMode.ForRead) as SubDMesh;

        //            ed.WriteMessage(String.Format("\n Vertices : {0}", mesh.NumberOfVertices));
        //            ed.WriteMessage(String.Format("\n Edges    : {0}", mesh.NumberOfEdges));
        //            ed.WriteMessage(String.Format("\n Faces    : {0}", mesh.NumberOfFaces));

        //            // Get the Face information
        //            int[] faceArr = mesh.FaceArray.ToArray();
        //            int edges = 0;
        //            int fcount = 0;

        //            for (int x = 0; x < faceArr.Length; x = x + edges + 1)
        //            {
        //                ed.WriteMessage(String.Format("\n Face {0} : ", fcount++));

        //                edges = faceArr[x];
        //                for (int y = x + 1; y <= x + edges; y++)
        //                {
        //                    ed.WriteMessage(String.Format("\n\t Edge - {0}", faceArr[y]));
        //                }
        //            }

        //            // Get the Edge information
        //            int ecount = 0;
        //            int[] edgeArr = mesh.EdgeArray.ToArray();

        //            for (int x = 0; x < edgeArr.Length; x = x + 2)
        //            {
        //                ed.WriteMessage(String.Format("\n Edge {0} : ", ecount++));
        //                ed.WriteMessage(String.Format("\n Vertex - {0}", edgeArr[x]));
        //                ed.WriteMessage(String.Format("\n Vertex - {0}", edgeArr[x + 1]));
        //            }

        //            // Get the vertices information
        //            int vcount = 0;
        //            foreach (Point3d vertex in mesh.Vertices)
        //            {
        //                ed.WriteMessage(String.Format("\n Vertex {0} - {1} {2}", vcount++, vertex.X, vertex.Y));
        //            }
        //        }
        //        trans.Commit();
        //    }
        //}

        public static Point3dCollection GetSubDMeshVertices()
        {
            Document activeDoc = Application.DocumentManager.MdiActiveDocument;
            Database db        = activeDoc.Database;
            Editor   ed        = activeDoc.Editor;

            TypedValue[] values = { new TypedValue((int)DxfCode.Start, "MESH") };

            SelectionFilter       filter = new SelectionFilter(values);
            PromptSelectionResult psr    = ed.SelectAll(filter);
            SelectionSet          ss     = psr.Value;

            if (ss == null)
            {
                return(null);
            }

            Point3dCollection collPoints = new Point3dCollection();

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < ss.Count; ++i)
                {
                    SubDMesh mesh = trans.GetObject(ss[i].ObjectId, OpenMode.ForRead) as SubDMesh;


                    // Get the vertices information
                    int vcount = 0;
                    foreach (Point3d vertex in mesh.Vertices)
                    {
                        //ed.WriteMessage(String.Format("\n Vertex {0} - {1} {2}", vcount++, vertex.X, vertex.Y));
                        collPoints.Add(new Point3d(vertex.X, vertex.Y, vertex.Z));
                    }
                }
                trans.Commit();
            }
            return(collPoints);
        }
예제 #13
0
        /// <summary> 将多个单行文字按其定位进行组合 </summary>
        public ExternalCmdResult LoadMenuItems(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            string assPath = @"D:\ProgrammingCases\GitHubProjects\CADDev\bin\eZcad - 副本.dll";

            string[] assPaths = eZcad.Utility.Utils.ChooseOpenFile("选择要加载菜单的程序集", "程序集(*.dll; *.exe)| *.dll; *.exe",
                                                                   multiselect: false);
            if (assPaths == null)
            {
                return(ExternalCmdResult.Cancel);
            }
            assPath = assPaths[0];

            Assembly ass = null;

            Type[] types;
            try
            {
                ass   = Assembly.LoadFrom(assPath);
                types = ass.GetTypes();
            }
            catch (ReflectionTypeLoadException ex)
            {
                types = ex.Types;
            }
            //
            if (ass != null && types != null)
            {
                var atts = ass.GetCustomAttributes(typeof(CommandClassAttribute));
                var mtds = GetExternalCommands(atts as CommandClassAttribute[]);
                if (mtds != null && mtds.Count > 0)
                {
                    var app      = Application.AcadApplication as AcadApplication;
                    var menuName = GetMenuName(docMdf.acEditor);
                    AddMenus(app, menuName + "", mtds);
                }
            }
            return(ExternalCmdResult.Commit);
        }
예제 #14
0
        private static Dictionary <string, Fields> CollectFields(
            SelectionSet selectionSet,
            Dictionary <string, Fields> fields = null,
            List <string> visitedFragmentNames = null)
        {
            if (fields == null)
            {
                fields = new Dictionary <string, Fields>();
            }

            selectionSet.Selections.Apply(selection =>
            {
                if (selection is Field field)
                {
                    if (!ShouldIncludeNode(field.Directives))
                    {
                        return;
                    }

                    var name = field.Alias ?? field.Name;
                    if (!fields.ContainsKey(name))
                    {
                        fields[name] = Fields.Empty();
                    }
                    fields[name].Add(field);
                }
                else if (selection is FragmentSpread)
                {
                    // TODO
                }
                else if (selection is InlineFragment)
                {
                    // TODO
                }
            });

            return(fields);
        }
예제 #15
0
파일: Events.cs 프로젝트: 15831944/EM
        }// mTxt_Modified

        #endregion "mTxt"

        #region "ldr"

        /// <summary>
        ///
        /// </summary>
        /// <param name="nameLayer"></param>
        /// <param name="ldr"></param>
        public static void activateLdr(string nameLayer, Leader ldr = null)
        {
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    if (ldr == null)
                    {
                        TypedValue[] TVs = new TypedValue[2];
                        TVs.SetValue(new TypedValue((int)DxfCode.Start, "LEADER"), 0);
                        TVs.SetValue(new TypedValue((int)DxfCode.LayerName, nameLayer), 1);
                        SelectionSet SS = Base_Tools45.Select.buildSSet(TVs);
                        foreach (SelectedObject ssObj in SS)
                        {
                            if (ssObj != null)
                            {
                                ldr           = (Leader)tr.GetObject(ssObj.ObjectId, OpenMode.ForWrite);
                                ldr.Modified += new EventHandler(Ldr_Modified);
                                ldrs.Add(ldr.ObjectId);
                                ldrs.TrimExcess();
                            }
                        }
                    }
                    else
                    {
                        ldr           = (Leader)ldr.ObjectId.GetObject(OpenMode.ForWrite);
                        ldr.Modified += new EventHandler(Ldr_Modified);
                        ldrs.Add(ldr.ObjectId);
                        ldrs.TrimExcess();
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Events.cs: line: 507");
            }
        }// activateLdr
예제 #16
0
파일: CAD.cs 프로젝트: yxx5006/CADAddin
        private static List <object> GetLayerObjectsByLayerName(List <string> ImgLayers)
        {
            List <object> objects = new List <object>();
            Editor        ed      = Application.DocumentManager.MdiActiveDocument.Editor;
            Document      acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database      acCurDb = acDoc.Database;

            if (ImgLayers.Count != 0)
            {
                using (OpenCloseTransaction trans = acCurDb.TransactionManager.StartOpenCloseTransaction())
                {
                    foreach (string layerName in ImgLayers)
                    {
                        try
                        {
                            TypedValue[] typedValue = new TypedValue[]
                            {
                                new TypedValue((int)DxfCode.LayerName, layerName)
                            };
                            SelectionFilter       filter = new SelectionFilter(typedValue);
                            PromptSelectionResult result = ed.SelectAll(filter);
                            SelectionSet          set    = result.Value;
                            ObjectId[]            ids    = set.GetObjectIds();
                            foreach (ObjectId entid in ids)
                            {
                                objects.Add(trans.GetObject(entid, OpenMode.ForRead));
                            }
                        }
                        catch (Exception)
                        {
                            ed.WriteMessage("\n获取信息出错。");
                        }
                    }
                    trans.Commit();
                }
            }
            return(objects);
        }
예제 #17
0
        /// <summary>
        /// Gets the list of requested fields from parent
        /// <seealso cref="Field"/>
        /// </summary>
        /// <param name="selectionSet">
        /// The parent field selection set
        /// </param>
        /// <param name="context">
        /// The request context
        /// </param>
        /// <param name="type">
        /// The type containing the fields
        /// </param>
        /// <returns>
        /// The list of fields
        /// </returns>
        public static IEnumerable <Field> GetRequestedFields(
            SelectionSet selectionSet,
            ResolveFieldContext context,
            MergedType type)
        {
            var directFields = selectionSet.Selections.OfType <Field>();

            foreach (var field in directFields)
            {
                yield return(field);
            }

            var typeNames = type.GetPossibleFragmentTypeNames().ToList();

            var inlineFragments =
                selectionSet.Selections.OfType <InlineFragment>().Where(f => typeNames.Contains(f.Type.Name));

            foreach (var fragment in inlineFragments)
            {
                foreach (var field in GetRequestedFields(fragment.SelectionSet, context, type))
                {
                    yield return(field);
                }
            }

            var fragmentsUsed =
                selectionSet.Selections.OfType <FragmentSpread>()
                .Select(fs => context.Fragments.FindDefinition(fs.Name))
                .Where(f => typeNames.Contains(f.Type.Name));

            foreach (var fragment in fragmentsUsed)
            {
                foreach (var field in GetRequestedFields(fragment.SelectionSet, context, type))
                {
                    yield return(field);
                }
            }
        }
예제 #18
0
        //Methods


        /// <summary>
        /// Blöcke mit Fenster wählen
        /// </summary>
        /// <returns></returns>
        public ErrorStatus SelectWindow()
        {
            ErrorStatus  eStatus = ErrorStatus.KeyNotFound;
            SelectionSet ssRes   = null;
            Editor       ed      = Application.DocumentManager.MdiActiveDocument.Editor;

            //Filter
            TypedValue[] values = new TypedValue[1] {
                new TypedValue((int)DxfCode.Start, "INSERT")
            };
            SelectionFilter selFilter = new SelectionFilter(values);

            PromptSelectionResult resSel = ed.GetSelection(selFilter);

            if (resSel.Status == PromptStatus.OK)
            {
                ssRes = resSel.Value;
                FillTable(ssRes);
                eStatus = ErrorStatus.OK;
            }

            return(eStatus);
        }
예제 #19
0
        /// <summary>
        /// 获取制定块的对象
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ObjectIdCollection GetObjectIdsAtBlock(string name)
        {
            ObjectIdCollection    ids     = new ObjectIdCollection();
            PromptSelectionResult ProSset = null;

            TypedValue[] filList = new TypedValue[1] {
                new TypedValue((int)DxfCode.BlockName, name)
            };
            SelectionFilter sfilter = new SelectionFilter(filList);
            Editor          ed      = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            ProSset = ed.SelectAll(sfilter);
            if (ProSset.Status == PromptStatus.OK)
            {
                SelectionSet sst  = ProSset.Value;
                ObjectId[]   oids = sst.GetObjectIds();
                for (int i = 0; i < oids.Length; i++)
                {
                    ids.Add(oids[i]);
                }
            }
            return(ids);
        }
예제 #20
0
        /// <summary>
        /// 选择所有对象
        /// </summary>
        /// <returns></returns>
        public static DBObjectCollection selectAll()
        {
            Entity                entity;
            DBObjectCollection    EntityCollection = new DBObjectCollection();
            PromptSelectionResult ents             = ed.SelectAll();

            if (ents.Status == PromptStatus.OK)
            {
                using (Transaction trans = db.TransactionManager.StartTransaction()){
                    SelectionSet ss = ents.Value;
                    foreach (ObjectId id in ss.GetObjectIds())
                    {
                        entity = trans.GetObject(id, OpenMode.ForWrite, true) as Entity;
                        if (entity != null)
                        {
                            EntityCollection.Add(entity);
                        }
                    }
                    trans.Commit();
                }
            }
            return(EntityCollection);
        }
예제 #21
0
        private List <ObjectId> SelectAllRaumblocks()
        {
            var             ed     = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            SelectionFilter filter = new SelectionFilter(new TypedValue[] {
                new TypedValue((int)DxfCode.Start, "INSERT"),
                new TypedValue((int)DxfCode.BlockName, Blockname)
            });
            PromptSelectionResult res = ed.SelectAll(filter);

            if (res.Status != PromptStatus.OK)
            {
                return(new List <ObjectId>());
            }

#if BRX_APP
            SelectionSet ss = res.Value;
#else
            using (SelectionSet ss = res.Value)
#endif
            {
                return(ss.GetObjectIds().ToList());
            }
        }
예제 #22
0
        /// <summary> 批量修改标注样式 </summary>
        public ExternalCmdResult ModifyDimStyle(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            var dimStyles = docMdf.acTransaction.GetObject
                                (docMdf.acDataBase.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;

            foreach (var dimStyleId in dimStyles)
            {
                var dimStyle = docMdf.acTransaction.GetObject(dimStyleId, OpenMode.ForWrite) as DimStyleTableRecord;

                // 开始修改标注样式
                if (dimStyle.Name.StartsWith("D"))
                {
                    // 修改箭头大小
                    dimStyle.Dimdec = 3;
                }
                else
                {
                    dimStyle.Dimdec = 0;
                }
            }

            return(ExternalCmdResult.Commit);
        }
예제 #23
0
        private ExternalCmdResult SetSubgradeEnvir(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;

            // var allXdataTypes = DbXdata.GetAllXdataTypes();
            var handledXdataTypes = DbXdata.DatabaseXdataType.RangeBlocks | DbXdata.DatabaseXdataType.SoilRockRange;
            // 在执行此方法前,已经通过“DbXdata.LoadAllOptionsFromDbToMemory”方法,将文档中的通用选项加载到了内存中,所以不需要再特别地调用 RefreshOptionsFromDb()方法了。
            //DbXdata.RefreshOptionsFromDb(docMdf, handledXdataTypes);
            //
            var fm  = new Form_SubgradeEnvir(docMdf);
            var res = fm.ShowDialog();

            if (res == DialogResult.OK)
            {
                DbXdata.FlushXData(docMdf, handledXdataTypes);
            }
            else if (res == DialogResult.Cancel)
            {
                // 将内存中对全局选项的修改进行还原,还原的方法就是重新从数据库中加载修改前的数据。
                DbXdata.RefreshOptionsFromDb(docMdf, handledXdataTypes);
            }
            return(ExternalCmdResult.Commit);
        }
예제 #24
0
        public void testRotate()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptSelectionOptions optSel = new PromptSelectionOptions();

            optSel.MessageForAdding = "请选择对象";
            PromptSelectionResult resSel = ed.GetSelection();

            if (resSel.Status != PromptStatus.OK)
            {
                return;
            }

            SelectionSet sset = resSel.Value;

            ObjectId[] ids = sset.GetObjectIds();
            foreach (ObjectId id in ids)
            {
                Edit.Rotate(id, new Point3d(0, 0, 0), Edit.Rad2Ang(30));
            }
        }
예제 #25
0
        public ExternalCommandResult Execute(SelectionSet impliedSelection, ref string errorMessage, ref IList <ObjectId> elementSet)
        {
            var dat = new DllActivator_eZcadTools();

            dat.ActivateReferences();

            using (DocumentModifier docMdf = new DocumentModifier(openDebugerText: true))
            {
                try
                {
                    BlockRefenceTest(docMdf.acDataBase, docMdf.acEditor, docMdf.acTransaction);
                    //
                    docMdf.acTransaction.Commit();
                    return(ExternalCommandResult.Succeeded);
                }
                catch (Exception ex)
                {
                    docMdf.acTransaction.Abort(); // Abort the transaction and rollback to the previous state
                    errorMessage = ex.Message + "\r\n\r\n" + ex.StackTrace;
                    return(ExternalCommandResult.Failed);
                }
            }
        }
예제 #26
0
 public static void SSForeach <T>(SelectionSet sset, Action <T> proc, OpenMode openMode = OpenMode.ForRead)
     where T : class
 {
     if (sset == null)
     {
         return;
     }
     using (Transaction tr = activeDB.TransactionManager.StartTransaction()) {
         foreach (SelectedObject so in sset)
         {
             if (so != null)
             {
                 T ent = tr.GetObject(so.ObjectId, openMode) as T;
                 if (ent != null)
                 {
                     proc(ent);
                 }
             }
         }
         tr.Commit();
         tr.Dispose();
     }
 }
예제 #27
0
        /// <summary>
        /// Apply appearance to selection set
        /// </summary>
        /// <param name="selectionSet"></param>
        /// <param name="Color"></param>
        /// <param name="transparency"></param>
        private void ApplyAppearance(SelectionSet selectionSet, object Color, object transparency)
        {
            if (selectionSet != null &&
                (Color != null || transparency.ToString() != "-1"))

            {
                var debug = selectionSet.Search.FindAll(false);
                IEnumerable <ModelItem> modelItems = debug as IEnumerable <ModelItem>;


                if (Color != null)
                {
                    //Pick color from json
                    var color = TransformColor(ColorTranslator.FromHtml(Color.ToString()));
                    Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(modelItems, color);
                }

                if (transparency.ToString() != "-1")
                {
                    Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentTransparency(modelItems, int.Parse(transparency.ToString()));
                }
            }
        }
예제 #28
0
파일: Select.cs 프로젝트: 15831944/EM
        getBrkLines()
        {
            ObjectIdCollection idsBrkLine = new ObjectIdCollection();

            TypedValue[] tvs = new TypedValue[2];
            tvs.SetValue(new TypedValue((int)DxfCode.Start, RXClass.GetClass(typeof(Polyline3d)).DxfName), 0);
            tvs.SetValue(new TypedValue((int)DxfCode.LayerName, "CPNT-BRKLINE"), 1);

            SelectionSet ss = Select.buildSSet(tvs);

            if (ss == null)
            {
                return(idsBrkLine);
            }

            ObjectId[] ids = ss.GetObjectIds();
            for (int i = 0; i < ids.Length; i++)
            {
                idsBrkLine.Add(ids[i]);
            }

            return(idsBrkLine);
        }
예제 #29
0
        /// <summary> 从边坡线所绑定的防护方式的文字对象来设置防护 </summary>
        public ExternalCmdResult FlushProtection(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;
            SQUtils.SubgradeEnvironmentConfiguration(docMdf);
            // var allSections = ProtectionUtils.GetAllSections(docMdf);
            var slopeLines = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true);

            // 从文字中提取边坡防护方式的数据
            foreach (var slp in slopeLines)
            {
                var xdata   = slp.XData;
                var slpSegs = SlopeData.Combine(xdata.Slopes, xdata.Platforms, sort: false);
                foreach (var s in slpSegs)
                {
                    SlopeLine.ExtractProtectionFromText(s, _docMdf.acDataBase);
                }
                // 将数据保存下来
                slp.Pline.UpgradeOpen();
                slp.FlushXData();
                slp.Pline.DowngradeOpen();
            }
            return(ExternalCmdResult.Commit);
        }
예제 #30
0
 public override Field EnterField(Field field)
 {
     if (field.Name.Value == "a")
     {
         var selectionSet = new SelectionSet
         {
             Selections = field.SelectionSet.Selections.Add(AddedField),
         };
         return(new Field
         {
             Alias = field.Alias,
             Name = field.Name,
             Arguments = field.Arguments,
             Directives = field.Directives,
             SelectionSet = selectionSet,
         });
     }
     else if (field == AddedField)
     {
         DidVisitAddedField = true;
     }
     return(field);
 }
예제 #31
0
        private object createSearchSetFromSearch(object name, object search)
        {
            //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html

            Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
            object   ss  = null;

            if (search is Search)
            {
                var currentSearch = new Search(search as Search);
                currentSearch.PruneBelowMatch = false;
                currentSearch.Selection.SelectAll();

                currentSearch.Locations = SearchLocations.DescendantsAndSelf;
                SavedItem selectionSet = new SelectionSet(currentSearch);
                selectionSet.DisplayName = name.ToString();


                Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, selectionSet);
                Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ToSavedItemCollection();
            }
            return(ss);
        }
예제 #32
0
        public static void NewFoundationLine()
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            using (Transaction acTrans = acDoc.Database.TransactionManager.StartTransaction())
            {
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                // If the prompt status is OK, objects were selected
                if (acSSPrompt.Status == PromptStatus.OK)
                {
                    SelectionSet      acSSet  = acSSPrompt.Value;
                    FoundationManager manager = DataService.Current.GetStore <StructureDocumentStore>(acDoc.Name)
                                                .GetManager <FoundationManager>();

                    // Step through the objects in the selection set
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        // Check to make sure a valid SelectedObject object was returned
                        if (acSSObj != null)
                        {
                            // Open the selected object for write
                            Entity acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Entity;

                            if (acEnt is Curve)
                            {
                                FoundationCentreline foundationCentreline = new FoundationCentreline();
                                foundationCentreline.BaseObject = acEnt.ObjectId;
                                manager.Add(foundationCentreline);
                            }
                        }
                    }

                    manager.UpdateDirty();
                }
            }
        }
예제 #33
0
        /// <summary>
        /// 通过XData,过滤包含字符串的实体
        /// </summary>
        /// <param name="data"></param>
        public static ObjectIdCollection SelectXdataObj(string data)
        {
            ObjectIdCollection objIds = new ObjectIdCollection();

            //获取当前文档编辑器
            Editor editor = Application.DocumentManager.MdiActiveDocument.Editor;

            //创建 TypedValue 数组,定义过滤条件
            TypedValue[] tValue = new TypedValue[2];
            tValue.SetValue(new TypedValue((int)DxfCode.Start, "Circle"), 0);
            tValue.SetValue(new TypedValue((int)DxfCode.ExtendedDataAsciiString,
                                           data), 1);
            //将过滤条件赋给 SelectionFilter 对象
            SelectionFilter sFilter = new SelectionFilter(tValue);
            //请求在图形区域选择对象
            PromptSelectionResult psr;

            psr = editor.GetSelection(sFilter);
            //如果提示状态 OK,说明已选对象
            if (psr.Status == PromptStatus.OK)
            {
                SelectionSet ss = psr.Value;
                Application.ShowAlertDialog("Number of objects selected: " +
                                            ss.Count.ToString());

                foreach (ObjectId id in ss.GetObjectIds())
                {
                    objIds.Add(id);
                }
            }
            else
            {
                Application.ShowAlertDialog("Number of objects selected: 0");
            }

            return(objIds);
        }
예제 #34
0
파일: EW_Main.cs 프로젝트: 15831944/EM
        public static void makeSurfaceOXg()
        {
            Layer.manageLayers("OXg-BRKLINE");
            Layer.manageLayers("OXg-BRKLINE-AREA");
            Layer.manageLayers("OXg-SURFACE");

            SelectionSet ss = EW_Utility1.buildSSetOXg();

            ObjectId[] ids = ss.GetObjectIds();

            for (int i = 0; i < ids.Length; i++)
            {
                ObjectId idOXg    = ids[i];
                string   strLayer = idOXg.getLayer();

                ObjectId idLWPlineX = idOXg.offset(-0.05);

                if (idLWPlineX == ObjectId.Null)
                {
                    idOXg.changeProp(LineWeight.LineWeight200, Misc.getColorByBlock(206));
                }
                else
                {
                    idLWPlineX.changeProp(LineWeight.LineWeight100, clr.mag);

                    if (!offsetSegments("SG", "OXg", idLWPlineX, strLayer))
                    {
                        return;
                    }
                }
            }

            if (ss.Count > 0)
            {
                viewResults("OXg", true);
            }
        }
예제 #35
0
        /// <summary>
        /// 提示用户选择实体,改变选择的所选实体的颜色
        /// </summary>
        /// <param name="colorIndex">需要变成的颜色</param>
        public static void ChangeEntityColor(int colorIndex)
        {
            //获取当前文档和数据库
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            //启动事务
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //请求在图形区域选择对象
                PromptSelectionResult psr = doc.Editor.GetSelection();
                //如果提示状态OK,表示已选择对象
                if (psr.Status == PromptStatus.OK)
                {
                    SelectionSet ss = psr.Value;
                    //遍历选择集内的对象
                    foreach (SelectedObject sobj in ss)
                    {
                        //确认返回的是合法的SelectedObject对象
                        if (sobj != null)
                        {
                            //以写打开所选对象
                            Entity ent = trans.GetObject(sobj.ObjectId,
                                                         OpenMode.ForWrite) as Entity;
                            if (ent != null)
                            {
                                //将对象颜色修改为绿色,绿色:3
                                ent.ColorIndex = colorIndex;
                            }
                        }
                    }
                    //保存新对象到数据库
                    trans.Commit();
                }
                //关闭事务
            }
        }
예제 #36
0
        /// <summary> 缩放文字大小 </summary>
        public ExternalCmdResult ScaleText(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;
            var texts = GetTexts(docMdf);
            //
            Editor ed  = Application.DocumentManager.MdiActiveDocument.Editor;
            double sc  = 2;
            var    psr = ed.GetDouble("\n缩放比例: ");

            if (psr.Status == PromptStatus.OK)
            {
                sc = psr.Value;
            }
            //

            foreach (var id in texts)
            {
                var ent = docMdf.acTransaction.GetObject(id, OpenMode.ForRead);
                if (ent is DBText)
                {
                    ent.UpgradeOpen();
                    var t = ent as DBText;

                    t.Height = t.Height * sc;
                    ent.DowngradeOpen();
                }
                else if (ent is MText)
                {
                    ent.UpgradeOpen();
                    var t = ent as MText;
                    t.TextHeight *= sc;
                    ent.DowngradeOpen();
                }
            }
            docMdf.acActiveDocument.Editor.Regen();
            return(ExternalCmdResult.Commit);
        }
예제 #37
0
파일: SelectPoints.cs 프로젝트: 15831944/EM
        selectPntsOnScreen()
        {
            SelectionSet ss = Select.buildSSet(typeof(CogoPoint), false, "Select Cogo Point");

            ObjectId[]   ids    = ss.GetObjectIds();
            List <CgPnt> cgPnts = new List <CgPnt>();

            for (int i = 0; i < ids.Length; i++)
            {
                ObjectId  idCgPnt = ids[i];
                CogoPoint objPnt  = (CogoPoint)idCgPnt.getEnt();

                if (objPnt.Layer.Contains("-OS-"))
                {
                    if (!objPnt.Layer.Contains("NOT-USED"))
                    {
                        ResultBuffer rb = idCgPnt.getXData("STAKE");
                        if (rb == null)
                        {
                            continue;
                        }
                        TypedValue[] tvs = rb.AsArray();

                        CgPnt cgPnt = new CgPnt
                        {
                            Num       = objPnt.PointNumber,
                            Desc      = conformPntDesc(objPnt.RawDescription),
                            nameLayer = objPnt.Layer,
                            hAlign    = tvs[1].Value.ToString().stringToHandle()
                        };
                        cgPnts.Add(cgPnt);
                    }
                }
            }

            Stake_ProcessPntList.ProcPntList(cgPnts, "OnScreen");
        }
예제 #38
0
 public override SelectionSet LeaveSelectionSet(SelectionSet selectionSet)
 {
     Visited = Visited.Add(Tuple.Create(false, selectionSet.Kind, (object)null));
     return selectionSet;
 }
예제 #39
0
 public override SelectionSet EnterSelectionSet(SelectionSet selectionSet)
 {
     Visited = Visited.Add(Tuple.Create(true, selectionSet.Kind, (object)null));
     return selectionSet;
 }
예제 #40
0
 void Start()
 {
     SelectionSet = GetComponent<SelectionSet>();
 }
예제 #41
0
 public override Field EnterField(Field field)
 {
     if (field.Name.Value == "a")
     {
         var selectionSet = new SelectionSet
         {
             Selections = field.SelectionSet.Selections.Add(AddedField),
         };
         return new Field
         {
             Alias = field.Alias,
             Name = field.Name,
             Arguments = field.Arguments,
             Directives = field.Directives,
             SelectionSet = selectionSet,
         };
     }
     else if (field == AddedField)
     {
         DidVisitAddedField = true;
     }
     return field;
 }
예제 #42
0
        public static SortedList<double, int> OrderObjects(SelectionSet ss, bool rightToLeft_one_OrBottomToTop_zero)
        {
            // gives you the DBText and ids ordered from right to left or top to bottom as the case may be
            // some dimensions might be mtext. some might be dbtext. we have to account for this.
            // we are either going in the x direction or the y direction. we have to account for this as well.

            Dictionary<Point3d, int> mtextDbTextPosition_Length = new Dictionary<Point3d, int>();

            SortedList<double, int> xOrYPosition_DimensionLength = new SortedList<double, int>();

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            using (DocumentLock docLock = doc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    foreach (SelectedObject so in ss)
                    {
                        DBText dbtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as DBText;

                        MText mtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as MText;

                        // ok so let's add the db text if it's not null
                        if (dbtext != null)
                        {
                            // check if it's a legitimate number, if it is, the continue on
                            if (!Regex.IsMatch(dbtext.TextString, @"^\s*\d+\s*$"))
                            {
                                // System.Windows.Forms.MessageBox.Show("Dimension " + dbtext.TextString + " is invalid. Pls check it");
                            }
                            else
                            {
                                mtextDbTextPosition_Length.Add(dbtext.Position, Convert.ToInt32(dbtext.TextString));
                            }
                        }

                        // but if it's an mtext then add that
                        if (mtext != null)
                        {
                            // check if it's a legitimate number, if it is, the continue on
                            if (!Regex.IsMatch(mtext.Text, @"^\s*\d+\s*$"))
                            {
                                // System.Windows.Forms.MessageBox.Show("Dimension " + dbtext.TextString + " is invalid. Pls check it");
                            }
                            else
                            {
                                mtextDbTextPosition_Length.Add(mtext.Location, Convert.ToInt32(mtext.Text));
                            }
                        }
                    }
                }
            }

            // sorts from left to right, increasing the x axis
            if (rightToLeft_one_OrBottomToTop_zero == true )
            {
                if (mtextDbTextPosition_Length != null)
                {
                    foreach (KeyValuePair<Point3d, int> item in mtextDbTextPosition_Length)
                    {
                        xOrYPosition_DimensionLength.Add(item.Key.X, item.Value);
                    }
                }
            }
            else
            {
                if (mtextDbTextPosition_Length != null)
                {
                    foreach (KeyValuePair<Point3d, int> item in mtextDbTextPosition_Length)
                    {
                        xOrYPosition_DimensionLength.Add(item.Key.Y, item.Value);
                    }
                }
            }

            return xOrYPosition_DimensionLength;
        }
예제 #43
0
        public static SortedList<double, string> OrderObjects_string(SelectionSet ss, bool rightToLeft_one_OrBottomToTop_zero)
        {
            // some dimensions might be mtext. some might be dbtext. we have to account for this.
            // we are either going in the x direction or the y direction. we have to account for this as well.

            Dictionary<Point3d, string> mtextDbTextPosition_Label = new Dictionary<Point3d, string>();

            SortedList<double, string> xOrYPosition_DimensionLength = new SortedList<double, string>();

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            using (DocumentLock docLock = doc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    foreach (SelectedObject so in ss)
                    {
                        DBText dbtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as DBText;

                        MText mtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as MText;

                        // ok so let's add the db text if it's not null
                        if (dbtext != null)
                        {
                            if (mtextDbTextPosition_Label.ContainsKey(dbtext.Position))
                            {
                                System.Windows.Forms.MessageBox.Show("Labels must have differing positions on either the X and Y axis. Label " + dbtext.TextString + "is positioned on the same axis as another label. Please move one of the labels");
                            }
                            else
                            {
                                mtextDbTextPosition_Label.Add(dbtext.Position, dbtext.TextString);
                            }

                        }

                        // but if it's an mtext then add that
                        if (mtext != null)
                        {
                            if (mtextDbTextPosition_Label.ContainsKey(mtext.Location))
                            {
                                System.Windows.Forms.MessageBox.Show("two labels cannot have the same position. Label " + mtext.Text + "is positioned exactly the same as another label. Please move one of the labels");
                            }
                            else
                            {
                                mtextDbTextPosition_Label.Add(mtext.Location, mtext.Text);
                            }
                        }
                    }
                }
            }

            // sorts from left to right, increasing the x axis
            if (rightToLeft_one_OrBottomToTop_zero == true)
            {
                if (mtextDbTextPosition_Label != null)
                {
                    foreach (KeyValuePair<Point3d, string> item in mtextDbTextPosition_Label)
                    {
                        if (!xOrYPosition_DimensionLength.ContainsKey(item.Key.X))
                        {
                            xOrYPosition_DimensionLength.Add(item.Key.X, item.Value);
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Same X coordinate for Label " + item.Value + "./n/n It is positioned exactly the same as another label. Please move one of the labels.");
                        }
                    }
                }
            }
            else
            {
                if (mtextDbTextPosition_Label != null)
                {
                    foreach (KeyValuePair<Point3d, string> item in mtextDbTextPosition_Label)
                    {
                        // only add if it doesn't contain a key
                        if (!xOrYPosition_DimensionLength.ContainsKey(item.Key.Y))
                        {
                            xOrYPosition_DimensionLength.Add(item.Key.Y, item.Value);
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Same Y coordinate for Label " + item.Value + "\n\n It is positioned exactly the same as another label. Please move one of the labels.");
                        }

                    }
                }
            }

            return xOrYPosition_DimensionLength;
        }
예제 #44
0
        // Returns all selected object IDS in a selection set - all IDs no matter the name of the blocks etc.
        public static ObjectIdCollection GetAllIDsFromSS(SelectionSet ss)
        {
            ObjectIdCollection idsOfObjects = new ObjectIdCollection();

            foreach (SelectedObject so in ss)
            {
                idsOfObjects.Add(so.ObjectId);
            }

            return idsOfObjects;
        }
예제 #45
0
 private void SelectManager_ObjectsSelected(object sender, SelectionEventArgs e)
 {
     this.selection = e.Selection;
 }
예제 #46
0
 /// <summary>
 /// Runs a set of selectors and returns the combined result as a single enumerable
 /// </summary>
 /// <param name="selectors"></param>
 /// <returns></returns>
 protected IEnumerable<IDomObject> mergeSelections(IEnumerable<string> selectors)
 {
     SelectionSet<IDomObject> allContent = new SelectionSet<IDomObject>();
     Each(selectors, item => allContent.AddRange(Select(item)));
     return allContent;
 }
예제 #47
0
        public static List<Point3d> GetTextPositions(SelectionSet ss)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            List<Point3d> textPositions = new List<Point3d>();

            using (DocumentLock docLock = doc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    foreach (SelectedObject so in ss)
                    {
                        DBText dbtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as DBText;

                        MText mtext = tr.GetObject(so.ObjectId, OpenMode.ForRead) as MText;

                        // ok so let's add the db text if it's not null
                        if (dbtext != null)
                        {
                            textPositions.Add(dbtext.Position);
                        }

                        // but if it's an mtext then add that
                        if (mtext != null)
                        {
                            textPositions.Add(mtext.Location);
                        }
                    }
                }
            }

            return textPositions;
        }
예제 #48
0
        // Successfully works
        public static ObjectIdCollection GetBRids(SelectionSet ss, string blockname)
        {
            ObjectIdCollection idsOfSS_containsAllObjectIds = GetAllIDsFromSS(ss);              // id collection contains all IDS
            ObjectIdCollection idsInSS_containsOnlyBlockNames = new ObjectIdCollection();       // id collection which needs irrelevant components to be removed from it

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            foreach (ObjectId id in idsOfSS_containsAllObjectIds)                               // populating ID collection. We must now remove from this collection all blockRefIds which do not have blockname in them.
            {
                idsInSS_containsOnlyBlockNames.Add(id);
            }

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in idsInSS_containsOnlyBlockNames)
                {
                    BlockReference br = tr.GetObject(id, OpenMode.ForRead) as BlockReference;

                    if (br != null)
                    {
                        if (! (br.Name == blockname))
                        {
                            idsInSS_containsOnlyBlockNames.Remove(id);
                        }
                    }
                }
            }

            return idsInSS_containsOnlyBlockNames;
        }
예제 #49
0
 private void SelectManager_ObjectsDeselected(object sender, SelectionEventArgs e)
 {
     this.selection = null;
 }
예제 #50
0
 public static Dictionary<ObjectId, string> GetAVsandBRidsfromSS(string blockName, string attributeName, SelectionSet ss)
 {
     ObjectIdCollection BrefIds = GetBRids(ss, blockName);
     return GetAVsandBRidsFromBRids(blockName, attributeName, BrefIds);
 }
예제 #51
0
        private void PrintSelectionSet(string title, SelectionSet ss)
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
             Editor ed = doc.Editor;

             ed.WriteMessage(string.Format("{0} BreakupBegin", Environment.NewLine));

             foreach (ObjectId id in ss.GetObjectIds())
             {
                 ed.WriteMessage( string.Format("{0}{1}", Environment.NewLine, id.ObjectClass.Name)          );
             }

             ed.WriteMessage(string.Format("{0}BreakupEnd", Environment.NewLine));
        }