import maya.cmds as cmds def straighten_cylinder_uv(cylinder_name): cmds.select(cylinder_name) cmds.polyProjection(cylinder_name + '.f[*]', type='Cylindrical', ch=True, ibd=True) cmds.u3dLayout(cylinder_name, res=1024, scl=1, flipReversed=True) cmds.delete(cylinder_name, ch=True) # Replace 'yourCylinderName' with the name of your cylinder straighten_cylinder_uv('yourCylinderName')
import maya.cmds as cmds
def export_model():
# 步骤一:获取物体的坐标信息和缩放值
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("请选择要处理的物体")
return
for obj in selected_objects:
# 获取物体的坐标信息
translation = cmds.xform(obj, query=True, translation=True, worldSpace=True)
rotation = cmds.xform(obj, query=True, rotation=True, worldSpace=True)
scale = cmds.xform(obj, query=True, scale=True, worldSpace=True)
print(f"物体 {obj} 的坐标信息:Translation {translation}, Rotation {rotation}, Scale {scale}")
# 步骤二:将物体坐标设置到世界中心
cmds.xform(obj, translation=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], worldSpace=True)
# 步骤三:删除物体的操作历史
cmds.delete(obj, constructionHistory=True)
# 步骤四:导出模型
export_path = "/your/export/path/" + obj + ".obj"
cmds.file(export_path, force=True, options="groups=1;ptgroups=1;materials=1;smoothing=1;normals=1", type="OBJexport", exportSelected=True)
print(f"物体 {obj} 导出成功,文件路径:{export_path}")
# 执行插件功能
export_model()
import maya.cmds as cmds
import random
def randomize_transforms(scale_min=0.8, scale_max=1.2, rotation_range=360):
selected_objects = cmds.ls(selection=True)
for obj in selected_objects:
random_scale = random.uniform(scale_min, scale_max)
cmds.scale(random_scale, random_scale, random_scale, obj)
random_rotation = [random.uniform(-rotation_range, rotation_range) for _ in range(3)]
cmds.rotate(random_rotation[0], random_rotation[1], random_rotation[2], obj)
randomize_transforms()
import maya.cmds as cmds
def straighten_cylinder_uv(cylinder_name):
cmds.select(cylinder_name)
cmds.polyProjection(cylinder_name + '.f[*]', type='Cylindrical', ch=True, ibd=True)
cmds.u3dLayout(cylinder_name, res=1024, scl=1, flipReversed=True)
cmds.delete(cylinder_name, ch=True)
# Replace 'yourCylinderName' with the name of your cylinder
straighten_cylinder_uv('yourCylinderName')
import maya.cmds as cmds
def process_objects():
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("Please select objects to process")
return
for obj in selected_objects:
translation = cmds.xform(obj, query=True, translation=True, worldSpace=True)
rotation = cmds.xform(obj, query=True, rotation=True, worldSpace=True)
scale = cmds.xform(obj, query=True, scale=True, worldSpace=True)
cmds.delete(obj, constructionHistory=True)
print(f"Object {obj} processed successfully. Coordinates: Translation {translation}, Rotation {rotation}, Scale {scale}")
# Execute the plugin functionality
process_objects()
import maya.cmds as cmds
def process_objects():
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("Please select objects to process")
return
for obj in selected_objects:
translation = cmds.xform(obj, query=True, translation=True, worldSpace=True)
rotation = cmds.xform(obj, query=True, rotation=True, worldSpace=True)
scale = cmds.xform(obj, query=True, scale=True, worldSpace=True)
cmds.xform(obj, translation=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], worldSpace=True)
cmds.delete(obj, constructionHistory=True)
print(f"Object {obj} processed successfully")
# Execute the plugin functionality
process_objects()
import maya.cmds as cmds
def process_objects():
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("Please select objects to process")
return
for obj in selected_objects:
initial_scale = cmds.getAttr(obj + ".scale")[0]
cmds.xform(obj, centerPivots=True)
cmds.setAttr(obj + ".scale", 1, 1, 1)
cmds.delete(obj, constructionHistory=True)
print(f"Object {obj} processed successfully. Initial Scale: {initial_scale}")
# Execute the plugin functionality
process_objects()
a
for ($obj in `ls -sl`)
{
string $transform = `createNode transform -n ($obj+"_GEO")`;
parent -s -r $obj $transform;
} 曲线分割
import maya.cmds as cmds
def process_objects():
# 步骤一:获取物体的坐标信息和缩放值
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("请选择要处理的物体")
return
for obj in selected_objects:
# 获取物体的坐标信息
translation = cmds.xform(obj, query=True, translation=True, worldSpace=True)
rotation = cmds.xform(obj, query=True, rotation=True, worldSpace=True)
scale = cmds.xform(obj, query=True, scale=True, worldSpace=True)
print(f"物体 {obj} 的坐标信息:Translation {translation}, Rotation {rotation}, Scale {scale}")
# 步骤二:将物体坐标设置到世界中心
cmds.xform(obj, translation=[0, 0, 0], rotation=[0, 0, 0], scale=[1, 1, 1], worldSpace=True)
# 步骤三:删除物体的操作历史
cmds.delete(obj, constructionHistory=True)
print(f"物体 {obj} 处理完成")
# 执行插件功能
process_objects()
import maya.cmds as cmds
def process_objects():
selected_objects = cmds.ls(selection=True)
if not selected_objects:
print("Please select objects to process")
return
for obj in selected_objects:
current_scale = cmds.getAttr(obj + ".scale")[0]
cmds.xform(obj, centerPivots=True)
cmds.setAttr(obj + ".scale", 1, 1, 1)
cmds.delete(obj, constructionHistory=True)
print(f"Object {obj} processed successfully. Current Scale: {current_scale}")
# Execute the plugin functionality
process_objects()