Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transform of linked element creates an empty outline

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
dean.hayton
331 Views, 2 Replies

Transform of linked element creates an empty outline

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)

 

 

2 REPLIES 2
Message 2 of 3
jeremy_tammik
in reply to: dean.hayton

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
Message 3 of 3
dean.hayton
in reply to: jeremy_tammik

Hi Jeremy, this solution works well, thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report