본문 바로가기

Programming/cinema4d & 3dsmax

(20)
[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) # ..
[3dsMax python] Material with pymxs 모든 재질 가져오기 아래코드를 사용하면 Slate Material Editor에서 Scene Materials 에 모든정보를 가져옵니다. 😎 특정재질을 찾으려면 for문에서 이름만 비교하면 됩니다. 특정재질을 복사하려면 주석부분을 풀면됩니다. import pymxs for m in pymxs.runtime.scenematerials: print m # m2 = pymxs.runtime.copy(m) 재질의 맵에 접근하기 재질은 map을 가지고 있습니다. 그중 Diffuse map에 접근하는 방법입니다. 그렇다면 다른 map에는 어떻게 접근할까요? (이 문서를 참고해주세요) import pymxs for material in pymxs.runtime.scenematerials: print material...