日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Maya 搭建PyCharm 插件开发环境

發(fā)布時間:2024/1/1 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Maya 搭建PyCharm 插件开发环境 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在新版本的maya安裝目錄是包含了Pymel庫,路徑:D:\Autodesk\Maya2019\Python\Lib\site-packages,在配置Pycharm的第三方lib的時候可以直接添加這個路徑。

1.在Pycharm編輯器添加擴展工具,QtDenginer 和 生成Qtpy的pySide2_uic

?

1.1Qt Designers的配置

Name:QtDesiginer

Program:? D:\Autodesk\Maya2019\bin\designer.exe

Arguments:$FileDir$\$FileName$

Wording directory:$ProjectFileDir$

1.2 PyUIC的配置

pyuic是Qt提供的一個吧.ui的界面文件,轉(zhuǎn)成python的文件。

Name:PyUIC

Program:? “C:\Program Files\Autodesk\Maya2019\bin\mayapy.exe”

Arguments:"C:\Program Files\Autodesk\Maya2019\bin\pyside2-uic" -o $FileDir$\$FileNameWithoutExtension$.py $FileDir$\$FileName$

Wording directory:$ProjectFileDir$

這里由于是Maya2019,通過mayapy來啟動一個pyside2-uic?這個DLL文件來執(zhí)行命令,如果有pyside2-uic.exe 就把執(zhí)行程序換成pyside2-uic.exe

-o 后面接輸出文件名字?

$FileName$ 選擇的源文件名字

?

ps:如果路徑有空格,使用引號括起來

2.編輯一個界面

?

然后使用PyUIC對保存的cone.ui進行處理生成cone.py

# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'cone.ui' # # Created: Mon Jul 22 12:21:47 2019 # by: pyside2-uic running on PySide2 2.0.0~alpha0 # # WARNING! All changes made in this file will be lost!from PySide2 import QtCore, QtGui, QtWidgetsclass Ui_ar_conePtrWindow(object):def setupUi(self, ar_conePtrWindow):ar_conePtrWindow.setObjectName("ar_conePtrWindow")ar_conePtrWindow.resize(376, 188)self.label = QtWidgets.QLabel(ar_conePtrWindow)self.label.setGeometry(QtCore.QRect(30, 30, 111, 41))font = QtGui.QFont()font.setPointSize(15)self.label.setFont(font)self.label.setObjectName("label")self.inputRotation = QtWidgets.QLineEdit(ar_conePtrWindow)self.inputRotation.setGeometry(QtCore.QRect(140, 40, 113, 20))self.inputRotation.setObjectName("inputRotation")self.pushButton = QtWidgets.QPushButton(ar_conePtrWindow)self.pushButton.setGeometry(QtCore.QRect(140, 130, 75, 23))self.pushButton.setObjectName("pushButton")self.retranslateUi(ar_conePtrWindow)QtCore.QMetaObject.connectSlotsByName(ar_conePtrWindow)def retranslateUi(self, ar_conePtrWindow):ar_conePtrWindow.setWindowTitle(QtWidgets.QApplication.translate("ar_conePtrWindow", "Form", None, -1))self.label.setText(QtWidgets.QApplication.translate("ar_conePtrWindow", "Y-Rotation", None, -1))self.pushButton.setText(QtWidgets.QApplication.translate("ar_conePtrWindow", "Create Cone", None, -1))

這就是生成的cone.py。相當于工具自動把界面代碼生成出來了,然后只需要引入調(diào)用即可。

3.代碼控制界面

#-*- coding: UTF-8 -*- import sys from PySide2.QtWidgets import * import os sys.path.append(os.path.expanduser('~/maya/scripts')) import Cone reload(Cone)class AR_QtConePtrWindow(QWidget):def __init__(self):super(AR_QtConePtrWindow, self).__init__()self.ui = Cone.Ui_ar_conePtrWindow()self.ui.setupUi(self)self.ui.pushButton.clicked.connect(self.onCreateCone)def onCreateCone(self):rotaVale = self.ui.inputRotation.text()print("Rota Value:%f" % rotaVale)if __name__ == "__main__":# app = QApplication(sys.argv)window = AR_QtConePtrWindow()window.show()# sys.exit(app.exec_())

?

Qt界面的內(nèi)容,可以Google查PySide2找到類的說明,如果是信號,在Python 就可以通過connect來連接一個函數(shù),如上面的clicked就是一個信號。如果是虛函數(shù),可以在這里直接重寫。

如果Py帶中文內(nèi)容,加上#-*- coding: UTF-8 -*-

?

代碼拷貝到插件目錄,也就是Documents下面的Maya目錄:C:\Users\Dell\Documents\maya\scripts

然后在MAYA命令窗口執(zhí)行窗口那個文件的代碼:

?

reload 很關(guān)鍵,自己寫的代碼都要用這個,否則修改的內(nèi)容不能再當前狀態(tài)下生效,只能退出Maya編輯器再打開來重新加載。有了reload執(zhí)行重新打開下我們開發(fā)的工具界面就又重新加載了

總結(jié)

以上是生活随笔為你收集整理的Maya 搭建PyCharm 插件开发环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。