Need some help with 3ds max to Blender converter

I’m working on a script that helps transfer assets from 3ds max to Blender.
I looked for existing scripts/solutions, but found none that work and do a good job.
My plan is to use some existing format both apps can use and use an additional XML file to transfer whatever data is missing, mainly the materials - since most of the assets use fairly standard PBR shaders+textures, transferring the material data is fairly easy as long as the material names are preserved.
I tried several formats. Alembic ignores materials completely and mangles the hierrachy and some names, USD has problems with the mesh geometry, and obj has smoothing issues. FBX seems like the best bet but objects are not always where they should be. Here’s why.
3ds max nodes have an additional transform, that’s used to offset the pivot (=origin) when needed. for example, if you create a door and you move the pivot off to the edge of the door, that isn’t getting baked into the mesh data, it’s saved as an additional transform that can be later un-done. you can also rotate the pivot and even scale it although that’s never used.
I can extract this data as a set of euler/quat and position offsets, and now I’m trying to figure out how to use it. I’m still new to blender coding/internals and bad at math but I figured it I turned on “affect origins” I could apply the original offsets in reverse, and that should do that trick. The rotation is a bit trickier as they have to be applied on the object’s initial transform orientation, one by one. and as far as I can tell, trying it on a single object, manually, it does. The problem is, I’m not sure how to implement it in code. My first idea is to save a transform orientation to a slot, use it to rotate, do that for each and every object using ops. dirty but should work… maybe?
But I want to have some input from professionals before I dive into it. Do you think this is the right way or is there some simpler way that doesn’t use ops to fix those issues? the 3ds max documentation says it should be possible to construct a transform matrix from the rotation position and scale offsets by multiplying them but my math education doesn’t extend to matrices and I have no idea how to take two vector values and a quat and end up with a matrix.
So… I’m open to any direction you could suggest. I’d be more than happy to find out some tool to transfer data already exists and works, or that a better format can transfer geometry flawlessly between max and blender. or some easier way to code the offsets.
Sorry for the long post and thanks for reading.

You know this one (i don’t have 3dsmax) B2MAX ?

Yeah, that’s one of the addons I tried. materials were gone and object locations were messed up. I think it’s just using FBX to transfer and not doing too much to fix the issues I had doing it manually.

Okay, I think I know what I need. I need help with code that:

  1. creates a transform orientation based on the current active object.
  2. applies three rotation transforms, first Z then Y then X, using that orientation.

I first tried it manually: using a test file with two objects and a set of euler angles taken from the 3ds max objectoffset values, I created the transform orientation, then used the rotate tool, using the gizmo and not the input boxes, to rotate Z Y and X and then, in the operator panel, input the accurate values I had. Doing this, I was able to return the object’s origin to its orientation in 3ds max. I could verify it visually as I had a child object that would align with the parent if the process was successful.

However when I tried writing code for that same operation, the result was visually different. The objects didn’t align, and I’m not sure why. So, if anyone could have a look and figure out why using the rotate tool and the code gave me different results, I’d be grateful.

the code:

bpy.context.scene.tool_settings.use_transform_data_origin = True
bpy.ops.transform.create_orientation(name=“MyOrientation”)
bpy.ops.transform.rotate(value=math.radians(16.6854), orient_axis=“Z”, orient_type=“MyOrientation”)
bpy.ops.transform.rotate(value=math.radians(18.8895), orient_axis=“Y”, orient_type=“MyOrientation”)
bpy.ops.transform.rotate(value=math.radians(47.2051), orient_axis=“X”, orient_type=“MyOrientation”)

I think what you’re looking for is a transform matrix. It’s a construct that describes location, rotation and scale of every object relatively to an origin (in case of world matrix, the center of the world (0, 0, 0))

print(bpy.context.active_object.matrix_world)