Delete an area in a drafting view

Delete an area in a drafting view

Anonymous
Not applicable
961 Views
6 Replies
Message 1 of 7

Delete an area in a drafting view

Anonymous
Not applicable

Hello everybody!

 

I am working on a tool that creates schematics. I need to delete some elements (detail items) only in a given area of my drafting view.

 

Capture.PNG

 

In the above example I need to remove the lower detail item and keep the other two. I am trying to use the ElementOwnerViewFilter combined with the BoundingBoxIntersectsFilter as shown below.

 

 

 private void CleardBArea (ElementId vId, int dBPos, double width, double height)
{
    XYZ min = new XYZ(0,(height / 4) * dBPos,0);
    XYZ max = new XYZ(width,(height /4) * (dBPos + 1),0);

    
    Outline outline = new Outline(min,max);
    BoundingBoxIntersectsFilter bbF = new BoundingBoxIntersectsFilter(outline);
    ElementOwnerViewFilter eOVF = new ElementOwnerViewFilter(vId);
    FilteredElementCollector vColl = new FilteredElementCollector(this.ActiveUIDocument.Document).WherePasses(eOVF).WherePasses(bbF);
    ClearElements(vColl);
}

 

It works fine if I try to delete lines, but unfortunately, when I try to delete detail items, the filter ignores it.

Could you please recomend any other way to develop it?

 

thanks in advance

 

0 Likes
Accepted solutions (1)
962 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear Chema,

 

Please provide a complete minimal, self-explanatory, reproducible case including and sample model containing a macro with the source code to reproduce, demonstrate, analyse and test the problem and the solution:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Cheers, Jeremy.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 7

Anonymous
Not applicable

Please find attached a zip with the minimal infomratio to reproduce my problem.

 

There is a revit 2015 file with a macro that should remove half of the drafting view. It works with all elements excepts the family instances

 

regards!

0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

Do you mean family instances or detail items?



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 7

Anonymous
Not applicable

Detail Items

0 Likes
Message 6 of 7

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Chema,

 

This is my post nr. 2001!

 

Thank you for your clarification.

 

I raised an issue with the development team to clarify how to achieve this, REVIT-92319 [API: FilteredElementCollector misses detail items -- 11829955].

 

They took a look at it and closed it again as 'works as expected', because the BoundingBoxIntersectsFilter is intended for use with a model geometry bounding box.

 

A detail item only has a view specific geometry bounding box, so it fails to filter them.

 

The workaround is to retrieve the view specific bounding box and use Outline.Intersects to perform the equivalent check, e.g., like this:

 

  var b1 = detailItem.get_BoundingBox(this.ActiveView);
  XYZ min = new XYZ();
  XYZ max = new XYZ(1.969,0.656,0);
  var outline = new Outline(min,max);
  var outlineOfDetailItem = new Outline(b1.Min, b1.Max);
  outline.Intersects(outlineOfDetailItem , 0.00001);

 

I published this solution on The Building Coder as well for future reference:

 

http://thebuildingcoder.typepad.com/blog/2016/06/filtering-for-view-specific-elements.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 7

Anonymous
Not applicable

Thanks so much!!!!!!!!!

0 Likes