in tools.py [0:0]
def get_object_info(context: Any, name: str):
try:
obj = bpy.data.objects.get(name)
if not obj:
raise ValueError(f"Object with name {name} not found")
obj_info = {
"name": obj.name,
"type": obj.type,
"location": [obj.location.x, obj.location.y, obj.location.z],
"rotation": [
obj.rotation_euler.x,
obj.rotation_euler.y,
obj.rotation_euler.z,
],
"scale": [obj.scale.x, obj.scale.y, obj.scale.z],
"visible": obj.visible_get(),
"materials": [],
}
if obj.type == "MESH":
bounding_box = get_aabb(obj)
obj_info["world_bounding_box"] = bounding_box
for slot in obj.material_slots:
if slot.material:
obj_info["materials"].append(slot.material.name)
if obj.type == "MESH" and obj.data:
mesh = obj.data
obj_info["mesh"] = {
"vertices": len(mesh.vertices),
"edges": len(mesh.edges),
"polygons": len(mesh.polygons),
}
return {"status": "success", "data": obj_info}
except Exception as e:
print(f"Error in get_object_info: {str(e)}")
traceback.print_exc()
return {"status": "error", "data": str(e)}