본문 바로가기

Code/cinema4d & 3dsmax

(21)
[3dsMax python] Menu & Macroscript with pymxs Menu 맥스에 맨위에 메뉴바가 있는데 여기를 코드로 수정, 추가하는 법을 알아보려고 합니다. 기존메뉴에 추가/삭제 3ds Max 2021 버전에서는 런타임 글로벌 변수를 쉽게 만들수 있지만(rt.a = 'hi'), 그 하위 버전에는 아래 코드 처럼 만들어야 합니다.ㅜㅜ (한참 찾음) 그리고 매크로 스크립트를 생성해주고, 메뉴아이템을 만들어 줍니다. from pymxs import runtime as rt import re def myfunc(): print 'Hello' rt.execute('global abcd') rt.globalVars.set('abcd', myfunc) # category, macroName, tooltip, text, function t = rt.macros.new('test'..
[c4dpython] material & texture Create material import c4d material = c4d.Material() material.SetName("Generator Material") material[c4d.MATERIAL_COLOR_COLOR] = c4d.Vector(1, 0, 0) doc.InsertMaterial(material, None) // 여기에 checknames=False 하면 중복된 재질 이름 생성 허용 c4d.EventAdd() Find Material materials = doc.GetMaterials() for mat in materials: Apply material Material를 Texture Tag를 이용해 Object 에 적용합니다. tag = c4d.TextureTag() tag.SetM..
[c4dpython] GUI GUI yes no dialog rvalue = c4d.gui.QuestionDialog("Hello") input dialog name = c4d.gui.InputDialog("input:") alert c4d.gui.MessageDialog("This document has not been previously saved, please save it now.") File Explorer (load) 이건 파일탐색기와 함께 파일이름 가져오기 import c4d fn = c4d.storage.LoadDialog() doc = c4d.documents.LoadDocument(fn.decode("utf8")) file_name = c4d.storage.LoadDialog(type=c4d.FILESELECTTY..
[c4d python] object 오브젝트 가져오기 for obj in doc.GetObjects(): children = object.GetChildren() import c4d from c4d import gui def test(): o = doc.GetActiveObject() # Only one object # o = doc.GetActiveObjects(0) # return list if not o: return o.SetName('test') c4d.EventAdd() if __name__ == '__main__': test() import c4d from c4d import gui def test(): print 'hello' o = doc.GetActiveObjects(0) if o == []: return newName ..
[c4d python] 스크립트 사용법 (+ Plugin) Cinema 4D 3D 디자이너들은 다양한 툴을 다루는것 같은데, 그중 Cinema 4D 라는 툴도 유명한것 같습니다. 우연히 기회가 생겨 Cinema 4D 플러그인을 만들어 볼려고 합니다. 😎 환경구축 자동완성이나 Lint도 있는 것 같지만, 일단 제일 기본적인 환경구축을 해볼려고 합니다. Script 탭에서 Console과 Script Manager를 킵니다. 그리고 저는 파이참에서 코딩을 하고, 파일을 Script Manager로 Open 해서 실행을 했습니다. 첫 코드! 선택한 오브젝트의 이름을 출력해보자! obj = doc.GetActiveObject() print obj.GetName() 출력이 되네요! 저 파란색부분을 드래스 해서 위에 버튼으로 만들수도 있습니다😀 하지만 두개를 클릭하면 에러..
[3dsMax python] Log Logging 모듈 print 문으로 어느 정도 로그를 남겼었지만, 스크립트를 만들어 디자이너에게 줄 경우, 로그파일이 필요해서 합니다. 참고로 맥스에 print 문이 많이 찍히게 되면 맥스가 멈춰서 한참 기다려야합니다. (무거운 파일이면 맥스가 꺼집니다) 그래서 저는 되도록이면 주요 로그는 콘솔에, 주요 로그와 세부로그는 파일로 남겨보겠습니다. 그냥 import 해서 사용하면 됩니다. 빨간 글씨로 출력이 됩니다. 하지만 default 레벨설정이 warning이여서 info 랑 debug는 출력안됩니다. import logging logging.debug("test") logging.info("test") logging.warning("test") logging.error("test") # WARNING..
[3dsMax python] GUI with pymxs 파일탐색기 Pyside2를 사용하지 않고 파일을 불러와봤습니다. from pymxs import runtime as rt path = os.path.dirname(os.path.abspath(__file__)) path_to_file = rt.getOpenFileName(caption="Open A Test Excel:", filename=path+'\\') 폴더경로를 가져올려면 아래처럼 하시면 됩니다. from pymxs import runtime as rt rtrt = rt.getSavepath() print rtrt Dialog Example wikidocs.net/35742\ max gui는 pyside2 를 사용하는데, 아주 좋은 문서가 나왔습니다. 저걸 보고 Dialog 창을 만들어봤습니다. ..
[3dsMax python] V-ray material with pymxs V-ray Renderer 이름이 V-ray 입니다. 카오스 그룹에서 만들었습니다. 한국지사도 있습니다. 저는 개발자여서 왜 Default 렌더러인 Arnold와 V-ray가 비슷해보이지만, 그래픽쪽 최전선에 있는 사람들 눈에는 "빛의 표현" 분야에서는 최고라고 합니다. V-ray 재질 생성 Vray가 깔려있다는 전제하에, 인터넷에 돌아다니는 맥스스크립트를 보고 파이썬으로 흉내를 내봤습니다. 놀랍게도 정상작동합니다 😎 from pymxs import runtime as rt if __name__ == '__main__': print 'Hi, velbie!' obj = rt.sphere() material = rt.VRayMtl() material.diffuse = rt.Color(255, 0, 0) # ..