Este es un script para 3ds max, quiero que lo conviertas totalmente a MaxScript



# -*- coding: utf-8 -*-
import functools
import pymxs
from pymxs import runtime as rt
from PySide2 import QtWidgets, QtCore
import MaxPlus

texture_path = False

maxscript_code = '''
faces = $selection[1].EditablePoly.GetSelection #face
face_centers = #()
for face in faces do
(
    face_center = polyOp.GetFaceCenter $selection[1] face
    append face_centers face_center
)
'''

def create_material(name, diffuse_color, texture):
    material = rt.StandardMaterial()
    material.name = name

    material.diffuse = rt.color(diffuse_color[0], diffuse_color[1], diffuse_color[2])

    bitmap = rt.Bitmaptexture()
    bitmap.filename = texture

    material.diffuseMap = bitmap
    material.Specular_Level = 100

    selection = rt.selection
    for obj in selection:
        if rt.isvalidnode(obj):
            obj.material = material

    return material

def create_dummy_from_selected_object(name):
    if name:
        MaxPlus.Core.EvalMAXScript(maxscript_code)

        rt = pymxs.runtime
        coords = rt.face_centers
        coords = get_average_coordinates(coords)

        dummy = MaxPlus.Factory.CreateDummyObject()
        dummy_node = MaxPlus.Factory.CreateNode(dummy)
        dummy_node.Position = MaxPlus.Point3(coords[0], coords[1], coords[2])
        dummy_node.SetWorldScale(MaxPlus.Point3(0.015, 0.015, 0.015))
        dummy_node.SetName(name)

        rt.clearSelection()
        dummy_node.Select()

def get_average_coordinates(lista):
    num_coords = len(lista)
    add_x = sum(coords[0] for coords in lista)
    add_y = sum(coords[1] for coords in lista)
    add_z = sum(coords[2] for coords in lista)

    promedio_x = add_x / num_coords
    promedio_y = add_y / num_coords
    promedio_z = add_z / num_coords

    return [promedio_x, promedio_y, promedio_z]

def select_damn():
    MaxPlus.Core.EvalMAXScript('''
    for obj in objects do
    (
        if (matchPattern obj.name pattern:"*_dam") or (matchPattern obj.name pattern:"*_vlo") do
        (
            selectMore obj
        )
    )
    ''')

def open_file_dialog():
    file_dialog = QtWidgets.QFileDialog()
    file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
    file_dialog.setNameFilter("Images (*.png *.jpg *.tga *.dds *.jpeg)")
    if file_dialog.exec_():
        file_path = file_dialog.selectedFiles()[0]
        button3.setText(file_path.split("/")[-1])

        print("Loaded image: "+file_path)

        global texture_path
        texture_path = file_path

def show_alert(title, icon, message):
    app = QtWidgets.QApplication.instance()
    if app is None:
        app = QtWidgets.QApplication([])
    message_box = QtWidgets.QMessageBox(parent=widget)
    message_box.setText(str(message))
    message_box.setWindowTitle(title)
    if icon:
        message_box.setIcon(QtWidgets.QMessageBox.Information)
    message_box.exec_()
	

botones1 = {
    "head_l": ["255,175,1",False],
    "head_r": ["1,255,200",False],
    "indicatorf_l": ["255,174,1","indicatorsf"],
    "indicatorf_r": ["1,255,199","indicatorsf"],
    "fogf_l": ["255,173,1","foglightsf"],
    "fogf_r": ["1,255,198","foglightsf"],
    "parkf_l": ["255,171,1","parklightsf"],
    "parkf_r": ["1,255,196","parklightsf"],
}

botones2 = {
    "indicator_l": ["1,195,255","indicators"],
    "indicator_r": ["120,1,255","indicators"],
    "tail_l": ["185,255,1","taillights"],
    "tail_r": ["255,60,1","taillights"],
    "brake_l": ["184,255,1","brakelights"],
    "brake_r": ["255,59,1","brakelights"],
    "reverse_l": ["183,255,1","reverselights"],
    "reverse_r": ["255,58,1","reverselights"],
    "indicatorr_l": ["182,255,1","indicatorsr"],
    "indicatorr_r": ["255,57,1","indicatorsr"],
    "fogr_l": ["181,255,1","foglightsr"],
    "fogr_r": ["255,56,1","foglightsr"],
}


botones = {}
botones.update(botones1)
botones.update(botones2)

def button_clicked(button_name):
    selection = pymxs.runtime.selection
    if len(selection) > 0:
        if str(pymxs.runtime.classof(selection[0])) == "Editable_Poly":
            diffuse_color = [int(c) for c in botones[button_name][0].split(",")]
            dummy_name = botones[button_name][1]
            material_name = button_name
            texture = texture_path

            if texture:
                create_material(material_name, diffuse_color, texture)
                create_dummy_from_selected_object(dummy_name)
            else:
                show_alert("Error", True, "Please select a texture")
                print("ERROR: No texture")
        else:
            show_alert("Error", True, "No Editable Poly")
    else:
        show_alert("Error", True, "Select an object")


app = None
if not QtWidgets.QApplication.instance():
    app = QtWidgets.QApplication([])

widget = QtWidgets.QWidget()
widget.setWindowTitle("Tools")
widget.setFixedSize(250, 350)
widget.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

layout = QtWidgets.QGridLayout(widget)

column_count = 2
button_count = 0

layout.addWidget(QtWidgets.QLabel('  front:'))
button_count += 2

for button_name in sorted(botones1.keys()):
    button = QtWidgets.QPushButton(button_name)
    button.clicked.connect(functools.partial(button_clicked, button_name))

    row = button_count // column_count
    column = button_count % column_count

    layout.addWidget(button, row, column)
    button_count += 1

layout.addWidget(QtWidgets.QLabel('  rear / others:'))
button_count += 2

for button_name in sorted(botones2.keys()):
    button = QtWidgets.QPushButton(button_name)
    button.clicked.connect(functools.partial(button_clicked, button_name))

    row = button_count // column_count
    column = button_count % column_count

    layout.addWidget(button, row, column)
    button_count += 1

for i in range(1,3):
    layout.addWidget(QtWidgets.QFrame())

button2 = QtWidgets.QPushButton("Select dam/vlo")
layout.addWidget(button2)

button2.clicked.connect(lambda: select_damn())

button3 = QtWidgets.QPushButton("Select texture")
button3.clicked.connect(lambda: open_file_dialog())
layout.addWidget(button3)

button4 = QtWidgets.QPushButton("Info")
button4.clicked.connect(lambda: show_alert("Error", False, "made by Weaita"))
layout.addWidget(button4)

widget.show()

if app:
    app.exec_()