Wrong placement of NewFamilyInstance

Wrong placement of NewFamilyInstance

mateus.komarchesqui
Enthusiast Enthusiast
239 Views
0 Replies
Message 1 of 1

Wrong placement of NewFamilyInstance

mateus.komarchesqui
Enthusiast
Enthusiast

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:

mateuskomarchesqui_1-1648235645402.png

 

 

Here is where the family instances are being placed:

mateuskomarchesqui_2-1648235754488.png

 

 

Note that the family instances are aligned with the point I am placing them:

mateuskomarchesqui_3-1648235899953.png

 

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:

mateuskomarchesqui_0-1648235485909.png

 

 

Just for comparison this is the desired behaviour:

mateuskomarchesqui_4-1648236086856.png

 

 

Any ideas what could be wrong?

 

0 Likes
240 Views
0 Replies
Replies (0)