if flag: # extra data for this group count = struct.unpack("<L", md.read(4))[0] md.seek(count * 16, 1) else: null = struct.unpack("<L", md.read(4))[0] process_surfaces(files, vertexGroups, materials) #-----------------------------------------------------------# ga.evaluate(ga.data, 'SelectAllBones') #ga.evaluate(ga.data, 'RecordRestPosition') bonemayastyledraw() itemiconscale(0.2) monend() elapsed = time.time() - t1 print "Time: " + str(elapsed) md.close() return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Final Fantasy 7: Remake Skeleton Importer", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), \ ( "Import FF7R Skeleton", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), \ ( "model/import", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] #( "Utilities/File", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_ImportFF7R_SKEL", import_7R_SKEL): ServerTagInfo }
# LWGeneric ------------------------------------------- def process(self, generic_access): ui = lwsdk.LWPanels() panel = ui.create('Test Text') c1 = panel.text_ctl( 'Text', ['Static text 1', 'Static text 1', 'Static text 1']) panel.align_controls_vertical([c1]) panel.size_to_layout(5, 5) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_RESIZE) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Text Test", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Text Test", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyTextTest", test_panels_text): ServerTagInfo }
self.tree_root.children[-1].children.append(TreeNode("Child 3-1")) ui = lwsdk.LWPanels() panel = ui.create('Test Tree') c1 = panel.tree_ctl('Tree', 200, 200, self.tree_info_func, self.tree_count_func, self.tree_node_func) c1.set_event(self.tree_event_func) # note: no event data panel.align_controls_vertical([c1]) panel.size_to_layout(5, 5) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Tree Test", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Tree Test", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyTreeTest", test_panels_tree): ServerTagInfo }
("Display Output", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] # Every Python plug-in must define a global "ServerRecord" instance. # This is a dictionary that mimics the LWSDK ServerRecord format. For # Python plug-ins, the dictionary key is an instance of a Factory that # is responsible for generating Handler plug-ins of its "species", and # the key value is a list of one or more ServerTagInfo settings (see above). # # Each plug-in type defines both a Handler and a Factory. The Factory # serves the role that LWInstanceFuncs does in the native-code SDK # (that of creating and destroying instances). In the Python case, the Factory # implements the create() and destroy() methods of the LWInstanceFuncs, with # load(), save(), copy() and descln() being more properly assigned to the Handler. # # It is the responsibilty of the Factory to generate instances of the Handler, # initializing them with any provided context information. It is important that # Factories maintain a local link to the Handler instances they return to LightWave # so that the instance is not reclaimed by Python's garbage collector until it # is of no further use to LightWave (indicated by a call to the destroy() method). # This can be accomplished in any way you choose; the pre-defined Factories for each # plug-in type simply maintain lists of instances. # # When LightWave is done with the instance, it will call the Factory's destroy() # method for any final disposal. ServerRecord = { lwsdk.GenericFactory("LW_PyDisplayOutput", display_output): ServerTagInfo }
else: #if nothing matched, just pass the line right through to the new scene outfile.write( l + "\n") # copy over Bullet dynamics cache file if os.path.lexists(os.path.join( self.content_dir, "Dynamics") ): dynasource = os.path.join( self.content_dir, "Dynamics", self.scene.name[:-4]) + ".dynacache" dynadest = os.path.join( self.dyn_dir, os.path.basename( dynasource ) ) self.psCopy(dynasource, dynadest) outfile.close() self.psCopy(tempscene, new_scene) if self.reload == True: lwsdk.command("LoadScene " + self.scene.filename) else: lwsdk.command("LoadScene " + new_scene) os.remove(tempscene) os.rmdir(tempdir) return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Package Scene", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "Package Scene", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_PyPackageScene", package_scene) : ServerTagInfo }
print 'You %s: %s' % (action, single_text[row]) # LWGeneric ------------------------------------------- def process(self, generic_access): ui = lwsdk.LWPanels() panel = ui.create('Test Listbox') c1 = panel.listbox_ctl('Listbox', 200, 10, self.name_1d, self.count_1d) c1.set_select(self.single_select_event_func) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_RESIZE) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Listbox Test", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Listbox Test", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyListboxTest", test_panels_listbox): ServerTagInfo }
__status__ = "Example" __lwver__ = "11" class add_null(lwsdk.IGeneric): def __init__(self, context): super(add_null, self).__init__() # LWGeneric ------------------------------------------- def process(self, ga): result = ga.evaluate(ga.data, "AddNull Null") result = ga.evaluate(ga.data, "Position 0 1 0") # if 'autokey' is not turned on, we need to explicitly # create keys for the object at the current time offset interface_info = lwsdk.LWInterfaceInfo() if not (interface_info.generalFlags & lwsdk.LWGENF_AUTOKEY): ga.evaluate(ga.data, "CreateKey %f" % interface_info.curTime) return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Create Null", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Create Null", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = {lwsdk.GenericFactory("LW_PyAddNull", add_null): ServerTagInfo}
import lwsdk, os, tempfile, sys except ImportError: raise Exception("The LightWave Python module could not be loaded.") ################################################################ # Layout Surface Extraction geometry # ################################################################ class OD_LayoutPasteFromExternal(lwsdk.IGeneric): def __init__(self, context): super(OD_LayoutPasteFromExternal, self).__init__() return def process(self, ga): lwsdk.command('AddNull ODCopy') lwsdk.command('ModCommand_OD_LWPasteFromExternal Layout') return lwsdk.AFUNC_OK ServerTagInfo_OD_LayoutPasteFromExternal = [ ("OD_LayoutPasteFromExternal", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("OD_LayoutPasteFromExternal", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("OD_LayoutPasteFromExternal", OD_LayoutPasteFromExternal): ServerTagInfo_OD_LayoutPasteFromExternal }
def count_1d(self, control, userdata): return len(single_text) def popup_event(self, control, userdata): print 'You selected: %s' % single_text[self._c1.get_int()] # LWGeneric ------------------------------------------- def process(self, generic_access): ui = lwsdk.LWPanels() panel = ui.create('Test Custom Popup') self._c1 = panel.custpopup_ctl('Custom Popup', 200, self.name_1d, self.count_1d) self._c1.set_event(self.popup_event) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Python Custom Popup Test", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "Custom Popup Test", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_PyCustPopupTest", test_panels_custpopup) : ServerTagInfo }
return lwsdk.AFUNC_OK instance_null_id = lwsdk.itemid_to_str(instance_null) lwsdk.command("SelectItem %s" % instance_null_id) server_name = self._item_info.server(instance_null, "InstancerHandler", 1) if not server_name: print >> sys.stderr, 'No Instancer server found for object "InstanceNull"!' return lwsdk.AFUNC_OK server_flags = self._item_info.serverFlags(instance_null, "InstancerHandler", 1) if (server_flags & lwsdk.LWSRVF_DISABLED): lwsdk.command("EnableServer InstancerHandler 0 1") else: lwsdk.command("EnableServer InstancerHandler 0 0") return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Toggle Instance", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Toggle Instance", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyToggleInstance", toggle_instance): ServerTagInfo }
__email__ = "*****@*****.**" __status__ = "ControlBoothBehavior" __lwver__ = "11" import os class set_play_mode(lwsdk.IGeneric): def __init__(self, context): super(set_play_mode, self).__init__() if 'LAYOUT_PLAY_MODE' not in os.environ: os.environ['LAYOUT_PLAY_MODE'] = 'PAUSED' def process(self, ga): if (os.environ['LAYOUT_PLAY_MODE'] == 'PAUSED'): result = ga.evaluate(ga.data, "PlayForward") os.environ['LAYOUT_PLAY_MODE'] = 'PlayForward' else: result = ga.evaluate(ga.data, "Pause") os.environ['LAYOUT_PLAY_MODE'] = 'PAUSED' return lwsdk.AFUNC_OK ServerTagInfo = [("SetPlayMode", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH)] ServerRecord = { lwsdk.GenericFactory("LW_PySetPlayMode", set_play_mode): ServerTagInfo }
lwsdk.command("SelectItem %s" % selected_item_id) lwsdk.command("Clone 1") lwsdk.command("Position %s" % str(pos)) # Note: Rotation expects degrees! lwsdk.command("Rotation %s" % str(Vector.to_degrees(rot))) lwsdk.command("Scale %s" % str(scl)) if not autokey_is_on: lwsdk.command("CreateKey %f" % current_time) lwsdk.command("StatusMsg {%f}Baking instances..." % (current_index / target_index)) current_index += 1.0 lwsdk.command("SelectItem %s" % selected_item_id) lwsdk.command("StatusMsg Baking complete.") return lwsdk.AFUNC_OK ServerTagInfo = [ ("Python Bake Instance", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Bake Instance", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyBakeInstance", bake_instance): ServerTagInfo }
#http://home.comcast.net/~erniew/lwsdk/docs/commands/layout.html def process(self, generic_access): #launch interface print("export_three_layout process()") lwsdk.command("StatusMsg export_three_layout") #lwsdk.command("LoadScene " + "E:/3Dstuff/Packaged Scenes/FirstAlphaConstruct10-19-12/Scenes/fivechairs.lws") mesh = lwsdk.LWMeshInfo() #lwsdk.command("SaveObject " + "E:/3Dstuff/Packaged Scenes/FirstAlphaConstruct10-19-12/Scenes/fivechairs.lwo") #item_info = lwsdk.LWItemInfo() #obj_info = lwsdk.LWObjectInfo() return lwsdk.AFUNC_OK ServerTagInfo = [ ("Export Three Layout", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Export Three Layout", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_PyExportThreeLayout", export_three_layout): ServerTagInfo }
__lwver__ = "11" class mobile_suit(lwsdk.IGeneric): def __init__(self, context): super(mobile_suit, self).__init__() def process(self, generic_access): lwsdk.LWMessageFuncs().info('ガンダム、行きまーす!') return lwsdk.AFUNC_OK ServerTagInfo = [ ("MobileSuit Sortie", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH), ("Gandamu, Ikimasu!", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH), ("Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH) ] ServerRecord = { lwsdk.GenericFactory("LW_MobileSuit", mobile_suit): ServerTagInfo } def main(): print "Calculate Funnel deployment Vectors" def deploy(): print "Deploy funnels to target location"
if self._include_x: x_value = random() * self._radius * x_invert r = random() y_invert = -1 if r < 0.5 else 1 y_value = 0.0 if self._include_y: y_value = random() * self._radius * y_invert r = random() z_invert = -1 if r < 0.5 else 1 z_value = 0.0 if self._include_z: z_value = random() * self._radius * z_invert ga.evaluate(ga.data, "SelectItem %s" % lwsdk.itemid_to_str(obj)) ga.evaluate(ga.data, "Position %f %f %f" % (x_value, y_value, z_value)) if not autokey_is_on: ga.evaluate(ga.data, "CreateKey %f" % current_time) return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Python Scatter Objects", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "Scatter Objs", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_PyScatterObjects", scatter_objects) : ServerTagInfo }
################################################################ class OD_LayoutPasteFromExternal(lwsdk.IGeneric): def __init__(self, context): super(OD_LayoutPasteFromExternal, self).__init__() return def process(self, ga): lwsdk.command('AddNull ODCopy') lwsdk.command('ModCommand_OD_LWPasteFromExternal Layout') return lwsdk.AFUNC_OK ServerTagInfo_OD_LWCopyToExternal = [ ( "OD_LWCopyToExternal", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "OD_LWCopyToExternal", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ) ] ServerTagInfo_OD_LWPasteFromExternal = [ ( "OD_LWPasteFromExternal", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "OD_LWPasteFromExternal", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ) ] ServerTagInfo_OD_LayoutPasteFromExternal = [ ( "OD_LayoutPasteFromExternal", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "OD_LayoutPasteFromExternal", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.CommandSequenceFactory("OD_LWPasteFromExternal", OD_LWPasteFromExternal) : ServerTagInfo_OD_LWPasteFromExternal, lwsdk.CommandSequenceFactory("OD_LWCopyToExternal", OD_LWCopyToExternal) : ServerTagInfo_OD_LWCopyToExternal, lwsdk.GenericFactory("OD_LayoutPasteFromExternal", OD_LayoutPasteFromExternal) : ServerTagInfo_OD_LayoutPasteFromExternal }
action = 'deselected' if selecting: action = action[2:] print 'You %s: %s' % (action, ' '.join(multi_text[row])) # LWGeneric ------------------------------------------- def process(self, generic_access): ui = lwsdk.LWPanels() panel = ui.create('Test Multilist') c1 = panel.multilist_ctl('Multilist', 200, 10, self.name_2d, self.count_2d, self.column_width) c1.set_select(self.multi_select_event_func) if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_RESIZE) == 0: ui.destroy(panel) return lwsdk.AFUNC_OK ui.destroy(panel) return lwsdk.AFUNC_OK ServerTagInfo = [ ( "Python Multilist Test", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ), ( "Multilist Test", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ), ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH ) ] ServerRecord = { lwsdk.GenericFactory("LW_PyMultilistTest", test_panels_multilist) : ServerTagInfo }