Rotate families to face Camera/point

I’m attempting to rotate families to face the camera (or a specified point/coordinate).

I’ve utilized the ‘synthetic’ package to extract camera location and element facing direction. In my current workflow I’ve tried to get the vector of each element to camera location, and then the vector of existing element facing direction, then rotate the family by the difference in angle between those two vectors. However the graph is not working out for me.

One problem seems to be the camera position reported is not correct. I’m unsure whether units are the cause (i’m working in metric). Any help would be greatly appreciated. Graph attached.

Face-Me Script_.dyn (32.0 KB)

Face-Me Test Component.rfa (336 KB)

have you checked the value after AngelWithVector node ? because it will give you the degree without minus ( - ) sign, it could rotate the family in wrong direction

Hi @khuzaimah.ElecEng,

Cheers for the suggestion. I’ve tried out putting in an Abs node to ensure the rotation values remain positive but still don’t get a result. Let me know if i misunderstood.

I’ve also added an extra couple of nodes to visualize whats happening:

no, the idea is to have the minus sign where needed, the AngelWithVector node will give you the absolute value already.
are rotating by Z axis ?

@khuzaimah.ElecEng, I see what you mean now. I’ve tried a few things but can’t think how I would determine which rotation values must be negative. I did run the graph with all rotation values negative and all positive to see if any families orient correctly, but no luck so there must also be something else amiss…

Regarding the camera location, my initial suspicions of unit conversions were confirmed, as when i multiple the coordinate values to adjust from feet to millimetres, the camera location is correct.

I tried also converting ‘FamilyInstance.FacingOrientation’ in a similar manner, but it did not harbour results

i have a trick to add minus sign to the right value,
let us say that you want to rotate by Z axis, the Y value from both vectors and subtract them, now you will have some values with minus sign, make them all +1 & -1 and multiply these value to the Angels values

Cheers for the pointer, I believe I’ve set this up correctly but still no luck…

Face-Me Script_v1.dyn (84.1 KB)

Are you rotating in 3D or 2D?

The FamilyInstance.SetRotation node only rotates the family on the family’s Z axis. Unless your camera point is magically in line with every family’s origin point, you’ll get a bad result as the vector’s angle will produce a different value.

Vector.AngleAboutAxis will solve this problem for you.

1 Like

From some trial and error, I noticed that the ‘FamilyInstance.SetRotation’ node rotates elements from project north rather than their current orientation…

I therefore needed to get the angle between vector of elements to camera and vector going north (rather than vector of current family facing orientation).

@khuzaimah.ElecEng you’re trick to apply negative values to the angles resolved the issues with elements beyond the camera location (in x direction).

Thank you for all your help! Really happy with the result.

Face-Me Script_v1.dyn (64.0 KB)


Thank you, worked perfectly, just had to update the Synthetic nodes.