I am creating a reference plane after a user closes my PMP. I would like to know the transformation matrix of the plane before it’s being created because you cannot create the plane while the PMP is open.

I know the start direction of the edge. This will become the normal of the plane. But how do I calculate the x-axis and y-axis before the plane is created? Which coordinate transformation will SolidWorks use?

SW will use the coordinate system of the active document because that is where you are inserting the plane. The point you have will give the translation component of the math transform. You just need the rotation angles of the normal vector with regards to the coordinate system of the active document (where you are inserting the plane).

True. The impossible task is getting three rotation angles from a single direction vector for the normal.

I have finally given up because I think it’s mathematically impossible. Now I create the plane before showing the PMP and use the plane’s transformation matrix to create a preview and to create a sketch on that plane when closing the PMP.

I don’t know the context of your question, but have you considered using a Coordinate system?
This gives you some more control over the orientation of the X Y Z vectors.

For creating a plane those rotations are not important (you can use 0’s as in the code below)
fi. FeatureManager.InsertRefPlane(4, 0, 2, 0, 0, 0)

I don’t know if those are the angles SolidWorks uses. From what I have found here, they use Euler angles and ZXZ rotations. But of course, such a crucial thing is not documented anywhere in the official help.

@Eddy My goal was to calculate in advance what the plane transformation was going to be. I really needed that plane

I have finally found one working solution, spent way too many hours on it and now the client wants to try a completely different approach Luckily they don’t mind the extra hours.

Sure. I want to show a PMP and a preview of the geometry that I will create. You cannot create a reference plane when a PMP is open, and hiding the PMP, creating a plane and re-showing the PMP crashes Solidworks. So I create the plane before I open a PMP.

I then use the transformation matrix from the plane to draw the correct temporary geometry for a preview. If the user clicks OK, I create the actual sketch and geometry.

I’ve tried dozens of approaches and only got this to work.