maya python 建立求 建立Maya UI

2021-10-11 21:50:59 字數 1814 閱讀 5975

您使用的是cmds,我強烈建議您改用pymel

import pymel.core as pm

但這不是你的問題。在

問題出在邏輯上。

有乙個名為self.loadobject&;self.basename的類成員變數。這2個表示maya ui物件的名稱。執行查詢時,將使用maya ui物件的內容覆蓋這些變數。在

然後,當您再次嘗試使用這兩個物件時,maya會告訴您:runtimeerror:

"dude who the !@#$ are you talking about?"

我為我在autodesk的朋友們道歉,他們要麼因為語言粗俗而刪掉了第二行,要麼就忽略了在maya中包含乙個有用的偵錯程式。在import maya.cmds as cmds

#x=myui()

class myui:

def __init__(self):

self.title = "test ui"

self.window = cmds.window(self.title, widthheight=(1000, 600),

resizetofitchildren=1)

cmds.rowlayout("button1, button2, button3", numberofcolumns=5)

cmds.columnlayout(adjustablecolumn=true, columnalign="center",

rowspacing=10)

self.loadobjecttext = "select object and load name"

self.loadobjectfieldname = cmds.textfieldbuttongrp(label="load object name",

buttonlabel="load",

text=self.loadobjecttext,

buttoncommand=self.load)

self.basenametext = "enter basename."

self.basenamefieldname = cmds.textfieldbuttongrp(label="basename",

buttonlabel="rename",

text=self.basenametext,

buttoncommand=self.replace_name)

cmds.setparent(menu=true)

cmds.showwindow(self.window)

def load(self):

select_objects = cmds.ls(selection=true)

cmds.textfieldbuttongrp(self.loadobjectfieldname, e=true, text=select_objects[0])

def replace_name(self, *args):

self.loadobjecttext = cmds.textfieldbuttongrp(self.loadobjectfieldname,

q=true, text=true)

self.basenametext = cmds.textfieldbuttongrp(self.basenamefieldname,

q=true, text=true)

name = cmds.rename(self.loadobjecttext, self.basenametext)

ctlname = "%s_ctl" % name

self.new_name = cmds.rename(name, ctlname)

廣義表的建立,遍歷,求深度

include typedef char atomtype typedef enum elemtag atom 0,表示原子 list 1,表示子表 typedef struct glnode htp 表結點的指標域htp,包括 表頭指標域hp和表尾指標域tp atom htp atom htp 是...

建立主鍵 建立外來鍵 建立約束

建立主鍵 三種方法 建立學生表 第一種 create table student sno char 5 primary key,學號 可以直接指定主鍵 sname char 20 not null,姓名 s char 3 not null,性別 sage integer not null,年齡 sd...

Oracle建立儲存過程 建立函式 建立包

一 oracle建立儲存過程 1 基本語法 create orreplace procedureupdate emp sal name inout type,name inout type,is begin endupdate emp sal 2 寫乙個簡單的例子修改emp表的ename欄位 cre...