Multiply transform difference

Hi all,

I am trying to use an alternative method to multiply a transform. To do this, I am using System.Windows.Media.Media3D. But when I try to use it, I get a different result from when I use the SolidWorks API MultiplyTransform. I have attached my part and code (below). I think I am wrongly creating the Matrix3D, but I have tried different ways and none would give the same result as SolidWorks.

Transform.SLDPRT (45.6 KB)

    public void MultiplyTransform0()
    {
        var progId = "SldWorks.Application";

        var progType = Type.GetTypeFromProgID(progId);

        ISldWorks app = Activator.CreateInstance(progType) as SolidWorks.Interop.sldworks.ISldWorks;
        app.Visible = true;

        ModelDoc2 model = app.OpenDocSilent(@"<YOUR PATH>\Transform.SLDPRT", 1, 0);
                    
        Sketch sketch = model.GetActiveSketch2();
        MathUtility mathUtility = app.IGetMathUtility();
        MathTransform mathTransform = sketch.ModelToSketchTransform;
        mathTransform = mathTransform.Inverse();

        double[] transform = mathTransform.ArrayData;
        SketchPoint sketchPoint = sketch.GetSketchPoints2()[0];
        double[] point =  new double[] { sketchPoint.X, sketchPoint.Y, sketchPoint.Z };

        MathPoint mathPoint = mathUtility.CreatePoint(point);

        mathPoint = mathPoint.MultiplyTransform(mathTransform);

        double[] resultValue = mathPoint.ArrayData;

        Vector3D vector1 = new Vector3D(point[0], point[1], point[2]);

        Matrix3D matrix1 = new Matrix3D(
            transform[0], transform[1], transform[2], transform[13],
            transform[3], transform[4], transform[5], transform[14],
            transform[6], transform[7], transform[8], transform[15],
            transform[9], transform[10], transform[11], transform[12]
            );

        Vector3D vectorResult = new Vector3D();
        vectorResult = Vector3D.Multiply(vector1, matrix1);
    }

Thanks in advance for helping me out!

JJ

Can you share a few more specifics, maybe some sample numbers? Which two objects should be identical?

I wrote a whole article on the subject, maybe that helps you in some way:

I read your article. It’s really good and useful.

In the code I shared, you get a resultValue, which is the result you get using the multiply of the transform using SWX functions. The vectorResult is the result you get using the Vector3D multiplication. They should give the same result, but they don’t.