Advertisement
Guest User

Untitled

a guest
Jan 21st, 2021
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.11 KB | None | 0 0
  1. bl_info = {
  2.     "name": "Random Word Generator",
  3.     "author": "Darkfall",
  4.     "version": (1, 0),
  5.     "blender": (2, 90, 1),
  6.     "location": "View3D > N > Random Word Gen Tab",
  7.     "description": "Generates a Random Phrase",
  8.     "warning": "",
  9.     "doc_url": "",
  10.     "category": "Add Words",
  11. }
  12.  
  13. import bpy
  14. from bpy.types import Panel, Operator, PropertyGroup
  15. from bpy.props import IntProperty, PointerProperty, BoolProperty
  16. from random import randint
  17.  
  18.  
  19.  
  20.  
  21.  
  22. class RandomWordGenProperties(PropertyGroup):
  23.    
  24.     list_a = ["A", "Dr", "Mr", "Mrs", "Our", "The"]
  25.    
  26.    
  27.     list_b = ["Adorable", "Adventurous", "Agressive", "Agreeable", "Angry", "Annoyed", "Annoying", "Anxious", "Arrogant", "Attractive", "Average", "Awful", "Bad", "Beautiful", "Better", "Bewildered", "Bloody", "Blushing", "Bored", "Brainy", "Brave", "Breakable", "Bright", "Broken", "Bronze", "Busy", "Calm", "Careful", "Cautious", "Charming", "Cheerful", "Clean", "Clear", "Clever", "Cloudy", "Clumsy", "Colorful", "Comfortable", "Condemned", "Confused", "Cooperative", "Courageous", "Crazy", "Creepy", "Crowded", "Cruel", "Curious", "Cute", "Dangerous", "Dark", "Dead", "Defeated", "Defiant", "Delightful", "Depressed", "Determained", "Different", "Difficult", "Disgusted", "Doubtful", "Dull", "Eager", "Easy", "Elated", "Elegant", "Embarrassed", "Enchanting", "Encouraging", "Energetic", "Enthusiastic", "Envious", "Evil", "Excited", "Expensive", "Exuberant", "Faithful", "Famous", "Fancy", "Fantastic", "Fierce", "Filthy", "Fine", "Foolish", "Fragile", "Frail", "Frantic", "Friendly", "Frightened", "Frozen", "Funny", "Gentle", "Gifted", "Glamorous", "Gleaming", "Glorious", "Good", "Gold", "Golden", "Gorgeous", "Graceful", "Greiving", "Grotesque", "Grumpy", "Handsome", "Happy", "Healthy", "Helpful", "Helpless", "Hilarious", "Horrible", "Hungry", "Hurt", "Important", "Impossible", "Industrial", "Inexpensive", "Innocent", "Inquisitive", "Itchy", "Jelous", "Jolly", "Joyous", "Kind", "Lazy", "Light", "Lively", "Lonely", "Long", "Lovely", "Lucky", "Magnificent", "Misty", "Modern", "Motionless", "Muddy", "Mushy", "Mysterious", "Nasty", "Naughty", "Nervous", "Never-ending", "Nice", "Obedient", "Obnoxious", "Odd", "Old", "Old-fashoined", "Open", "Outrageous", "Outstanding", "Perfect", "Plain", "Pleasant", "Poised", "Poor", "Powerful", "Precious", "Proud", "Putrid", "Puzzled", "Quaint", "Real", "Relieved", "Repulsive", "Rich", "Righteous", "Rival", "Rusty", "Secret", "Scary", "Silver", "Silvery", "Selfish", "Shiny", "Shy", "Silly", "Sleepy", "Smiling", "Sore", "Sparkling", "Splendid", "Spotless", "Stalking", "Steady", "Strange", "Stranger", "Stupid", "Subtle", "Successful", "Super", "Talented", "Tame", "Tender", "Tense", "Terrible", "Thankful", "Thoughful", "Thoughtless", "Tired", "Tough", "Troubled", "Ugliest", "Ugly", "Unsightly", "Unusual", "Upset", "Uptight", "Vast", "Victorious", "Wandering", "Weary", "Wicked", "Wild", "Witty", "Worried", "Wrong", "Zelous"]
  28.    
  29.    
  30.     list_c = ["Actor", "Anchor", "Antagonist", "Apple", "Angel", "Angle", "Army", "Astronaut", "Ball", "Balloon", "Beach", "Bear", "Beast", "Book", "Brain", "Cake", "Castle", "Coast", "Colony", "Complex", "Conundrum", "Core", "Crowd", "Dancer", "Detective", "Detector", "Devil", "Director", "Diver", "Driver", "Express", "Factory", "Family", "Forest", "Future", "Gamer", "Garden", "Hacker", "Hangman", "History", "House", "Idea", "Island", "Jail", "Jester", "Joker", "King", "Knight", "Lake", "Lighthouse", "Matrix", "Mind", "Monument", "Moon", "Mountain", "Navy", "Nail", "Night", "Office", "Officer", "Operator", "Page", "Park", "Path", "Pickle", "Pizza", "Place", "Planet", "Player", "Picture", "Price", "Prince", "Princess", "Prison", "Program", "Programmer", "Protagonist", "Queen", "Razor", "Rifle", "Ring", "Reptile", "Road", "River", "Science", "Situation", "Society", "Soldier", "Sound", "Steed", "Story", "Surface", "Tavern", "Tower", "Traveler", "Tree", "Undead", "Unicorn", "Vampire", "Warrior", "Wizard", "World", "Wolf", "Zombie"]
  31.    
  32.    
  33.     number_1 : IntProperty(default= 0)
  34.     number_2 : IntProperty(default= 0)
  35.     number_3 : IntProperty(default= 0)
  36.    
  37.     number_4 : IntProperty(default= 1)
  38.    
  39.    
  40.     word_count : IntProperty(default= 3, min= 1, max= 3, description= "Select How Many Words to be Generated")
  41.    
  42.     wc_bool : BoolProperty(default= False, description= "Selecting this Option will randomize the Word Count")
  43.    
  44.    
  45.    
  46.    
  47.    
  48.    
  49.  
  50.  
  51.  
  52.  
  53.  
  54. class RANDOMWORDGEN_PT_main_panel(Panel):
  55.     bl_label = "Random Word Generator"
  56.     bl_idname = "RANDOMWORDGEN_PT_main_panel"
  57.     bl_space_type = 'VIEW_3D'
  58.     bl_region_type = 'UI'
  59.     bl_category = "Random Word Gen"
  60.  
  61.     def draw(self, context):
  62.         layout = self.layout
  63.         scene = context.scene
  64.         mytool = scene.my_tool
  65.        
  66.         wc = mytool.word_count
  67.         r_wc = mytool.wc_bool
  68.        
  69.        
  70.        
  71.        
  72.            
  73.            
  74.         if r_wc == False:
  75.             layout.prop(mytool, "word_count", text= "Word Count")
  76.             row = layout.row()
  77.        
  78.             if wc >= 1:
  79.                 row.label(text= mytool.list_a[mytool.number_1])
  80.             if wc >= 2:
  81.                 row.label(text= mytool.list_b[mytool.number_2])
  82.             if wc >= 3:
  83.                 row.label(text= mytool.list_c[mytool.number_3])
  84.         else:
  85.             row = layout.row()
  86.             if mytool.number_4 >= 1:
  87.                 row.label(text= mytool.list_a[mytool.number_1])
  88.             if mytool.number_4 >= 2:
  89.                 row.label(text= mytool.list_b[mytool.number_2])
  90.             if mytool.number_4 >= 3:
  91.                 row.label(text= mytool.list_c[mytool.number_3])
  92.         layout.prop(mytool, "wc_bool", text= "Randomize Word Count")        
  93.                            
  94.        
  95.  
  96.        
  97.         layout.operator("randomwordgen.myop_operator")
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. class RANDOMWORDGEN_OT_my_op(Operator):
  105.     bl_label = "Generate Random Words"
  106.     bl_idname = "randomwordgen.myop_operator"
  107.    
  108.    
  109.    
  110.     def execute(self, context):
  111.         scene = context.scene
  112.         mytool = scene.my_tool
  113.        
  114.         a = 0
  115.        
  116.        
  117.         b2 = len(mytool.list_a)
  118.         b = b2 - 1
  119.        
  120.         c2 = len(mytool.list_b)
  121.         c = c2 - 1
  122.        
  123.         d2 = len(mytool.list_c)
  124.         d = d2 - 1
  125.        
  126.         e = 1
  127.         f = 3
  128.        
  129.         r1 = randint(a, b)
  130.         r2 = randint(a, c)
  131.         r3 = randint(a, d)
  132.        
  133.         r4 = randint(e, f)
  134.        
  135.         mytool.number_1 = r1
  136.         mytool.number_2 = r2
  137.         mytool.number_3 = r3
  138.        
  139.         mytool.number_4 = r4
  140.        
  141.        
  142.        
  143.        
  144.        
  145.         return {'FINISHED'}
  146.    
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. classes = [RandomWordGenProperties, RANDOMWORDGEN_PT_main_panel, RANDOMWORDGEN_OT_my_op]
  157.  
  158.  
  159.  
  160. def register():
  161.     for cls in classes:
  162.         bpy.utils.register_class(cls)
  163.        
  164.     bpy.types.Scene.my_tool = PointerProperty(type= RandomWordGenProperties)
  165.  
  166. def unregister():
  167.     for cls in classes:
  168.         bpy.utils.unregister_class(cls)
  169.     del bpy.types.Scene.my_tool
  170.  
  171.  
  172.  
  173. if __name__ == "__main__":
  174.     register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement