How to get AABB of a ArrayMesh?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ícaro Dantas de Araú

Hello, I need to know the size of a 3d object, so I was looking for some way to get the AABB. ArrayMesh unfortunately does not have.

I tried to do the following:

func get_bounds(nd):
	var mdt = MeshDataTool.new()
	var m = nd.get_mesh()
	#get surface 0 into mesh data tool
	mdt.create_from_surface(m, 0)
	
	var bounds = AABB()
	for vtx in range(mdt.get_vertex_count()):
		var vert=mdt.get_vertex(vtx)
		
		bounds = bounds.expand(nd.global_transform.xform(vert))

	return bounds

But with some simple tests I realized it doesn’t work, can anyone help me?

:bust_in_silhouette: Reply From: Ícaro Dantas de Araú

Omg, i solved!

Solution:

var bounds = myMeshInstance.get_aabb()