Face Lower Left corner

Face Lower Left corner

revitaddins
Contributor Contributor
1,128 Views
5 Replies
Message 1 of 6

Face Lower Left corner

revitaddins
Contributor
Contributor

Hi Guys,

 

It's me again 😉 wondering why I'm getting different result on getting face bounding box max/min as shown in the video.

Mech Tools-Inconsistent.gif

 

PlanarFace face = solid.Faces.get_Item(0) as PlanarFace;
BoundingBoxUV bbUV = face.GetBoundingBox();

XYZ p3 = face.Evaluate(bbUV.Max);
FamilyInstance famInst = doc.Create.NewFamilyInstance(p3, fixture, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

Thanks again.

0 Likes
Accepted solutions (1)
1,129 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

Can't easily see what you are doing from that gif but I'm assuming face 0 isn't always the same face direction. Have you compared the normal vectors of each?

 

Face.getBoundingBox:
"A BoundingBoxUV with the extents of the parameterization of the face."

 

0 Likes
Message 3 of 6

revitaddins
Contributor
Contributor

Hi @RPTHOMAS108  thank you again for your quick response, basically I just want to get lower left corner for each face, so I thought I'll start by getting bb min, I haven't compare their vectors yet (and not sure how) since they are all rectangular i just thought they should be returning at least same corner locations?

0 Likes
Message 4 of 6

revitaddins
Contributor
Contributor
PS. I did face normal comparison and they are all the same
0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor

Since you are dealing with a PlanarFace it has an X,Y and Z direction.

 

It will help your understanding to plot these and what that means for BoundingBoxUV coords plotted in that space. You can use Face.Evaluate to get XYZ for a given UV point on a face, whilst Face.ComputeDerivative will give you the direction vectors at a given point (for PlanarFace they don't change).

 

In the below RGB represents X,Y,Z at face origin respectively. Green line drawing from min to max (after transforming into coordinate space of face).

 

210324b.PNG

 

Ordinarily the UV points aren't as useful as say projecting an XYZ of a known location onto a face (Face.Project). If you are tiling the face etc. then UV may be useful but you have to consider direction and form of parameters may not be as you expect.  

Message 6 of 6

revitaddins
Contributor
Contributor
Accepted solution

Thanks @RPTHOMAS108 , very helpful, I found an answer from @jeremy_tammik 's utility samples, again thank you for both of you.

 

if anyone will need the same i posted jeremy's code below. Cheers!

 

// <summary>
    /// Return the bottom four XYZ corners of the given 
    /// bounding box in the XY plane at the given 
    /// Z elevation in the order lower left, lower 
    /// right, upper right, upper left:
    /// </summary>
    public static XYZ[] GetBottomCorners(
      BoundingBoxXYZ b,
      double z )
    {
      return new XYZ[] {
        new XYZ( b.Min.X, b.Min.Y, z ),
        new XYZ( b.Max.X, b.Min.Y, z ),
        new XYZ( b.Max.X, b.Max.Y, z ),
        new XYZ( b.Min.X, b.Max.Y, z )
      };
    }

    /// <summary>
    /// Return the bottom four XYZ corners of the given 
    /// bounding box in the XY plane at the bb minimum 
    /// Z elevation in the order lower left, lower 
    /// right, upper right, upper left:
    /// </summary>
    public static XYZ[] GetBottomCorners(
      BoundingBoxXYZ b )
    {
      return GetBottomCorners( b, b.Min.Z );
    }

 

0 Likes