Transform of linked element creates an empty outline

dean.hayton
Participant
Participant

Transform of linked element creates an empty outline

dean.hayton
Participant
Participant

Hi all. I want to create an outline from a linked element's bounding box to use in a BoundingBoxIntersectsFilter. My approach bellow works for some cases but where a link or element is rotated beyond a certain limit, the bounding box goes askew and the Outline(xyz, xyz) method returns an empty outline. I've tried scaling the bounding box up with an offset which fixes some cases, but not all of them. Some advice on solutions would be appreciated. 

Screenshot (27).png

non-rotated link

 

Screenshot (28).png

rotated link

#get the elements bounding box
s_BBox = element.get_BoundingBox(doc.ActiveView)

#apply the link documents transform
s_BBox_min = link_trans.OfPoint(s_BBox.Min)
s_BBox_max = link_trans.OfPoint(s_BBox.Max)

#make the outline
new_outline = Outline(s_BBox_min, s_BBox_max)

#make the filter
bb_filter = BoundingBoxIntersectsFilter(new_outline)

 

 

0 Likes
Reply
Accepted solutions (1)
355 Views
2 Replies
Replies (2)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

Yes. You can corrupt the bounding box by transforming it. I would suggest the following:

  

  • Extract all eight corner vertices of the bounding box
  • Transform all eight vertices as individual points
  • Create a new bounding box from the eight transformed results

  

The Building Coder samples includes code to create and enlarge a bounding box point by point that will come in handy for the last step:

  

  /// <summary>
  ///   Expand the given bounding box to include
  ///   and contain the given point.
  /// </summary>
  public static void ExpandToContain(
    this BoundingBoxXYZ bb,
    XYZ p)
  {
    bb.Min = new XYZ(Math.Min(bb.Min.X, p.X),
      Math.Min(bb.Min.Y, p.Y),
      Math.Min(bb.Min.Z, p.Z));

    bb.Max = new XYZ(Math.Max(bb.Max.X, p.X),
      Math.Max(bb.Max.Y, p.Y),
      Math.Max(bb.Max.Z, p.Z));
  }

  

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/Util.cs#L2724-L...

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

dean.hayton
Participant
Participant

Hi Jeremy, this solution works well, thanks

0 Likes