Wrong placement of NewFamilyInstance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to place a family instance on the top face of a corbel.
For the majority of corbels along the model my code is able to place this family instance correctly. When the corbel is hosted on a beam the family I'm inserting gets the right hosting but is placed in the opposite side of the model, oriented along the X axis.
Here are the two target corbels, hosted on these beams:
Here is where the family instances are being placed:
Note that the family instances are aligned with the point I am placing them:
I'm using the following method:
doc.Create.NewFamilyInstance(corbelTopFace.Reference, point, direction, familySymbol);
The top face parameter is correct. Also is the family origin point.
The direction is determined by the following piece of code:
PlanarFace face = corbelTopFace as PlanarFace;
XYZ direction = face.FaceNormal.CrossProduct(XYZ.BasisZ);
if (direction .IsZeroLength())
{
direction = face.FaceNormal.CrossProduct(XYZ.BasisY);
}
Note that, when I use "direction = face.FaceNormal.CrossProduct(XYZ.BasisY);" occurs this problem I'm reporting. BUT, if I change it to "face.FaceNormal.CrossProduct(XYZ.BasisX);" I catch this exception:
Just for comparison this is the desired behaviour:
Any ideas what could be wrong?