def create_expose_transform( pos=None, size=1.0, is_center_marker=True, is_axis_tripod=False, is_cross=False, is_box=False, color=None): """ Creates a new expose transform node in the scene :param pos: :param size: :param is_center_marker: :param is_axis_tripod: :param is_cross: :param is_box: :param color: :return: """ pos = pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.green expose_transform = rt.ExposeTM( pos=pos, size=size, centermarker=is_center_marker, axistripod=is_axis_tripod, cross=is_cross, box=is_box) expose_transform.wirecolor = color return expose_transform
def create_gizmo_control(name, init_pos=None, radius=10, color=None): """ Creates a gizmo control :param name: str :param init_pos: :param radius: :param color: :return: """ pos = init_pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.yellow circle_a = create_circle_control(name=name, radius=radius, color=color, init_pos=pos, axis='x') circle_b = create_circle_control(name=name, radius=radius, color=color, init_pos=pos, axis='y') circle_c = create_circle_control(name=name, radius=radius, color=color, init_pos=pos, axis='z') gizmo_ctrl = add_shape(circle_a, circle_b) gizmo_ctrl = add_shape(gizmo_ctrl, circle_c) return gizmo_ctrl
def freeze_transform(node_name): """ Freezes the transform for the given node :param node_name: str """ node = node_utils.get_pymxs_node(node_name) rotation_controller = rt.getPropertyController(node.controller, 'Rotation') position_controller = rt.getPropertyController(node.controller, 'Position') if rt.classOf(rotation_controller) != rt.Rotation_Layer: rotation_list_controller = rt.Rotation_List() rt.setPropertyController(node.controller, 'Rotation', rotation_list_controller) rt.setPropertyController(rotation_list_controller, 'Available', rt.Euler_Xyz()) rotation_list_controller.setName(1, 'Frozen Rotation') rotation_list_controller.setName(2, 'Zero Euler XYZ') rotation_list_controller.setActive(2) if rt.classOf(position_controller) != rt.Position_Layer: position_list_controller = rt.Position_List() rt.setPropertyController(node.controller, 'Position', position_list_controller) pos_xyz_controller = rt.Position_XYZ() rt.setPropertyController(position_list_controller, 'Available', pos_xyz_controller) position_list_controller.setName(1, 'Frozen Position') position_list_controller.setName(2, 'Zero Pos XYZ') position_list_controller.setActive(2) pos_xyz_controller.x_Position = 0 pos_xyz_controller.y_Position = 0 pos_xyz_controller.z_Position = 0
def create_circle_control(name, init_pos=None, radius=10, color=None, axis='z'): """ Creates a circle control :param name: str :param init_pos: list(float, float, float) or None :param radius: float :param color: list(float, float, float) or rt.Point3 :param axis: str """ pos = init_pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.yellow rt.setCommandPanelTaskMode(rt.Name('modify')) ctrl_name = rt.uniquename(name) base_circle = rt.circle(name=ctrl_name, radius=radius, steps=6, pos=pos) if str(axis).lower() == 'x': xform_mod = rt.xform() rt.addModifier(base_circle, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(0, 90, 0)) elif str(axis).lower() == 'y': xform_mod = rt.xform() rt.addModifier(base_circle, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(90, 0, 0)) base_circle.wirecolor = color rt.convertTo(base_circle, rt.SplineShape) return base_circle
def getIDFromMaterial(multiMat, mat): if rt.classOf(multiMat) == rt.MultiMaterial: matList = list(multiMat.materialList) for i in range(len(matList)): if multiMat.materialList[i].name == mat.name: return multiMat.materialIDList[i] return -1
def getMaterialByFaceID(multiMat, ID): if rt.classOf(multiMat) == rt.MultiMaterial: matIdList = list(multiMat.materialIDList) for i in range(len(matIdList)): if multiMat.materialIDList[i] == ID: return multiMat.materialList[i] return None
def assignMatToMutliMat(multiMat, mat): if rt.classOf(multiMat) == rt.MultiMaterial: if multiMat.material1 is None: multiMat.material1 = mat else: multiMat.numsubs = multiMat.numsubs + 1 multiMat.materialList[multiMat.numsubs - 1] = mat
def removeMod(self): item = self.lw_skiin.selectedItems() allowed = mxs.readvalue(mxs.StringStream('Skin')) if mxs.classOf(mxs.modPanel.getCurrentObject()) == allowed: try: node = mxs.selection[0] mod = mxs.modPanel.getCurrentObject() modID = mxs.modPanel.getModifierIndex(mxs.selection[0], mod) if [node, mod, modID] in self.skinMeshes: print(self.skinMeshes) self.skinMeshes.remove([node, mod, modID]) self.lw_skiin.takeItem(self.lw_skiin.row(item[0])) print(self.skinMeshes) else: pass except: pass else: pass
def isMatInMultiMat(multiMat, mat): if rt.classOf(multiMat) == rt.MultiMaterial: if multiMat.material1 is None: return False for m in multiMat.materialList: if m.name == mat.name: return True return False
def convertToMesh(self): if not self.useAlpha_chb.isChecked() and not self.isValidTexture( self.texturePath): self.info_lbl = "Specified texture is missing or not found" return subdivideMod = rt.subdivide() volSel = rt.Vol__Select() for o in rt.selection: texturePath = self.texturePath if self.useAlpha_chb.isChecked(): mat = o.material if rt.classOf(mat) == rt.FlightSim: texturePath = mat.BaseColorTex elif rt.classOf(mat) == rt.Standardmaterial: texturePath = mat.opacityMap.filename else: self.info_lbl = "Currently only FlightSim material are supported" continue if not os.path.isabs(texturePath): texturePath = os.path.join( rt.pathConfig.getCurrentProjectFolder(), texturePath) if not self.isValidTexture(texturePath): continue p = rt.convertToPoly(o) rt.addModifier(o, subdivideMod) subdivideMod.size = 0.001 rt.convertTo(o, rt.editable_poly) #hack adding the modifier only one time do not work for first object in iteration WTF? rt.addModifier(o, subdivideMod) subdivideMod.size = 0.001 rt.convertTo(o, rt.editable_poly) rt.addModifier(p, volSel) volSel.level = 1 volSel.invert = True bitmap = rt.Bitmaptexture(filename=texturePath) volSel.texture = bitmap volSel.method = 0 volSel.volume = 4 p = rt.convertToPoly(o) rt.subObjectLevel = 1 p.delete(pymxs.runtime.Name("Vertex")) rt.convertTo(o, rt.editable_poly)
def UseLegacyShader(): multimats = list(filter(lambda m: rt.classOf(m) == rt.MultiMaterial, rt.sceneMaterials)) flightSimMats = list(filter(lambda m: rt.ClassOf(m) == rt.FlightSim, rt.sceneMaterials)) for multi in multimats: for m in multi.materialList: if rt.ClassOf(m) == rt.FlightSim: flightSimMats.append(m) for mat in flightSimMats: mat.setShaderTechniqueByName("Tech_Legacy")
def create_box_control(name, init_pos=None, length=10, width=10, height=10, color=None): """ Creates a box control :param name: str :param init_pos: :param length: :param width: :param height: :param color: :return: """ pos = init_pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.yellow rt.setCommandPanelTaskMode(rt.Name('modify')) base_box = rt.Box( lengthsegs=1, widthsegs=1, heightsegs=1, length=length, width=width, height=height, mapcoords=True, pos=pos, isSelected=True) rt.select(base_box) rt.convertTo(base_box, rt.PolyMeshObject) rt.subobjectLevel = 2 edge_bitarray = rt.BitArray() edge_indices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] edge_bitarray.count = len(edge_indices) for i, index in enumerate(edge_indices): edge_bitarray[i] = index base_box.EditablePoly.SetSelection(rt.Name('Edge'), edge_bitarray) ctrl_name = rt.uniquename(name) base_box.EditablePoly.createShape(ctrl_name, False, base_box) rt.subobjectLevel = 0 rt.delete(base_box) box_ctrl = rt.getNodeByName(ctrl_name) rt.convertTo(box_ctrl, rt.SplineShape) box_ctrl.wirecolor = color rt.CenterPivot(box_ctrl) transform.reset_xform_and_collapse(box_ctrl, freeze=True) return box_ctrl
def draw_line_between_two_points(point_a, point_b): """ Draws a spline curve where point_a is its starting point and point_b its end point :param point_a: list(float, float, float) or rt.Point3 :param point_b: list(float, float, float) or rt.Point3 :return: str, name of the new spline """ if rt.classOf(point_a) != rt.Point3: point_a = rt.Point3(*point_a) if rt.classOf(point_b) != rt.Point3: point_b = rt.Point3(*point_b) spline = rt.SplineShape(pos=point_a) rt.addNewSpline(spline) rt.addKnot(spline, 1, rt.Name('corner'), rt.Name('line'), point_a) rt.addKnot(spline, 1, rt.Name('corner'), rt.Name('line'), point_b) rt.updateShape(spline) return spline
def create_circle_with_triangle_control(name, init_pos=None, radius=10, corner_radius=0, color=None, axis='z'): """ Creates a circle with a triangle inside control :param name: str :param init_pos: :param radius: :param corner_radius: :param color: :param axis: :return: """ pos = init_pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.yellow circle_ctrl = create_circle_control(name, init_pos=pos, radius=radius, color=color, axis=axis) triangle_ctrl = rt.Ngon( radius=radius, cornerRadius=corner_radius, nsides=3, circular=False, scribe=1, pos=pos, isSelected=True) xform_mod = rt.xform() rt.addModifier(triangle_ctrl, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(0, 0, -90)) if str(axis).lower() == 'x': xform_mod = rt.xform() rt.addModifier(triangle_ctrl, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(0, -90, 0)) elif str(axis).lower() == 'y': xform_mod = rt.xform() rt.addModifier(triangle_ctrl, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(-90, 0, 0)) final_ctrl = add_shape(circle_ctrl, triangle_ctrl) return final_ctrl
def SetIBLmaps(radianceMap, irradianceMap): multimats = filter(lambda m: rt.classOf(m) == rt.MultiMaterial, rt.sceneMaterials) flightSimMats = filter(lambda m: rt.ClassOf(m) == rt.FlightSim, rt.sceneMaterials) if(MAXVERSION() >= MAX2021): multimats = list(multimats) flightSimMats = list(flightSimMats) for multi in multimats: for m in multi.materialList: if rt.ClassOf(m) == rt.FlightSim: flightSimMats.append(m) for mat in flightSimMats: mat.loadShader() mat.radianceMap = radianceMap mat.irradianceMap = irradianceMap
def create_rectangle_control(name, init_pos=None, length=10.0, width=10.0, corner_radius=0.0, color=None, axis='z'): """ Creates a rectangle control :param name: str :param init_pos: :param length: :param width: :param corner_radius: :param color: :param axis: :return: """ pos = init_pos or [0, 0, 0] if rt.classOf(pos) != rt.Point3: pos = rt.Point3(*pos) if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.yellow rt.setCommandPanelTaskMode(rt.Name('modify')) ctrl_name = rt.uniquename(name) base_rectangle = rt.rectangle(name=ctrl_name, length=length, width=width, cornerRadius=corner_radius, pos=pos) base_rectangle.wirecolor = color if str(axis).lower() == 'x': xform_mod = rt.xform() rt.addModifier(base_rectangle, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(0, 90, 0)) elif str(axis).lower() == 'y': xform_mod = rt.xform() rt.addModifier(base_rectangle, xform_mod) rt.setProperty(xform_mod.gizmo, 'rotation', rt.eulerAngles(90, 0, 0)) rt.convertTo(base_rectangle, rt.SplineShape) return base_rectangle
def updateParallax(): multimats = filter(lambda m: rt.classOf(m) == rt.MultiMaterial, rt.sceneMaterials) flightSimMats = filter(lambda m: rt.ClassOf(m) == rt.FlightSim, rt.sceneMaterials) for multi in multimats: for m in multi.materialList: if rt.ClassOf(m) == rt.FlightSim: flightSimMats.append(m) for mat in flightSimMats: if mat.materialTYpe == 8: heightmapPath = mat.HeightmapTex if heightmapPath: mat.corridor = True mat.HeightmapTex = "" print("{0} has been update".format(mat.name))
def runEmptyNodeCleaner(): sceneNodes = [] sceneNodes = node.getAllNodes() NodesToRemove = [] for sn in sceneNodes: cl = rt.classOf(sn) if cl == rt.Editable_Poly or cl == rt.Editable_Mesh: NF = sn.numfaces if NF <= 0: NodesToRemove.append(sn) for NTR in NodesToRemove: print("{0} was deleted because it was not containing any geometry". format(NTR)) rt.delete(NTR)
def filter(input): new = [] allowed = [] allowed.append(mxs.readvalue(mxs.StringStream('CATBone'))) allowed.append(mxs.readvalue(mxs.StringStream('HubObject'))) # print("NOT ALLOWED NODES:") index = 0 for i in input: new.append(i) if mxs.classOf(i) in allowed: self.selectedNodes.append(i) # print("{}".format(index), i.name) index += 1 # print("{}\n".format(len(self.selectedNodes))) self.result = new self.writeInNodeList(self.result)
def logParallaxInfo(): multimats = filter(lambda m: rt.classOf(m) == rt.MultiMaterial, rt.sceneMaterials) flightSimMats = filter(lambda m: rt.ClassOf(m) == rt.FlightSim, rt.sceneMaterials) for multi in multimats: for m in multi.materialList: if rt.ClassOf(m) == rt.FlightSim: flightSimMats.append(m) for mat in flightSimMats: if mat.materialTYpe == 8: heightmapPath = mat.HeightmapTex if not heightmapPath: logging.info( "'{0}' is ParallaxWindow with no heightmap".format( mat.name)) else: logging.info( "'{0}' is ParallaxWindow with heightmap path '{1}'".format( mat.name, heightmapPath))
def move_node(node_name, amount=None, move_vertices=False, use_local_axis=True): """ Moves given node :param node_name: :param amount: :param move_vertices: :param use_local_axis: :return: """ node_to_move = node_utils.get_pymxs_node(node_name) if not node_to_move: return amount = amount or [0, 0, 0] if rt.classOf(amount) != rt.Point3: amount = rt.Point3(*amount) if move_vertices: xform_mod = rt.xform() rt.addModifier(node_to_move, xform_mod) rt.setProperty(xform_mod.gizmo, 'position', amount) rt.CollapseStack(node_to_move) else: if use_local_axis: coordsys = getattr(rt, '%coordsys_context') local_coordsys = rt.Name('local') prev_coordsys = coordsys(local_coordsys, None) # store current coordsys rt.move(node_to_move, amount) # this is done in local axis coordsys(prev_coordsys, None) # restore previous coordsys else: rt.move(node_to_move, amount)
def addMod(self): allowed = mxs.readvalue(mxs.StringStream('Skin')) if mxs.classOf(mxs.modPanel.getCurrentObject()) == allowed: try: node = mxs.selection[0] mod = mxs.modPanel.getCurrentObject() modID = mxs.modPanel.getModifierIndex(mxs.selection[0], mod) if [node, mod, modID] in self.skinMeshes: pass else: self.skinMeshes.append([node, mod, modID]) self.lw_skiin.addItem("{} > {} > ID:{}".format( mxs.selection[0].name, mod, modID)) self.lw_skiin.item(self.lw_skiin.count() - 1).setBackground( QColor.fromRgb(60, 60, 60)) except: pass # print("Error") else: pass
def create_bone(root_node, name='new_bone', target_node=None, parent=None, **kwargs): length = kwargs.pop('length', 10) width = kwargs.pop('width', 10) height = kwargs.pop('height', 10) color = kwargs.pop('color', [7, 7, 11]) main_axis = kwargs.pop('main_axis', 'z') flip_main_axis = kwargs.pop('flip_main_axis', False) main_rot_axis = kwargs.pop('main_rot_axis', 'y') flip_main_rot_axis = kwargs.pop('flip_main_rot_axis', False) freeze = kwargs.pop('freeze', False) root_node = node_utils.get_pymxs_node(root_node) target_node = node_utils.get_pymxs_node(target_node) parent = node_utils.get_pymxs_node(parent) if not root_node or not node_utils.node_exists(root_node.name): logger.error('Bone could not be created!') return False if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.color(7, 7, 11) bone_name = rt.uniquename(name) bone_box = rt.box(name=bone_name, lengthsegs=1, widthsegs=1, heightsegs=1, length=length, width=width, height=height, mapcoords=True, isSelected=True) bone_box.wirecolor = color bone_box.boneEnable = True bone_box.boneAxis = rt.Name(main_axis.lower()) main_axis_index = 0 main_rot_index = 0 if main_axis.lower() == 'y': main_axis_index = 1 elif main_axis.lower() == 'z': main_axis_index = 2 if main_rot_axis.lower() == 'y': main_rot_index = 1 elif main_rot_axis.lower() == 'z': main_rot_index = 2 xform_utils.match_transforms(bone_box, root_node) if target_node and node_utils.node_exists(target_node.name): temp_helper = rt.Point(pos=rt.Point3(0, 0, 0)) xform_utils.match_position(temp_helper, bone_box) look_at_controller = rt.LookAt_Constraint() rt.setPropertyController(temp_helper.controller, 'Rotation', look_at_controller) look_at_controller.appendTarget(target_node, 1) look_at_controller.target_axis = main_axis_index look_at_controller.upnode_axis = 1 look_at_controller.StoUP_axis = main_rot_index look_at_controller.target_axisFlip = flip_main_axis look_at_controller.StoUP_axisFlip = flip_main_rot_axis xform_utils.match_transforms(bone_box, temp_helper) rt.delete(temp_helper) bone_box.height = rt.distance(root_node, target_node) if parent: bone_box.parent = parent if freeze: xform_utils.freeze_transform(bone_box) return bone_box
def _clickedFixedmatID(self): #pymxs.redraw(False) selection = list(rt.selection) aTreatedMAt = [] MTB = {} for s in selection: if rt.classof(s) == rt.Editable_mesh or rt.classof( s) == rt.Editable_poly: cmat = s.material if rt.classOf( cmat) == rt.Multimaterial and cmat not in aTreatedMAt: blanks = [] offset = 0 #Extend multimat large enough to check for blanks for i in range(len(cmat.materialList)): if i < cmat.materialIDList[i - offset]: offset += 1 if i != 0: cmat.materialList.count += 1 offset = 0 for i in range(len(cmat.materialList)): if i < cmat.materialIDList[i - offset]: offset += 1 if i != 0: blanks.append(i) matlistcount = len(cmat.materialList) aTreatedMAt.append(cmat) print("First Matlist to ser : {0}".format( cmat.materialIDList)) x = [y for y in cmat.materialIDList] MTB[cmat] = MatListnBlank(x, blanks) print("First Fake matlB : {0}".format(MTB[cmat])) if DEBUG_MODE(): print("First Blanks : {0}".format(blanks)) print("First Offsets : {0}".format(offset - 1)) #For the first mesh that is Mat ID recalculed for j in range(len(blanks)): repercute = False if DEBUG_MODE(): print("First CurBlank : {0}".format(j)) print("_________________") for i in range(len(cmat.materialList)): if repercute: if DEBUG_MODE(): print("_______First_repercuteon________") print( "First Pos in ID list to repercute : {0}, First prec value : {1}" .format(i, cmat.materialIDList[i])) print( "First New value to put : {0}".format( i + 1)) #self._setNewFaceIDinObject(oldID = cmat.materialIDList[i],newID = i + 1, Node = s) cmat.materialIDList[i] = i + 1 if i == blanks[j] - 1 and repercute == False: if DEBUG_MODE(): print( "First Pos ID to Change : {0} ".format( blanks[j] - 1)) print("First Value changed : {0}".format( blanks[j])) #self._setNewFaceIDinObject(oldID = cmat.materialIDList[i],newID = blanks[j],Node = s) cmat.materialIDList[i] = blanks[j] repercute = True #For other meshs that share the same multimat that are selected if rt.classOf(cmat) == rt.Multimaterial and cmat in MTB: print("Current Fake matlB : {0}".format(MTB[cmat])) print("Current Fake MTlMList : {0}".format( MTB[cmat].get_MultimatList())) FakeMatList = list(MTB[cmat].get_MultimatList()) for j in range(len(MTB[cmat].get_Blanks())): repercute = False if DEBUG_MODE(): print("CurBlank : {0}".format(j)) print("_________________") for i in range(len(FakeMatList)): if repercute: if DEBUG_MODE(): print("_______repercuteon________") print( "Pos in ID list to repercute : {0}, prec value : {1}" .format(i, FakeMatList[i])) print("New value to put : {0}".format(i + 1)) self._setNewFaceIDinObject( oldID=FakeMatList[i], newID=i + 1, Node=s) FakeMatList[i] = i + 1 if i == MTB[cmat].get_Blanks( )[j] - 1 and repercute == False: if DEBUG_MODE(): print("Pos ID to Change : {0} ".format( MTB[cmat].get_Blanks()[j] - 1)) print("Value changed : {0}".format( MTB[cmat].get_Blanks()[j])) self._setNewFaceIDinObject( oldID=FakeMatList[i], newID=MTB[cmat].get_Blanks()[j], Node=s) FakeMatList[i] = MTB[cmat].get_Blanks()[j] repercute = True else: print("Not a EditableMesh or EditablePoly object, skipped") self.textBrowser.setText("Cleaned : {0}".format(aTreatedMAt)) rt.holdMaxFile() rt.fetchMaxFile(quiet=True)
def mxType(self): return str(rt.classOf(self._node))
def create_end_bone(parent_bone, name='newBone', snap_to=None, match_to=None, parent=None, **kwargs): """ Creates and end bone :param parent_bone: :param snap_to: :param match_to: :param name: :param parent: :return: """ length = kwargs.pop('length', 10) width = kwargs.pop('width', 10) height = kwargs.pop('height', 5) color = kwargs.pop('color', [7, 7, 11]) main_axis = kwargs.pop('main_axis', 'z') extrude = kwargs.pop('extrude', True) freeze = kwargs.pop('freeze', False) parent_bone = node_utils.get_pymxs_node(parent_bone) snap_to = node_utils.get_pymxs_node(snap_to) match_to = node_utils.get_pymxs_node(match_to) parent = node_utils.get_pymxs_node(parent) if not parent_bone or not node_utils.node_exists(parent_bone.name): logger.error('Bone could not be created!') return False if color and rt.classOf(color) != rt.color: color = rt.color(*color) if not color: color = rt.color(7, 7, 11) bone_name = rt.uniquename(name) bone_box = rt.box(name=bone_name, lengthsegs=1, widthsegs=1, heightsegs=1, length=length, width=width, height=height, mapcoords=True, isSelected=True) bone_box.wirecolor = color bone_box.boneEnable = True bone_box.boneAxis = rt.Name(main_axis.lower()) xform_utils.match_transforms(bone_box, parent_bone) rt.SetCommandPanelTaskMode(rt.Name('modify')) rt.convertTo(bone_box, rt.PolyMeshObject) rt.subobjectLevel = 1 vertex_bitarray = rt.BitArray() vertex_indices = [1, 2, 3, 4] vertex_bitarray.count = len(vertex_indices) for i, index in enumerate(vertex_indices): vertex_bitarray[i] = index bone_box.EditablePoly.SetSelection(rt.Name('Vertex'), vertex_bitarray) bone_box.EditablePoly.collapse(rt.Name('Vertex')) bone_box.EditablePoly.SetSelection(rt.Name('Vertex'), rt.BitArray()) if extrude: rt.subobjectLevel = 4 vertex_bitarray = rt.BitArray() vertex_indices = [1] vertex_bitarray.count = len(vertex_indices) for i, index in enumerate(vertex_indices): vertex_bitarray[i] = index bone_box.EditablePoly.SetSelection(rt.Name('Face'), vertex_bitarray) bone_box.EditablePoly.extrudeFaces(height) bone_box.EditablePoly.SetSelection(rt.Name('Vertex'), rt.BitArray()) rt.subobjectLevel = 0 if snap_to: xform_utils.match_position(bone_box, snap_to) if match_to: xform_utils.match_transforms(bone_box, match_to) if parent: bone_box.parent = parent if freeze: xform_utils.freeze_transform(bone_box) return bone_box
def HasEditPolyn(node = None): if node != None: cls = rt.classOf(node) if cls == rt.Editable_Poly or cls == rt.Editable_Mesh: return True return False
def assignMatToMutliMatFromID(multiMat, mat, ID): if rt.classOf(multiMat) == rt.MultiMaterial: multiMat.materialList[ID-1] = mat