Advertisement
Guest User

main.pyp

a guest
Aug 10th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.50 KB | None | 0 0
  1. import sys
  2. import os
  3. import c4d
  4. from c4d import gui, plugins, bitmaps, utils, documents
  5.  
  6. __currdir__ = os.path.dirname(__file__)
  7. if __currdir__ not in sys.path:
  8.     sys.path.insert(0, __currdir__)
  9. from export_nx3 import *
  10.  
  11.  
  12.  
  13.  
  14.  
  15. PLUGIN_ID = 1011310 # Test ID
  16.  
  17. ####################################### Notice #################################################################
  18. TABVAN              = 10001        #TAB constant
  19.  
  20. MY_PARENTLINK       = 11001
  21. MY_EXPORT_BUTTON    = 11002
  22.  
  23. MY_INPUTFILE        = 13001
  24.  
  25. ##########################################################
  26.  
  27. class MyDialog(gui.GeDialog):
  28.  
  29.     def CreateLayout(self):
  30.    
  31.         self.TabGroupBegin(id=TABVAN, flags=c4d.BFH_LEFT, tabtype=c4d.TAB_TABS)
  32.        
  33.        
  34.         # Select TAB ===================
  35.         self.GroupBegin(id=1000, flags=c4d.BFH_FIT, cols=0, rows=4, title="Rappelz 3D Exporter")  
  36.  
  37.         self.GroupBegin(id=1011, flags=c4d.BFH_FIT, cols=2)
  38.         self.element = self.AddStaticText(id=1003, flags=c4d.BFH_LEFT, initw=200, name="Rappelz 3D Exporter")
  39.         self.GroupEnd()
  40.  
  41.         self.GroupBegin(id=1012, flags=c4d.BFH_FIT, cols=1, rows=4)
  42.         self.AddSeparatorV(600, flags=c4d.BFH_SCALE)              
  43.         self.GroupEnd()
  44.        
  45.         self.GroupBegin(id=1013, flags=c4d.BFH_SCALEFIT, cols=5, rows=4)
  46.         self.AddButton(MY_EXPORT_BUTTON, c4d.BFV_MASK, initw=100, name="Export")
  47.         self.GroupEnd()
  48.        
  49.         self.GroupEnd()
  50.  
  51.         #Importer TAB ==========================
  52.         self.GroupBegin(id=1017, flags=c4d.BFH_MASK, cols=1, rows=4, title="Rappelz 3D importer")
  53.         self.element = self.AddStaticText(id=1051, flags=c4d.BFH_MASK, initw=150, name="Select Rappelz 3D model", borderstyle=c4d.BORDER_NONE)
  54.         self.file = self.AddCustomGui(MY_INPUTFILE, c4d.CUSTOMGUI_FILENAME, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0)
  55.         self.GroupEnd()
  56.        
  57.         #About TAB ==========================
  58.         self.GroupBegin(id=1031, flags=c4d.BFH_SCALEFIT, cols=1, rows=4, title="About")
  59.         self.element = self.AddStaticText(id=1041, flags=c4d.BFH_LEFT, initw=500, name="A big thanks to glandu2 for all the research", borderstyle=c4d.BORDER_NONE)
  60.         self.element = self.AddStaticText(id=1042, flags=c4d.BFH_LEFT, initw=500, name="and his wonderful blender plugin !", borderstyle=c4d.BORDER_NONE)
  61.         self.element = self.AddStaticText(id=1043, flags=c4d.BFH_LEFT, initw=600, name="For more info look at: https://github.com/ldxngx/BTRFdom !", borderstyle=c4d.BORDER_NONE)
  62.         self.element = self.AddStaticText(id=1045, flags=c4d.BFH_LEFT, initw=500, name="", borderstyle=c4d.BORDER_NONE)
  63.         self.element = self.AddStaticText(id=1046, flags=c4d.BFH_LEFT, initw=500, name="Coded for c4d by gr4ph0s", borderstyle=c4d.BORDER_NONE)
  64.         self.element = self.AddStaticText(id=1046, flags=c4d.BFH_LEFT, initw=500, name="More info at: http://gr4ph0s.free.fr", borderstyle=c4d.BORDER_NONE)
  65.         self.GroupEnd()
  66.         #self.GroupEnd() #end About tab group
  67.        
  68.         return True    
  69.  
  70.     def InitValues(self):
  71.         return True
  72.  
  73.  
  74.     def Command(self, id, msg):      
  75.  
  76.         if (id == MY_EXPORT_BUTTON):
  77.             s = export_nx3()
  78.             print dir(s)
  79.             print s.name            
  80.             return True
  81.  
  82.         if (id == MY_INPUTFILE):
  83.             filename = self.GetString(MY_INPUTFILE)
  84.             gui.MessageDialog ("Selected file: " + filename)
  85.             return True
  86.            
  87.         # all other ID's            
  88.         return True
  89.  
  90. #################################################################################################
  91.  
  92. class MyRappelzPlugin(plugins.CommandData):
  93.     dialog = None
  94.     def Execute(self, doc):
  95.     # create the dialog
  96.        if self.dialog is None:
  97.           self.dialog = MyDialog()
  98.        return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
  99.        
  100.     def RestoreLayout(self, sec_ref):
  101.     # manage the dialog
  102.        if self.dialog is None:
  103.           self.dialog = MyDialog()
  104.        return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
  105.        
  106. if __name__ == "__main__":
  107.  
  108.  path, fn = os.path.split(__file__)
  109.  bmp = bitmaps.BaseBitmap()                                
  110.  bmp.InitWith(os.path.join(path, "res/icons/", "icon.tif"))
  111.  
  112.  okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Rappelz",0, bmp, "Rappelz", MyRappelzPlugin())  
  113.  if (okyn):
  114.     print "Rappelz plugin V0.1 initialized. @Gr4ph0s 2014"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement