How to perform affine transform on familyInstance

How to perform affine transform on familyInstance

KM_Yotsuha
Advocate Advocate
327 Views
2 Replies
Message 1 of 3

How to perform affine transform on familyInstance

KM_Yotsuha
Advocate
Advocate

for curve,I can use CreateTransformed Method to perform affine transform;

how can I do that on a familyinstance?

 

 

in the picture below,I can get the transform of block XL-106 and XL-107。the transform of  block XL-106 HasReflection, so I can't place the family instance right.

 

how can I perform affine transform on familyInstance directly?

or how can I break the transform of block XL-106 in to a seriers of basic transform so I can use method in ElementTransformUtils?

KM_Yotsuha_0-1661927789040.png

 

0 Likes
Accepted solutions (1)
328 Views
2 Replies
Replies (2)
Message 2 of 3

aignatovich
Advisor
Advisor
Accepted solution

I would suggest to make a set of primitive operations form the source transform matrices, e.g. rotations, translations and movement and then use ElementTransformUtils to perform them.

 

Movement is obvious

Rotation. I have a partial solution:

public static class TransformExtensions
{
	/// <summary>
	/// Gets Euler angles in X-Y-Z order. Assuming that <paramref name="transform"/> is unscaled and doesn't represent mirror operations
	/// </summary>
	/// <param name="transform"></param>
	/// <returns></returns>
	public static XYZ ToEulerAngles(this Transform transform)
	{
		var y = Math.Asin(transform.BasisZ.X);

		if (y.IsLessThan(1, 1e-5))
		{
			var x = Math.Atan2(-transform.BasisZ.Y, transform.BasisZ.Z);

			var z = Math.Atan2(-transform.BasisY.X, transform.BasisX.X);

			return new XYZ(x, y, z);
		}

		return new XYZ(Math.Atan2(transform.BasisY.Z, transform.BasisY.Y), y, 0);
	}
}

Mirroing:

Seems it's enough to make one mirroing operation and then rotation is possible to make source transform, but I haven't prove it.

Message 3 of 3

KM_Yotsuha
Advocate
Advocate

Awosome~~~~

0 Likes