TBC Macros and Extensions

 View Only
Expand all | Collapse all

TransformData is deteriorating the object origin

  • 1.  TransformData is deteriorating the object origin

    Posted 02-04-2025 16:35

    I've got a macro that rotates IFC objects.

    If I apply multiple rotations one after the other, the object starts to move away from the original origin at an increasing speed.

    My original code did use the Matrix4D at the user's selected origin, which could be far away from 0,0,0.

    targetmatrix = Matrix4D.BuildTransformMatrix(Vector3D(ps1), Vector3D(0, 0, 0), spinor, Vector3D(1, 1, 1))

    It doesn't make a difference if the ShellMeshInstance vertices are defined close to zero or far away, both objects act exactly the same.

    If I use the above shown matrix, rotating directly around the user defined origin, far away from zero, I get a visible shift after about 17 rotations.

    If I shift it to zero first, like the below code, I get a visible shift after about 6 rotations.

    matrixtozero = Matrix4D.BuildTransformMatrix(ps1, Point3D(0, 0, 0), 0, 1.0, 1.0, 1.0)
    matrixbacktops1 = Matrix4D.BuildTransformMatrix(Point3D(0, 0, 0), ps1,  0, 1.0, 1.0, 1.0)
    
    targetmatrix = Matrix4D.BuildTransformMatrix(Vector3D(0, 0, 0), Vector3D(0, 0, 0), spinor, Vector3D(1, 1, 1))
    targetmatrixinverted = Matrix4D.BuildTransformMatrix(Vector3D(0, 0, 0), Vector3D(0, 0, 0), spinor.Reverse, Vector3D(1, 1, 1))
    
    o.Transform(TransformData(matrixtozero, None)) # move object to zero
    o.Transform(TransformData(targetmatrix, None))  # apply rotation about 1 axis and origon at 0,0,0
    o.Transform(TransformData(targetmatrixinverted, None)) # apply the exact opposite rotation
    o.Transform(TransformData(matrixbacktops1, None)) # move object back to where it was

    Before and after each rotation I copy the ShellMeshInstance's current GlobalTransformation into a list.

    After doing 6 times the above the object has moved several metres.

    Here it shows about 10 metres, on the screen it's more than 20. Don't understand the difference.

    Either way, shifting it to zero or not, I could understand if the rotation would be slightly affected, but there is no reason why it should translate, the targetmatrix is set explicitly to no shift (Vector3D(0,0,0)), so it must not.

    What is the reason for this translation? This looks suspiciously like a bug to me.



    ------------------------------
    Ronny Schneider
    ------------------------------


  • 2.  RE: TransformData is deteriorating the object origin
    Best Answer

    Posted 02-05-2025 15:14

    Hey Ronny,

    We also found this issue last year. It has been fixed in the current version of TBC v2024.10.

    Cheers,



    ------------------------------
    Andrew Clark
    ------------------------------



  • 3.  RE: TransformData is deteriorating the object origin

    Posted 02-05-2025 15:40

    Thanks for the update Andrew,

    as usual not included in the release notes.

    And since there wasn't much of interest in them in general, I've been avoiding the 2-hour over the phone update session with our IT, where they have to enter their password a dozen times. It seems I'll have to bite the bullet soonish.

    TBC, TBC backup, restoring macro folder permissions, Office update, RPS to get the few Trimble macros, latest ANZ, TIM, Access Sim, Siteworks Sim, Connect Synch ...



    ------------------------------
    Ronny Schneider
    ------------------------------



  • 4.  RE: TransformData is deteriorating the object origin

    Posted 02-12-2025 15:49

    Yesterday I went through the ordeal with IT and updated to 2024.10.

    It's still moving but at a much tinier rate. You'll only see it visually after hundreds of rotations.

    Below example is a forward/backward rotation about one axis, and the change of the GlobalTransformation.Translation values plotted



    ------------------------------
    Ronny Schneider
    ------------------------------