def _setNativeCamera( self, nativeCamera ): if type( nativeCamera ) in [ str, unicode ]: from cross3d import Scene scene = Scene() camera = scene._findNativeObject( nativeCamera ) else: camera = nativeCamera if nativeCamera: mxs.viewport.setCamera( camera ) self.refresh() return True return False
def _nativeModel( self ): """ \remarks implements the AbstractSceneObject._nativeModel method to look up the native model for this object \sa children \return <list> [ <Py3dsMax.mxs.Object> nativeObject, .. ] """ name = self.name() split = name.split( '.' ) if len( split ) > 1: modelName = split[0] from cross3d import Scene scene = Scene() return scene._findNativeObject( modelName ) return None
def _nativeModel(self): """ \remarks implements the AbstractSceneObject._nativeModel method to look up the native model for this object \sa children \return <list> [ <Py3dsMax.mxs.Object> nativeObject, .. ] """ name = self.name() split = name.split('.') if len(split) > 1: modelName = split[0] from cross3d import Scene scene = Scene() return scene._findNativeObject(modelName) return None
def exportAlembic(self, filename, **kwargs): from cross3d import Scene scene = Scene() job = {'filename': filename} job.update(**kwargs) objects = kwargs.get('objects', scene.selection()) job["objects"] = ",".join([obj.name() for obj in objects]) job['in'] = kwargs.get('in', scene.animationRange()[0]) job['out'] = kwargs.get('out', scene.animationRange()[1]) jobString = ";".join( [ "=".join([k,str(v)]) for k, v in job.iteritems()] ) return xsi.alembic_export(jobString)
def exportAlembic(self, filename, **kwargs): from cross3d import Scene scene = Scene() job = {'filename': filename} job.update(**kwargs) objects = kwargs.get('objects', scene.selection()) job["objects"] = ",".join([obj.name() for obj in objects]) job['in'] = kwargs.get('in', scene.animationRange()[0]) job['out'] = kwargs.get('out', scene.animationRange()[1]) jobString = ";".join( ["=".join([k, str(v)]) for k, v in job.iteritems()]) return xsi.alembic_export(jobString)
def _nativeCamera(self): cameraName = self.cameraName() if cameraName in self.sceneCameras: cameraName = "Views.View%s.%sCamera" % (self.name, cameraName) if cameraName == 'Render Pass': from cross3d import Scene scene = Scene() renderPass = self.scene.currentRenderPass() cameraName = renderPass.camera().name() if cameraName: return xsi.Dictionary.GetObject(cameraName) else: return None
def dispatchEvent(self, signal, *args): print 'Dispatching event', signal if ( self.signalsBlocked() ): return # emit a defined pyqtSignal if ( hasattr(Dispatch,signal) and type(getattr(Dispatch,signal)).__name__ == 'pyqtBoundSignal' ): # this should identify the object type before emiting it if it needs to emit something getattr(Dispatch,signal).emit(SceneObject(Scene.instance(), args[0])) # elif process application specific signals like xsi's value changed # otherwise emit a custom signal else: from PyQt4.QtCore import SIGNAL self.emit( SIGNAL( signal ), *args ) # emit linked signals if ( signal in self._linkedSignals ): for trigger in self._linkedSignals[signal]: self.dispatch( trigger )
def dispatchEvent(self, signal, *args): print 'Dispatching event', signal if (self.signalsBlocked()): return # emit a defined pyqtSignal if (hasattr(Dispatch, signal) and type(getattr( Dispatch, signal)).__name__ == 'pyqtBoundSignal'): # this should identify the object type before emiting it if it needs to emit something getattr(Dispatch, signal).emit(SceneObject(Scene.instance(), args[0])) # elif process application specific signals like xsi's value changed # otherwise emit a custom signal else: from PyQt4.QtCore import SIGNAL self.emit(SIGNAL(signal), *args) # emit linked signals if (signal in self._linkedSignals): for trigger in self._linkedSignals[signal]: self.dispatch(trigger)
def _nativeCamera( self ): cameraName = self.nativePointer().Camera.Value from cross3d import Scene scene = Scene() return scene.findObject( cameraName )
import sys from Py3dsMax import mxs exLibs = "C:/Python2.7.6/Lib/site-packages/" if not exLibs in sys.path: sys.path.append(exLibs) import MaxPlus from cross3d import Scene scene = Scene() print scene.currentFileName() print len(scene.objects()) for obj in scene.objects(): MaxPlus.Core.EvalMAXScript("print %s" % obj)
def fromDictionary( self, dictionary, materialType=MaterialType.Generic, mapType=MapType.Generic, ): """Creates a new material from the given dictionary. A new material is created from the description provided in the given dictionary. For more information on the structure of the dictionary expected, please see the documentation for AbstractSceneMaterial.__iter__. Args: dictionary(dict): The dictionary containing the material description. materialType(cross3d.constants.MaterialType): The type of material to create. Default is MaterialType.Generic. mapType(cross3d.constants.MapType): The type of map to use. Default if MapType.Generic. Returns: StudiomaxSceneMaterial """ name = dictionary.get('name', None) maps = dictionary.get('maps', dict()) objects = dictionary.get('objects', []) if materialType & MaterialType.VRay: mtl = mxs.VRayMtl() propMap = dict(diffuse='texmap_diffuse', ) else: mtl = mxs.StandardMaterial() propMap = dict(diffuse='diffuseMap', ) if name: mtl.name = name # We'll keep a running tab of loaders and reuse those that # point to the same files. We can also go ahead and pull # the existing loaders of the correct type from the scene # so that we can potentially reuse those, as well. mapRefs = dict() if mapType & MapType.VRay: for bm in mxs.getClassInstances(mxs.vrayhdri): mapPath = bm.HDRIMapName if mapPath: mapRefs[mapPath] = bm else: for bm in mxs.getClassInstances(mxs.bitmaptex): mapPath = bm.fileName if mapPath: mapRefs[mapPath] = bm for prop, mapPath in maps.iteritems(): if prop in propMap: # If a loader already exists for this map, then use # that rather than constructing a duplicate. if mapPath in mapRefs: bitmap = mapRefs[mapPath] elif mapType & MapType.VRay: bitmap = mxs.vrayhdri() bitmap.HDRIMapName = mapPath mapRefs[mapPath] = bitmap else: bitmap = mxs.bitmaptex() bitmap.fileName = mapPath mapRefs[mapPath] = bitmap bitmap.name = os.path.basename(mapPath) + '_{}'.format(prop) mtl.setProperty(propMap[prop], bitmap) # If we have a list of object names that the material # should be assigned to, get the object by name and do so. for objName in objects: obj = mxs.getNodeByName(objName) if obj: obj.material = mtl scn = Scene() return StudiomaxSceneMaterial(scn, mtl)
def _nativeCamera(self): cameraName = self.nativePointer().Camera.Value from cross3d import Scene scene = Scene() return scene.findObject(cameraName)