Author Topic: Cannot Select Invisible Entities  (Read 1657 times)

0 Members and 1 Guest are viewing this topic.

slingblade

  • Mosquito
  • Posts: 4
Cannot Select Invisible Entities
« on: November 19, 2015, 06:02:51 PM »
Hi,

I need to hide and show entities in my drawing, I want to do this by setting the visibility property on the entities.

To select the entities in the drawing I am using a selection set with a filter. In the filter I use DxfCode.Visibility to select the entities. The DxfCode.Visibility in the filter works when the entities are visible and I set the visibility code to zero. I.e. it returns the entities as expected.

However after I have set the entitles visible property to false and they are hidden and I want to select them again so I can make them visible, I reuse the same filter but  I set the DxfCode.visibility to 1. When I execute the selection set the PromptSelectionResult status is set to "Error". (I.e. result.Status == PromptStatus.Error)

Does anyone have experience with selecting invisible entities and can explain how I might do this?

This snippet is where I use the selection set:
Code: [Select]
                TypedValue[] values = ReturnEntityDxfCodes(entities_are_visible);

                SelectionFilter filter =
                  new SelectionFilter(values);
                PromptSelectionResult res =
                  ed.SelectCrossingWindow(new Point3d(extents.Max3d.ToArray()),
                  new Point3d(extents.Min3d.ToArray()), filter);
                if (res.Status == PromptStatus.OK)
                {
                    if (res.Value != null)
                    {
                        ObjectId[] obj_ids = res.Value.GetObjectIds();
                        return obj_ids;
                    }
                }

This is where I set the Dxf Codes, the last one selects visibility (this works if the entities are visible)
Code: [Select]
private TypedValue[] ReturnEntityDxfCodes(bool entities_are_visible)
        {
            int visible = 0;
            if (!entities_are_visible)
                visible = 1;

            TypedValue[] values =
                {
                  new TypedValue(
                    -4,
                    "<OR"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "Circle"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "Point"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "Insert"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "Line"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "LWPOLYLINE"
                  ),new TypedValue(
                    (int)DxfCode.Start,
                    "POLYLINE"
                  ),new TypedValue(
                    -4,
                    "OR>"
                  ),new TypedValue(
                    -4,
                    "<AND"
                  ),new TypedValue(
                    (int)DxfCode.Visibility,
                    visible
                  ),new TypedValue(
                    -4,
                    "AND>"
                  )
                };
            return values;
        }

To test the way I set the dxf codes I set only the dxfCode for visibility
Code: [Select]
if (!entities_are_visible)
                {
                    TypedValue[] invisible_dxfcode =
                    {
                        new TypedValue(
                        (int)DxfCode.Visibility,
                        1
                        )
                    };
                    return invisible_dxfcode;
                }

I had the same result with this, the result.Status flag was set to "Error".
« Last Edit: November 20, 2015, 02:07:07 AM by slingblade »
Where are we going and why am I in this hand-basket?

slingblade

  • Mosquito
  • Posts: 4
Re: Cannot Select Invisible Entities
« Reply #1 on: November 20, 2015, 02:30:35 AM »
I found the issue. I was using the SelectCrossingWindow selection set to search for invisible entities. This selection set requires the entities be visible.

I switch to the SelectAll(filter) selection set to select only the invisible entities.This works great. :-)
Where are we going and why am I in this hand-basket?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cannot Select Invisible Entities
« Reply #2 on: November 20, 2015, 03:08:18 AM »
slingblade,
To help anyone reading this thread at a later date , please post the code that solved your issue.

Thanks,
 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.