Author Topic: Highlight a fixed edge on a Box inside a Block  (Read 229 times)

0 Members and 1 Guest are viewing this topic.


  • Mosquito
  • Posts: 3
Highlight a fixed edge on a Box inside a Block
« on: November 18, 2019, 10:23:41 AM »
I am trying to highlight a fixed BOX's edge .
I went through some posts that seems GetSubentityPathsAtGraphicsMarker can do the job.
The idea works fine when the BOX is under directly Model Space since this command will take null input for the last argument in this case.
The problem I am having now is that when the BOX is under a BLOCK that the returned SubEntityPath can not include the top Blockreference's id even I already input the containers id in the last argument of GetSubentityPathsAtGraphicsMarker.
The returned SubEntityPathId is still having only entity's itself. So when going into highlight it will throw an exception.
The code I am having now is as below.
Can anyone help me point out what I am missing here?
And why the GSMarker is like 0x12, 0x16,... of the edge?  I got this number with another coding by PromptSelectionOption which allows me to see the GSMarker of single edge.
Is there other alternative way to get the GSMarkers?

Code: [Select]
        public static void SelectBox()
            Database db = HostApplicationServices.WorkingDatabase;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

                PromptNestedEntityOptions NEntOpt = new PromptNestedEntityOptions("\nPick a nested entity:");
                PromptNestedEntityResult NEntRes = ed.GetNestedEntity(NEntOpt);
                if (NEntRes.Status == PromptStatus.OK)
                    Point3d pt = NEntRes.PickedPoint;
                    Matrix3d mt = NEntRes.Transform;
                    ObjectId box_id = NEntRes.ObjectId;     
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                        Entity top_ent = null;
                        if (NEntRes.GetContainers().Length > 0)
                            top_ent = (Entity)tr.GetObject(NEntRes.GetContainers()[0], OpenMode.ForRead);

                        Entity box_ent = (Entity)tr.GetObject(box_id, OpenMode.ForRead);
                        FullSubentityPath[] ips = box_ent.GetSubentityPathsAtGraphicsMarker(SubentityType.Edge, (IntPtr)0x12, pt, mt, NEntRes.GetContainers());  //highlighting a fixed edge with 0x12

                        if (top_ent!=null)
                            top_ent.Highlight(ips[0], false);
                            box_ent.Highlight(ips[0], false);

            catch (System.Exception ex)