def inter_ui(self): ui = lwsdk.LWPanels() panel = ui.create('Random Number') panel.setw(300) interval_control = panel.float_ctl('Change interval (seconds)') interval_control.set_float(self._change_interval) # 'width' for dir_ctl() is in characters, not pixels! path_control = panel.dir_ctl('Object path', 50) if len(self._object_path): path_control.set_str(self._object_path) path_control.set_event(self, self.path_callback) self._controls = [interval_control, path_control] panel.align_controls_vertical(self._controls) panel.size_to_layout(5, 5) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL): self._change_interval = interval_control.get_float() path = path_control.get_str() if not os.path.exists(path): lwsdk.LWMessageFuncs().error('The provided path', 'is invalid!') else: self._object_path = path ui.destroy(panel) return lwsdk.AFUNC_OK
def inter_ui(self): global object_path ui = lwsdk.LWPanels() panel = ui.create('Frame Timer') panel.setw(300) # 'width' for dir_ctl() is in characters, not pixels! self._path_control = panel.dir_ctl('Object path', 50) if len(object_path): self._path_control.set_str(object_path) self._path_control.set_event(self, self.path_callback) panel.size_to_layout(5, 5) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL): path = self._path_control.get_str() if not os.path.exists(path): lwsdk.LWMessageFuncs().error('The provided path', 'is invalid!') else: object_path = path ui.destroy(panel) return lwsdk.AFUNC_OK
def process(self, mod_command): self.read_history() ui = lwsdk.LWPanels() panel = ui.create('Select layers by string ' + __version__ + ' - ' + __copyright__) self.text_string = panel.str_ctl("String", 50) self.hchoice_contains = panel.hchoice_ctl( "Select FG Layer", ('Contains string', 'Not contains string')) self.bool_others = panel.bool_ctl("Select others as BG Layer") self.bool_sort_history = panel.bool_ctl( "Move the last condition up if they match") self.list_history = panel.multilist_ctl('History', 450, 10, self.nameCallback, self.countCallback, self.columnCallback) self.button_remove = panel.button_ctl("Remove") self.button_remove.ghost() self.list_history.set_select(self.selectCallback) self.button_remove.set_event(self.remove_history) self.set_default_values() if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK history = HistoryData() history.string = self.text_string.get_str() history.select_contains = not self.hchoice_contains.get_int() history.select_others = self.bool_others.get_int() self.last_string = history.string self.last_select_contains = history.select_contains self.last_others = history.select_others self.sort_history = self.bool_sort_history.get_int() self.add_history(history) self.write_history() try: self.select_layers(mod_command, history) except NoForegroundLayer: message_funcs = lwsdk.LWMessageFuncs() message_funcs.error('No foreground layer', '') finally: return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK
def select_layers(self, mod, data): obj_funcs = lwsdk.LWObjectFuncs() state_query = lwsdk.LWStateQueryFuncs() obj_name = state_query.object() layer_list = state_query.layerList(lwsdk.OPLYR_NONEMPTY, obj_name) # there is no mesh ! if layer_list == '': message_funcs = lwsdk.LWMessageFuncs() message_funcs.error('No mesh data', '') return lwsdk.AFUNC_OK current_obj = obj_funcs.focusObject() layers = layer_list.split(' ') foreground_layers = [] background_layers = [] for layer in layers: layer_int = int(layer) - 1 # layer name is (unnamed), display None layer_name = obj_funcs.layerName(current_obj, layer_int) if layer_name == None: layer_name = '' if data.select_contains == (0 if layer_name.find(data.string) < 0 else 1): foreground_layers.append(layer) else: background_layers.append(layer) if len(foreground_layers) == 0: raise NoForegroundLayer() if len(foreground_layers) > 0: cs_options = lwsdk.marshall_dynavalues(' '.join(foreground_layers)) cs_setlayer = mod.lookup(mod.data, "SETALAYER") mod.execute(mod.data, cs_setlayer, cs_options, lwsdk.OPSEL_USER) if len(background_layers) > 0 and data.select_others: cs_options = lwsdk.marshall_dynavalues(' '.join(background_layers)) cs_setlayer = mod.lookup(mod.data, "setblayer") mod.execute(mod.data, cs_setlayer, cs_options, lwsdk.OPSEL_USER)
def selectLayers(self, data): obj_funcs = lwsdk.LWObjectFuncs() state_query = lwsdk.LWStateQueryFuncs() obj_name = state_query.object() layer_list = state_query.layerList(lwsdk.OPLYR_NONEMPTY, obj_name) # there is no mesh ! if layer_list == '': message_funcs = lwsdk.LWMessageFuncs() message_funcs.error('No mesh data', '') return lwsdk.AFUNC_OK current_obj = obj_funcs.focusObject() layers = layer_list.split(' ') foreground_layers = [] background_layers = [] for layer in layers: layer_int = int(layer) - 1 # layer name is (unnamed), display None layer_name = obj_funcs.layerName(current_obj, layer_int) if layer_name == None: layer_name = '' if data.select_contains == ( False if layer_name.find(data.string) < 0 else True): foreground_layers.append(layer) else: background_layers.append(layer) print('foreground_layers') print(foreground_layers) print('background_layers') print(background_layers)
def process(self, generic_access): # All this particular plug-in does is display some messages # to various outputs... # have the user select an image file... image_path = lwsdk.LWDirInfoFunc(lwsdk.LWFTYPE_IMAGE) image_pattern = lwsdk.LWFileTypeFunc(lwsdk.LWFTYPE_IMAGE) # returns tuple(result, file name, file path, full path) result = lwsdk.LWFileReqFunc("Select an image file", image_pattern, image_path) if (type(result) is tuple) and (result[0] == 1): # output the value to the PCore console as a regular message print result[3] # handle as an error on the PCore console ('errors' automatically open the console) print >> sys.stderr, result[3] # this will appear on the LightWave GUI lwsdk.LWMessageFuncs().info('Python v%s' % sys.version.split()[0], result[3]) return lwsdk.AFUNC_OK
def process(self, mod_command): #deselect any Morph Targets command = mod_command.lookup(mod_command.data, "SELECTVMAP") cs_options = lwsdk.marshall_dynavalues(("MORF")) result = mod_command.execute(mod_command.data, command, cs_options, lwsdk.OPSEL_USER) file = tempfile.gettempdir() + os.sep + "ODVertexData.txt" #find existing Vmaps loaded_weight = []; loaded_uv = []; loaded_morph = [] for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_WGHT )): loaded_weight.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_WGHT, u)) for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_TXUV )): loaded_uv.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_TXUV, u)) for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_MORF )): loaded_morph.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_MORF, u)) mesh_edit_op = mod_command.editBegin(0, 0, lwsdk.OPLYR_FG) if not mesh_edit_op: print >>sys.stderr, 'Failed to engage mesh edit operations!' return lwsdk.AFUNC_OK try: # Getting Point ID of selected Point points = [] edit_op_result = mesh_edit_op.fastPointScan(mesh_edit_op.state, self.fast_point_scan, (points,), lwsdk.OPLYR_FG, 0) if edit_op_result != lwsdk.EDERR_NONE: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) return lwsdk.AFUNC_OK point_count = len(points) edit_op_result = lwsdk.EDERR_NONE polys = [] edit_op_result = mesh_edit_op.fastPolyScan(mesh_edit_op.state, self.fast_poly_scan, (polys,), lwsdk.OPLYR_FG, 0) if edit_op_result != lwsdk.EDERR_NONE: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) return lwsdk.AFUNC_OK poly_count = len(polys) edit_op_result = lwsdk.EDERR_NONE #if there's no points, then we dont need to do anything if point_count == 0: lwsdk.LWMessageFuncs().info("No Points.", "") return lwsdk.AFUNC_OK f = open(file, "w") f.write ("VERTICES:" + str(point_count) + "\n") positions = [] uvMaps = [] weightMaps = [] morphMaps = [] # Filling Position Array for Selected Point for point in points: pos = mesh_edit_op.pointPos(mesh_edit_op.state, point) f.write(str(pos[0]) + " " + str(pos[1]) + " " + str(pos[2]*-1) + "\n") #write polygons-point connection for poly reconstruction f.write("POLYGONS:" + str(len(polys)) + "\n") x =0 for poly in polys: surf = mesh_edit_op.polySurface(mesh_edit_op.state,poly) ppoint = "" for point in reversed(mesh_edit_op.polyPoints(mesh_edit_op.state,poly)): ppoint += "," + str(self.pointidxmap[str(point)]) polytype = "FACE" subD = mesh_edit_op.polyType(mesh_edit_op.state, poly)# & lwsdk.LWPOLTYPE_SUBD if subD == lwsdk.LWPOLTYPE_SUBD: polytype = "CCSS" elif subD == lwsdk.LWPOLTYPE_PTCH: polytype = "SUBD" f.write(ppoint[1:] + ";;" + surf + ";;" + polytype + "\n") #grab all weights for weight in loaded_weight: mesh_edit_op.vMapSelect(mesh_edit_op.state, weight, lwsdk.LWVMAP_WGHT, 1) f.write("WEIGHT:" + weight + "\n") for point in points: if (mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) != None: f.write(str(mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) + "\n") else: f.write("0.0\n") #grab all UVs for uvs in loaded_uv: cont = [] discont = [] c = 0 #selecting uv map mesh_edit_op.vMapSelect(mesh_edit_op.state, uvs, lwsdk.LWVMAP_TXUV, 2) #check whether we are dealing with continuous or discontinous UVs, we have to look at points per poly for this for poly in polys: for point in mesh_edit_op.polyPoints(mesh_edit_op.state,poly): #vpget gets uv coordinates based on point in poly, if that has a value, the uv is discontinuous.. if it doesnt, its continuous. pInfo = mesh_edit_op.pointVPGet(mesh_edit_op.state,point, poly)[1] if pInfo != None: #check if discontinous curPos = [pInfo[0], pInfo[1]] #print "oh:", self.polyidxmap[str(poly)] discont.append([curPos, str(self.polyidxmap[str(poly)]), str(self.pointidxmap[str(point)])]) #discont.append([curPos, str(1), str(self.pointidxmap[str(point)])]) c+= 1 else: #otherwise, the uv coordinate is continuous if mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1] != None: curPos = [mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1][0], mesh_edit_op.pointVGet(mesh_edit_op.state, point)[1][1]] cont.append([curPos, str(self.pointidxmap[str(point)])]) c+= 1 f.write("UV:" + uvs + ":"+str(c) + "\n") for uvpos in discont: f.write(str(uvpos[0][0]) + " " + str(uvpos[0][1]) + ":PLY:" + str(uvpos[1]) + ":PNT:" + str(uvpos[2]) + "\n") for uvpos in cont: f.write(str(uvpos[0][0]) + " " + str(uvpos[0][1]) + ":PNT:" + str(uvpos[1]) + "\n") #grab all Morphs for morph in loaded_morph: mesh_edit_op.vMapSelect(mesh_edit_op.state, morph, lwsdk.LWVMAP_MORF, 3) f.write("MORPH:" + morph + "\n") for point in points: if (mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) != None: ms = mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1] f.write(str(ms[0]) + " " + str(ms[1]) + " " + str(ms[2]*-1) + "\n") else: f.write("0 0 0\n") except: edit_op_result = lwsdk.EDERR_USERABORT raise finally: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) f.close() return lwsdk.AFUNC_OK
def process(self, mod_command): #get the command arguments (so that we can also run this from layout) cmd = mod_command.argument.replace('"', '') file = tempfile.gettempdir() + os.sep + "ODVertexData.txt" #open the temp file if os.path.exists(file): with open(file, "r") as f: lines = f.readlines() else: lwsdk.LWMessageFuncs().info("Storage File does not exist. Needs to be created via the Layout CopyTransform counterpart", "") return 0 #find existing Vmaps # loaded_weight = []; loaded_uv = []; loaded_morph = [] # for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_WGHT )): # loaded_weight.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_WGHT, u)) # for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_TXUV )): # loaded_uv.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_TXUV, u)) # for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_MORF )): # loaded_morph.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_MORF, u)) #check if we are in modeler, if so, clear polys if cmd == "": #Remove Current mesh from layer command = mod_command.lookup(mod_command.data, "CUT") result = mod_command.execute(mod_command.data, command, None, lwsdk.OPLYR_FG) edit_op_result = lwsdk.EDERR_NONE mesh_edit_op = mod_command.editBegin(0, 0, lwsdk.OPSEL_USER) if not mesh_edit_op: print >>sys.stderr, 'Failed to engage mesh edit operations!' return lwsdk.AFUNC_OK try: #Parse File to see what Data we have vertline = []; polyline = []; uvMaps = []; morphMaps = []; weightMaps = [] count = 0 for line in lines: if line.startswith("VERTICES:"): vertline.append([int(line.strip().split(":")[1].strip()), count]) if line.startswith("POLYGONS:"): polyline.append([int(line.strip().split(":")[1].strip()), count]) if line.startswith("UV:"): uvMaps.append([line.strip().split(":")[1:], count]) # changed this to add the # of uv coordinates into the mix if line.startswith("MORPH"): morphMaps.append([line.split(":")[1].strip(), count]) if line.startswith("WEIGHT"): weightMaps.append([line.split(":")[1].strip(), count]) count += 1 #create Points for verts in vertline: points = [] for i in xrange(verts[1] + 1, verts[1] + verts[0] + 1): x = map(float, lines[i].split()) points.append(mesh_edit_op.addPoint(mesh_edit_op.state, [ x[0], x[1], x[2]*-1 ])) #create Polygons for polygons in polyline: polys = [] for i in xrange(polygons[1] + 1, polygons[1] + polygons[0] + 1): pts = [] split = lines[i].split(";;") surf = split[1].strip() polytype = split[2].strip() for x in split[0].split(","): pts.insert(0, (points[int(x.strip())])) ptype = lwsdk.LWPOLTYPE_FACE if polytype == "CCSS": ptype = lwsdk.LWPOLTYPE_SUBD elif polytype == "SUBD": ptype = lwsdk.LWPOLTYPE_PTCH polys.append(mesh_edit_op.addPoly(mesh_edit_op.state, ptype, None, surf, pts)) #setup weightmaps for weightMap in weightMaps: mesh_edit_op.vMapSelect(mesh_edit_op.state, weightMap[0], lwsdk.LWVMAP_WGHT, 1) count = 0 for point in points: if lines[weightMap[1]+1+count].strip() != "None": mesh_edit_op.pntVMap(mesh_edit_op.state, point, lwsdk.LWVMAP_WGHT, weightMap[0], [float(lines[weightMap[1]+1+count].strip())]) count += 1 #Set Mprph Map Values for morphMap in morphMaps: mesh_edit_op.vMapSelect(mesh_edit_op.state, morphMap[0], lwsdk.LWVMAP_MORF, 3) count = 0 for point in points: if lines[morphMap[1]+1+count].strip() != "None": mesh_edit_op.pntVMap(mesh_edit_op.state, point, lwsdk.LWVMAP_MORF, morphMap[0], [float(lines[morphMap[1]+1+count].split(" ")[0]), float(lines[morphMap[1]+1+count].split(" ")[1]), float(lines[morphMap[1]+1+count].split(" ")[2])*-1]) count += 1 #Set UV Map Values for uvMap in uvMaps: mesh_edit_op.vMapSelect(mesh_edit_op.state, uvMap[0][0], lwsdk.LWVMAP_TXUV, 2) count = 0 for i in range(int(uvMap[0][1])): split = lines[uvMap[1]+1+count].split(":") if len(split) > 3: #check the format to see if it has a point and poly classifier, determining with that, whether the uv is discontinuous or continuous mesh_edit_op.pntVPMap(mesh_edit_op.state, points[int(split[4])], polys[int(split[2])], lwsdk.LWVMAP_TXUV, uvMap[0][0], [float(split[0].split(" ")[0]), float(split[0].split(" ")[1])]) else: mesh_edit_op.pntVMap(mesh_edit_op.state, points[int(split[2])], lwsdk.LWVMAP_TXUV, uvMap[0][0], [float(split[0].split(" ")[0]), float(split[0].split(" ")[1])]) count +=1 except: edit_op_result = lwsdk.EDERR_USERABORT raise finally: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) return lwsdk.AFUNC_OK
def show_error_dialog(self, msg1, msg2): message_funcs = lwsdk.LWMessageFuncs() message_funcs.error(msg1, msg2)
def process(self, generic_access): lwsdk.LWMessageFuncs().info('ガンダム、行きまーす!') return lwsdk.AFUNC_OK
def process(self, mod_command): def polytree(polys, points): #here we build a tree on which polys belong to a point. #n will store the polyIDs assignement per point #nfullNormals will add the poly normals together for that point from the belonging polys n = [] nfullNormals = [] #create empty arrays for p in points: n.append([]) nfullNormals.append([]) #go through each poly checking with points belong to it. count = 0 for poly in polys: pts = mesh_edit_op.polyPoints(mesh_edit_op.state,poly) for p in pts: n[self.pointidxmap[str(p)]].append(count) nfullNormals[self.pointidxmap[str(p)]] = lwsdk.Vector(nfullNormals[self.pointidxmap[str(p)]]) + lwsdk.Vector(mesh_edit_op.polyNormal(mesh_edit_op.state,polys[count])[1]) count += 1 return n, nfullNormals #deselect any Morph Targets command = mod_command.lookup(mod_command.data, "SELECTVMAP") cs_options = lwsdk.marshall_dynavalues(("MORF")) result = mod_command.execute(mod_command.data, command, cs_options, lwsdk.OPSEL_USER) #The temporary filename where it resides, typically this is the systems temp folder as it will resolve to the same on every system file = tempfile.gettempdir() + os.sep + "ODVertexData.txt" #find existing Vmaps loaded_weight = []; loaded_uv = []; loaded_morph = [] for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_WGHT )): loaded_weight.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_WGHT, u)) for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_TXUV )): loaded_uv.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_TXUV, u)) for u in range(0, lwsdk.LWObjectFuncs().numVMaps( lwsdk.LWVMAP_MORF )): loaded_morph.append(lwsdk.LWObjectFuncs().vmapName(lwsdk.LWVMAP_MORF, u)) #start mesh edit operations mesh_edit_op = mod_command.editBegin(0, 0, lwsdk.OPLYR_FG) if not mesh_edit_op: print >>sys.stderr, 'Failed to engage mesh edit operations!' return lwsdk.AFUNC_OK try: # Query all points points = [] edit_op_result = mesh_edit_op.fastPointScan(mesh_edit_op.state, self.fast_point_scan, (points,), lwsdk.OPLYR_FG, 0) if edit_op_result != lwsdk.EDERR_NONE: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) return lwsdk.AFUNC_OK point_count = len(points) edit_op_result = lwsdk.EDERR_NONE # Query all polygons polys = [] edit_op_result = mesh_edit_op.fastPolyScan(mesh_edit_op.state, self.fast_poly_scan, (polys,), lwsdk.OPLYR_FG, 0) if edit_op_result != lwsdk.EDERR_NONE: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) return lwsdk.AFUNC_OK poly_count = len(polys) edit_op_result = lwsdk.EDERR_NONE #if there's no points, then we dont need to do anything if point_count == 0: lwsdk.LWMessageFuncs().info("No Points.", "") return lwsdk.AFUNC_OK #initializing some variables we'll need positions = [] uvMaps = [] weightMaps = [] morphMaps = [] vertexNormals = [] #open the file and start writing points header and point positions f = open(file, "w") f.write ("VERTICES:" + str(point_count) + "\n") # Writing point positions for each point for point in points: pos = mesh_edit_op.pointPos(mesh_edit_op.state, point) f.write(str(pos[0]) + " " + str(pos[1]) + " " + str(pos[2]*-1) + "\n") #check to see if any surfaces have smoothing on: smoothing = 0 surfIDs = lwsdk.LWSurfaceFuncs().byObject(lwsdk.LWStateQueryFuncs().object()) for surf in surfIDs: smooth = lwsdk.LWSurfaceFuncs().getFlt(surf, lwsdk.SURF_SMAN) if smooth > 0: smoothing = 1 break #Query which polygons belong to a point and build an array for easy lookup (only needed if there's any smoothing) if smoothing > 0: ptree = polytree(polys, points) #write Polygon Header f.write("POLYGONS:" + str(len(polys)) + "\n") x =0 for poly in polys: #check if the surface of a poly has smoothing enabled or not so that we either export smoothed or nonsmoothed normals surf = mesh_edit_op.polySurface(mesh_edit_op.state,poly) surfID = lwsdk.LWSurfaceFuncs().byName(surf, lwsdk.LWStateQueryFuncs().object()) smoothing = lwsdk.LWSurfaceFuncs().getFlt(surfID[0], lwsdk.SURF_SMAN) #Write poly construction with surface name and type, as well as storing the normals ppoint = "" for point in reversed(mesh_edit_op.polyPoints(mesh_edit_op.state,poly)): ppoint += "," + str(self.pointidxmap[str(point)]) if smoothing > 0: vertexNormals.append(lwsdk.Vector().normalize(ptree[1][self.pointidxmap[str(point)]]/float(len(ptree[0])))) else: vertexNormals.append(mesh_edit_op.polyNormal(mesh_edit_op.state,poly)[1]) polytype = "FACE" subD = mesh_edit_op.polyType(mesh_edit_op.state, poly)# & lwsdk.LWPOLTYPE_SUBD if subD == lwsdk.LWPOLTYPE_SUBD: polytype = "CCSS" elif subD == lwsdk.LWPOLTYPE_PTCH: polytype = "SUBD" f.write(ppoint[1:] + ";;" + surf + ";;" + polytype + "\n") #grab all weights for weight in loaded_weight: mesh_edit_op.vMapSelect(mesh_edit_op.state, weight, lwsdk.LWVMAP_WGHT, 1) f.write("WEIGHT:" + weight + "\n") for point in points: if (mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) != None: f.write(str(mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) + "\n") else: f.write("0.0\n") #grab all UVs for uvs in loaded_uv: cont = [] discont = [] c = 0 #selecting uv map mesh_edit_op.vMapSelect(mesh_edit_op.state, uvs, lwsdk.LWVMAP_TXUV, 2) #check whether we are dealing with continuous or discontinous UVs, we have to look at points per poly for this for poly in polys: for point in mesh_edit_op.polyPoints(mesh_edit_op.state,poly): #vpget gets uv coordinates based on point in poly, if that has a value, the uv is discontinuous.. if it doesnt, its continuous. pInfo = mesh_edit_op.pointVPGet(mesh_edit_op.state,point, poly)[1] if pInfo != None: #check if discontinous curPos = [pInfo[0], pInfo[1]] #print "oh:", self.polyidxmap[str(poly)] discont.append([curPos, str(self.polyidxmap[str(poly)]), str(self.pointidxmap[str(point)])]) #discont.append([curPos, str(1), str(self.pointidxmap[str(point)])]) c+= 1 else: #otherwise, the uv coordinate is continuous if mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1] != None: curPos = [mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1][0], mesh_edit_op.pointVGet(mesh_edit_op.state, point)[1][1]] cont.append([curPos, str(self.pointidxmap[str(point)])]) c+= 1 #Write UVs f.write("UV:" + uvs + ":"+str(c) + "\n") for uvpos in discont: f.write(str(uvpos[0][0]) + " " + str(uvpos[0][1]) + ":PLY:" + str(uvpos[1]) + ":PNT:" + str(uvpos[2]) + "\n") for uvpos in cont: f.write(str(uvpos[0][0]) + " " + str(uvpos[0][1]) + ":PNT:" + str(uvpos[1]) + "\n") #grab all Morphs for morph in loaded_morph: mesh_edit_op.vMapSelect(mesh_edit_op.state, morph, lwsdk.LWVMAP_MORF, 3) f.write("MORPH:" + morph + "\n") for point in points: if (mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1]) != None: ms = mesh_edit_op.pointVGet(mesh_edit_op.state,point)[1] f.write(str(ms[0]) + " " + str(ms[1]) + " " + str(ms[2]*-1) + "\n") else: f.write("0 0 0\n") #Write Vertex Normals f.write("VERTEXNORMALS:" + str(len(vertexNormals)) + "\n") for normal in vertexNormals: f.write(str(normal[0]) + " " + str(normal[1]) + " " + str(normal[2]*-1) + "\n") except: edit_op_result = lwsdk.EDERR_USERABORT raise finally: mesh_edit_op.done(mesh_edit_op.state, edit_op_result, 0) f.close() return lwsdk.AFUNC_OK
def path_callback(self, id, data): path = self._controls[1].get_str() if len(path) and (not os.path.exists(path)): lwsdk.LWMessageFuncs().error('The provided path', 'is invalid!') self._controls[1].set_str(self._object_path)