Move object, set origin and export

Hi,
Using Blender 4.3.2, I would like to select multiple objects in my blender scene, and have them individually translated to (0;0;0), set their origin according to their surface (bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS', center='MEDIAN')) and individually export them as GLBs.

How to code this ? I use Blender maybe twice a year during 5 min, and cannot keep up with the APIs changes, sorry guys

Thanks a lot :+1:

location is just object’s prop - https://docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.location
I believe object.origin_set is working for each object individually, so select them, call the operator and export in the way you like.

1 Like

Thanks Andrej,

I will sort that out for the selection translation and origin setting.

To export a list of object separately to glb, should I create an exporter
bpy.ops.collection.exporter_add(***, *name=''* )

then export ?

bpy.ops.collection.exporter_export(***, *index=0* )

Steps are unclear to me.

The simplest way would be just to do the steps in UI and then just list all operators you used from UI in your script. You can get operators names either from Info window in Scripting tab or from Python tooltips when hovering over buttons (make sure it’s enabled in Blender settings).

Yes this is what I did but the export and select are not listed!

Selection - https://blender.stackexchange.com/questions/38618/selecting-an-object-via-scripting

Export - hover over export button to get it’s operator’s name (ensure Python tooltips are enabled in settings).

That’s very kind of you, let’s do this.

Thanks!