회원 로그인
|
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개(1/24페이지)
번호 | 제목 | 글쓴이 | 조회 | 날짜 |
---|---|---|---|---|
마야 뷰포트 네비게이션 팁 | 푸딩뱃살 | 43191 | 2020.04.06 17:22 | |
Maya 버전 별 Python 버전 | 푸딩뱃살 | 64469 | 2014.01.08 17:59 | |
464 | [Dev] Autodesk Maya Devkit 다운로드 | 푸딩뱃살 | 694 | 2023.01.28 14:28 |
463 | [Base] (해결 중) modules 환경설정 중 | 푸딩뱃살 | 636 | 2022.11.09 11:47 |
462 | [Script] pymel 딕셔너리형 사용 시 KeyError | 푸딩뱃살 | 847 | 2022.11.07 12:08 |
461 | [오류] Building Numpy for Maya Python 2.7.x | 푸딩뱃살 | 589 | 2022.10.23 14:38 |
460 | [Base] 뷰포트에서 조절자가 안 보일때 | 푸딩뱃살 | 773 | 2022.10.13 15:47 |
459 | [Rigging] mirror joints 사용 시 유의 사항 | 푸딩뱃살 | 785 | 2022.10.04 10:46 |
458 | [Script] 2022에서 enum34 모듈 설치 금지 | 푸딩뱃살 | 594 | 2022.08.17 18:08 |
457 | [Script] pymel 예제 | 푸딩뱃살 | 614 | 2022.07.05 19:20 |
456 | [Script] 인코드 / 디코드 - 2.7 한글 사용 | 푸딩뱃살 | 893 | 2022.03.08 17:52 |
455 | [Dev] ui 없이 mayapy로 자동화 | 푸딩뱃살 | 694 | 2022.02.17 13:56 |
454 | [Dev] mayapy로 ui파일 py로 | 푸딩뱃살 | 522 | 2022.02.15 18:20 |
453 | [오류] Error : MayaBonusTools | 푸딩뱃살 | 907 | 2022.01.21 17:52 |
452 | [오류] Error: ModuleNotFoundError | 푸딩뱃살 | 760 | 2022.01.21 16:24 |
451 | [Dev] mayapy | 푸딩뱃살 | 637 | 2022.01.19 20:08 |
450 | [Base] function selCom at 0x7f29c5c04aa0 | 푸딩뱃살 | 603 | 2022.01.19 17:24 |
449 | [Base] wireframe on shaded 단축키 만들기 | 푸딩뱃살 | 905 | 2022.01.04 10:55 |
448 | [오류] OpenCL Error | 푸딩뱃살 | 515 | 2021.12.28 01:40 |
447 | [Script] Easily Translate MEL Commands to Python | 푸딩뱃살 | 817 | 2021.12.02 11:22 |
446 | [Base] output window 띄우지 않기 | 푸딩뱃살 | 812 | 2021.11.24 21:44 |
445 | [Rigging] shapeEditorManager 삭제 안됨 | 푸딩뱃살 | 883 | 2021.11.12 23:30 |