회원 로그인
|
Python Plug-in 시작하기
- 파이썬 플러그인 기본 프레임
# -*- coding:euc-kr -*_ # https://www.youtube.com/watch?v=Wf03mSCdh-Q import sys import maya.OpenMaya as OpenMaya # 플러그인 생성하는데 필요 모듈(MPx 접두사가 붙는 프록시 클래스라고 함) # 이러한 클래스 중 하나에서 상속함으로써 자체 클래스가 마야 내에서 특정 역할을 채택할 수 있다. # 유형에는 커맨드(MPxCommand), 디포머, 셰이더, 일반 노드가 포함된다. import maya.OpenMayaMPx as OpenMayaMPx commandName = 'hello' # maya.cmds의 함수명 결정 #명령을 생성하기 때문에 사용자 정의 클래스 MyCommandClass()는 OpenMayaMPx.MPxCommand 상속 class MyCommandClass(OpenMayaMPx.MPxCommand): # 사용자 정의 클래스의 생성자 __init__() 함수는 MPxCommand 기본 클래스에서 __init__()를 호출해야 한다. # 유형에 따라 MPx 프록시 클래스의 __init__()를 호출한다. def __init__(self): ''' Constructor ''' OpenMayaMPx.MPxCommand.__init__(self) def doIt(self, args): ''' Command execution. ''' print('hello world') pass # 명령 인스턴스를 생성하는 기능을 참조(플러그인 로드할 때 인수로) def cmdCreator(): ''' Create on instance of our command. ''' # MyCommandClass()를 호출하여 파이썬 인스턴스를 C++ 포인터로 마야에 전달 return OpenMayaMPx.asMPxPtr(MyCommandClass()) # 플러그인 로드 def initializePlugin(mobject): ''' Initialize the plug-in when Maya loads it. ''' mplugin = OpenMayaMPx.MFnPlugin(mobject, 'vendor', '1.0', 'Any') try: # 마야 registerCommand 호출하여 등록 mplugin.registerCommand(commandName, cmdCreator) # except: sys.stderr.write('Failed to register command: ' + commandName) # 플러그인 언로드 def uninitializePlugin(mobject): ''' Uninitialize the plug-in when Maya un-loads it. ''' mplugin = OpenMayaMPx.MFnPlugin(mobject) try: mplugin.deregisterCommand(commandName) # 명령 이름만 인수로 호출 except: sys.stderr.write('Failed to unregister command: ' + commandName) ''' OpenMaya에 프록시 클래스 말고도 다양한 모듈이 있다. MFnMesh, MFnLight, MFnCamera, MFnTransform, MVector 등과 같이 범용 클래스와 함수가 포함되어 있다. '''
참고
https://www.youtube.com/watch?v=Wf03mSCdh-Q
댓글 0개
| 엮인글 0개
466개(2/24페이지)
번호 | 제목 | 글쓴이 | 조회 | 날짜 |
---|---|---|---|---|
마야 뷰포트 네비게이션 팁 | 푸딩뱃살 | 42803 | 2020.04.06 17:22 | |
Maya 버전 별 Python 버전 | 푸딩뱃살 | 64118 | 2014.01.08 17:59 | |
444 | [Base] 스냅할 때 크러쉬 | 푸딩뱃살 | 860 | 2021.11.12 18:43 |
443 | [Base] 뷰포트에 빨간 테두리에 Paused | 푸딩뱃살 | 1251 | 2021.11.12 01:03 |
442 | [Modeling] 쉐이딩 프리뷰(6키)에서 메시가 검게 나오는 | 푸딩뱃살 | 1108 | 2021.11.08 12:03 |
441 | [Script] Internal C++ object (PySide2.QtWidgets.QMainWindow) alre | 푸딩뱃살 | 1271 | 2021.11.03 16:54 |
440 | [Base] Missing OpenColorIO configuration file | 푸딩뱃살 | 1166 | 2021.10.29 16:39 |
439 | [오류] Bind method Geodesic Voxel로 사용하면 에러 | 푸딩뱃살 | 1016 | 2021.10.26 15:08 |
438 | [Modeling] Retopologize 실패 | 푸딩뱃살 | 949 | 2021.10.22 15:47 |
437 | [Script] 마야 QT 메인 윈도우 찾기 | 푸딩뱃살 | 1288 | 2021.10.18 11:49 |
436 | [Rigging] Quick Rig - Embed Method | 푸딩뱃살 | 907 | 2021.10.13 17:58 |
435 | [Base] 마야 2022 설치 완료 후 실행 시 | 푸딩뱃살 | 805 | 2021.10.12 21:48 |
434 | [오류] shiboken2 에러 | 푸딩뱃살 | 1108 | 2021.10.06 18:04 |
433 | [Base] Maya2022 Python3에서 pymel 설치해서 사용해야 함 | 푸딩뱃살 | 1220 | 2021.10.06 17:13 |
432 | [오류] maya 2020 실행 시 에러 | 푸딩뱃살 | 890 | 2021.10.05 10:28 |
431 | [오류] 마야 바이러스 - Virus.MEL.Vacphage | 푸딩뱃살 | 1020 | 2021.08.25 11:16 |
430 | [Base] 마야 2022에서 파이썬 2.7 사용 | 푸딩뱃살 | 966 | 2021.08.19 23:11 |
429 | [오류] Flagged Script - Security Warning | 푸딩뱃살 | 1203 | 2021.08.16 15:26 |
>> | [Dev] Python Plug-in 시작하기 | 푸딩뱃살 | 1004 | 2021.08.01 02:06 |
427 | [Base] Maya 환경 설정 / 모듈 설정 | 푸딩뱃살 | 1388 | 2021.07.31 16:22 |
426 | [Script] maya pip 사용 | 푸딩뱃살 | 1446 | 2021.06.01 19:22 |
425 | [오류] PhysX 크러쉬 | 푸딩뱃살 | 919 | 2021.05.21 11:22 |