コード例 #1
0
ファイル: RingsAndEdges.cs プロジェクト: guchanghai/Cut
        /// <summary>
        /// Changes the color of the edges for each ring.
        /// </summary>
        /// <param name="ring">[in] Ring object.</param>
        /// <returns>  
        /// Returns true if successful.
        /// </returns>
        private bool HighLightRingEdges(Ring ring)
        {
            // Show how to get 1/2 edges in the Ring.
            HalfEdgeCollection edgeCollection = ring.GetEdges();

            using (Transaction trans = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
            {
                // Loops through and highlights all the edges
                int edgeIndex = 0;
                foreach (HalfEdge halfEdge in edgeCollection)
                {
                    FullEdge fullEdge = halfEdge.FullEdge;
                    ObjectId objId = fullEdge.Entity;

                    Entity entity = trans.GetObject(objId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, false) as Entity;
                    if (null != entity)
                        entity.ColorIndex = edgeIndex + 1;

                    edgeIndex = edgeIndex + 1;
                }

                trans.Commit();
            }

            return true;
        }