Esempio n. 1
0
def limit(limit=1, key=''):

    from macouno import liberty
    lib = liberty.liberty('string', key)

    nuFaces = lib.makeDict(mesh_extras.get_selected_faces())
    nuLen = len(nuFaces)

    while nuLen > limit:

        deFace = lib.Choose('select', nuFaces)

        deFace.select = False

        nuFaces = lib.makeDict(mesh_extras.get_selected_faces())
        nuLen = len(nuFaces)
Esempio n. 2
0
def limit(limit=1, key=''):

	from macouno import liberty
	lib = liberty.liberty('string', key)

	nuFaces = lib.makeDict(mesh_extras.get_selected_faces())
	nuLen = len(nuFaces)
	
	while nuLen > limit:
	
		deFace = lib.Choose('select',nuFaces)
		
		deFace.select = False
	
		nuFaces = lib.makeDict(mesh_extras.get_selected_faces())
		nuLen = len(nuFaces)
Esempio n. 3
0
def limited(bm, limit, key):

    from macouno import liberty
    lib = liberty.liberty('string', key)

    selFaces = lib.makeDict([f for f in bm.faces if f.select])
    nuLen = len(selFaces)

    while nuLen > limit:

        deFace = lib.Choose('select', selFaces)

        deFace.select_set(False)

        selFaces = lib.makeDict([f for f in bm.faces if f.select])
        nuLen = len(selFaces)

    return bm
Esempio n. 4
0
def limited(bm, limit, key):

	from macouno import liberty
	lib = liberty.liberty('string', key)

	selFaces = lib.makeDict([f for f in bm.faces if f.select])
	nuLen = len(selFaces)
	
	while nuLen > limit:
	
		deFace = lib.Choose('select',selFaces)
		
		deFace.select_set(False)
	
		selFaces = lib.makeDict([f for f in bm.faces if f.select])
		nuLen = len(selFaces)
		
	return bm
Esempio n. 5
0
def liberal(key='', extend=False):

	from macouno import liberty
	lib = liberty.liberty('bool', key)

	mesh = bpy.context.active_object.data

	hasSelected = mesh_extras.contains_selected_item(mesh.faces)

	# Loop through all the given faces
	for f in mesh.faces:
			
		s = selectCheck(f.select, hasSelected, extend)
		d = deselectCheck(f.select, hasSelected, extend)
		
		# Check if the faces match any of the directions
		if s and lib.Choose('bool'):
			f.select = True
			
		if d and not lib.Choose('bool'):
			f.select = False
Esempio n. 6
0
def liberal(key='', extend=False):

    from macouno import liberty
    lib = liberty.liberty('bool', key)

    mesh = bpy.context.active_object.data

    hasSelected = mesh_extras.contains_selected_item(mesh.faces)

    # Loop through all the given faces
    for f in mesh.faces:

        s = selectCheck(f.select, hasSelected, extend)
        d = deselectCheck(f.select, hasSelected, extend)

        # Check if the faces match any of the directions
        if s and lib.Choose('bool'):
            f.select = True

        if d and not lib.Choose('bool'):
            f.select = False
	def setup(self, context, dnaString, keepgroups):
	
		print("\n\n->-> Starting Entorform <-<-\n")
		print('  - DNA string',dnaString,"\n")
		
		# Get the active object
		self.ob = context.active_object
		self.me = self.ob.data
		
		self.dnaString = dnaString
		
		# Split the dna string into two parts if possible
		prt = dnaString.partition(' ')
		if not prt[2]:
			self.dnaParts = {
				'primary': dnaString,
				'secondary': dnaString
				}
		else:
		
			sec = ''
			for i, p in enumerate(prt):
				if i > 1:
					sec = sec + p
		
			self.dnaParts = {
				'primary': prt[0],
				'secondary': sec
			}
			
		self.primary = liberty.liberty('string', self.dnaParts['secondary'])
		self.secondary = liberty.liberty('string', self.dnaParts['primary'])
		
		self.options = {}
		
		self.options['basecolor'] = [0.0,0.0,0.0]
		self.options['bool'] = {'a': True,'b': False}
		
		self.options['primary'] = {
			'translate': {'min': 2.0, 'max': 3.0},
			'scale': {'min': 0.4, 'max': 0.7},
			'crease': {'min': 0.4, 'max': 0.7},
			'bumpscale': {'min': 0.4, 'max': 0.7},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(45),'max': math.radians(75)},
			'limit': {'min': 4, 'max': 6},
			}
			
		self.options['secondary'] = {
			'translate': {'min': -0.5, 'max': 1.5},
			'scale': {'min': -0.3, 'max': 0.3},
			'crease': {'min': -0.3, 'max': 0.3},
			'bumpscale': {'min': -0.35, 'max': 0.3},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(-15),'max': math.radians(15)},
			'limit': {'min': -2, 'max': 2},
			}
			
		self.options['falloffs'] = {'a': 'LIN', 'b': 'INC', 'c': 'DEC', 'd': 'SWO', 'e': 'SPI', 'f': 'BUM', 'g': 'SWE'}
		
		self.options['bumptypes'] = {'a': 'BUM', 'b': 'SPI', 'c': 'DIM', 'd': 'PIM'}
		
		self.options['selectiontypes'] = {'a': 'direction', 'b': 'liberal', 'c': 'joint', 'd': 'all', 'e': 'checkered', 'f': 'loops'} # tip = disabled
		self.options['selectioneyes'] = {'a': 'direction', 'b': 'liberal', 'c': 'joint', 'd': 'all', 'e': 'checkered'}
		
		self.options['directions'] = {
			'a': mathutils.Vector((1.0,0.0,0.0)), 	#top
			'b': mathutils.Vector((-1.0,0.0,0.0)),	#bottom
			'c': mathutils.Vector((0.0,1.0,0.0)),		#front
			'd': mathutils.Vector((0.0,-1.0,0.0)),	#rear
			'e': mathutils.Vector((0.0,0.0,1.0)),		#right
			'f': mathutils.Vector((0.0,0.0,-1.0)),		#left
			}
			
		self.options['areatypes'] = {'a': 'area','b': 'faces'}
		self.options['frequencies'] = {'a': 1, 'b': 2}
		self.options['colorstyles'] = {'a': 'hard','b': 'soft'}
		
		self.getPalette()
		
		# Set the editing to face mode only
		#bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', value="(False, False, True)")
		
		self.startTime = time.time()
		
		self.dnaPos = 0
		self.dnaStep = 1
		self.dna = {'name':'base','strings': []}
		
		self.palette = []

		self.keepgroups = keepgroups
		
		# Total number of strings
		self.stringCount = 0
		
		# Level of deepness
		self.LOD = 2
		
		# If the grow function made a matrix previously, we can remove it now
		try:
			del(self.ob['growmatrix'])
		except:
			pass

		# Get the vertex colours
		if not self.ob.data.vertex_colors.active:
			self.ob.data.vertex_colors.new()
			for f in self.ob.data.vertex_colors.active.data:
				try:
					f.color1 = f.color2 = f.color3 = f.color4 = (0.0,0.0,0.0)
				except:
					f.color1 = f.color2 = f.color3 = (0.0,0.0,0.0)
					
		self.vCols = self.ob.data.vertex_colors.active.data
		
		# Save the dna string in a property if we want!
		self.ob['dnastring'] = dnaString
			
		# Convert the string to a list
		self.origDNA = dnaString

		self.newGroups = []
		
		# Change Selection mode to face selection
		self.lastSelectioMode = bpy.context.tool_settings.mesh_select_mode[:]
		if bpy.context.tool_settings.mesh_select_mode != (False, False, True):
			bpy.context.tool_settings.mesh_select_mode = (False, False, True)
Esempio n. 8
0
	def setup(self, context, dnaString, keepgroups):
	
		print("\n\n->-> Starting Entorform <-<-\n")
		print('  - DNA string',dnaString,"\n")
		
		# Get the active object
		self.ob = context.active_object
		self.me = self.ob.data
		
		self.dnaString = dnaString
		
		# Split the dna string into two parts if possible
		prt = dnaString.partition(' ')
		if not prt[2]:
			self.dnaParts = {
				'primary': dnaString,
				'secondary': dnaString
				}
		else:
		
			sec = ''
			for i, p in enumerate(prt):
				if i > 1:
					sec = sec + p
		
			self.dnaParts = {
				'primary': prt[0],
				'secondary': sec
			}
			
		self.primary = liberty.liberty('string', self.dnaParts['secondary'])
		self.secondary = liberty.liberty('string', self.dnaParts['primary'])
		
		self.options = {}
		
		self.options['basecolor'] = [0.0,0.0,0.0]
		self.options['bool'] = {'a': True,'b': False}
		
		self.options['primary'] = {
			'translate': {'min': 2.0, 'max': 3.0},
			'scale': {'min': 0.5, 'max': 0.6},
			'crease': {'min': 0.4, 'max': 0.7},
			'bumpscale': {'min': 0.4, 'max': 0.7},
			'rotation': {'min': math.radians(-30.0), 'max': math.radians(30.0)},
			'divergence': {'min': math.radians(-5),'max': math.radians(15)},
			'limit': {'min': 1, 'max': 1},
			}
			
		self.options['secondary'] = {
			'translate': {'min': -0.5, 'max': 1.5},
			'scale': {'min': -0.1, 'max': 0.1},
			'crease': {'min': -0.3, 'max': 0.3},
			'bumpscale': {'min': -0.35, 'max': 0.3},
			'rotation': {'min': math.radians(-30.0), 'max': math.radians(30.0)},
			'divergence': {'min': math.radians(-15),'max': math.radians(15)},
			'limit': {'min': 0, 'max': 0},
			}
			
		self.options['falloffs'] = {'a': 'LIN', 'b': 'INC', 'c': 'DEC', 'd': 'SWO', 'e': 'SPI', 'f': 'BUM', 'g': 'SWE'}
		
		self.options['bumptypes'] = {'a': 'BUM', 'b': 'SPI', 'c': 'DIM', 'd': 'PIM'}
		
		self.options['selectiontypes'] = {'a': 'direction', 'b': 'liberal', 'c': 'joint', 'd': 'all', 'e': 'checkered', 'f': 'loops'} # tip = disabled
		self.options['selectioneyes'] = {'a': 'direction', 'b': 'liberal', 'c': 'joint', 'd': 'all', 'e': 'checkered'}
		
		self.options['directions'] = {
			'a': mathutils.Vector((1.0,0.0,0.0)), 	#top
			'b': mathutils.Vector((-1.0,0.0,0.0)),	#bottom
			'c': mathutils.Vector((0.0,1.0,0.0)),		#front
			'd': mathutils.Vector((0.0,-1.0,0.0)),	#rear
			'e': mathutils.Vector((0.0,0.0,1.0)),		#right
			'f': mathutils.Vector((0.0,0.0,-1.0)),		#left
			}
			
		self.options['areatypes'] = {'a': 'area','b': 'faces'}
		self.options['frequencies'] = {'a': 1, 'b': 2}
		self.options['colorstyles'] = {'a': 'hard','b': 'soft'}
		
		self.getPalette()
		
		# Set the editing to face mode only
		#bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', value="(False, False, True)")
		
		self.startTime = time.time()
		
		self.dnaPos = 0
		self.dnaStep = 1
		self.dna = {'name':'base','strings': []}
		
		self.palette = []

		self.keepgroups = keepgroups
		
		# Total number of strings
		self.stringCount = 0
		
		# Level of deepness
		self.LOD = 2
		
		# If the grow function made a matrix previously, we can remove it now
		try:
			del(self.ob['growmatrix'])
		except:
			pass

		# Get the vertex colours
		if not self.ob.data.vertex_colors.active:
			self.ob.data.vertex_colors.new()
			for f in self.ob.data.vertex_colors.active.data:
				try:
					f.color1 = f.color2 = f.color3 = f.color4 = (0.0,0.0,0.0)
				except:
					f.color1 = f.color2 = f.color3 = (0.0,0.0,0.0)
					
		self.vCols = self.ob.data.vertex_colors.active.data
		
		# Save the dna string in a property if we want!
		self.ob['dnastring'] = dnaString
			
		# Convert the string to a list
		self.origDNA = dnaString

		self.newGroups = []
		
		# Change Selection mode to face selection
		self.lastSelectioMode = bpy.context.tool_settings.mesh_select_mode[:]
		if bpy.context.tool_settings.mesh_select_mode != (False, False, True):
			bpy.context.tool_settings.mesh_select_mode = (False, False, True)
Esempio n. 9
0
	def setup(self, context, dnaString, steplimit, keepgroups):
	
		print("\n\n->-> Starting Entorform <-<-\n")
		print('  - DNA string',dnaString,"\n")
		
		# Get the active object
		self.ob = context.active_object
		self.me = self.ob.data
		
		self.dnaString = dnaString
		self.steplimit = steplimit
		
		r = round(math.sqrt(math.sqrt(len(self.me.polygons))))
		self.clusterSize = r * r
		print('Settingcluster to',self.clusterSize)
		
		#self.clusterSize = math.floor(math.sqrt(math.sqrt(len(self.me.polygons))))
		
		# Split the dna string into two parts if possible
		prt = dnaString.partition(' ')
		if not prt[2]:
			self.dnaParts = {
				'primary': dnaString,
				'secondary': dnaString
				}
		else:
		
			sec = ''
			for i, p in enumerate(prt):
				if i > 1:
					sec = sec + p
		
			self.dnaParts = {
				'primary': prt[0],
				'secondary': sec
			}
			
		self.primary = liberty.liberty('string', self.dnaParts['secondary'])
		self.secondary = liberty.liberty('string', self.dnaParts['primary'])
		
		self.options = {}
		
		self.options['seed'] = {'min': 0, 'max': 1000000}
		self.options['basecolor'] = [0.0,0.0,0.0]
		self.options['bool'] = {'a': True,'b': False}
		
		self.options['primary'] = {
			'translate': {'min': 2.0, 'max': 5.0},
			'scale': {'min': 0.4, 'max': 0.7},
			'crease': {'min': 0.4, 'max': 0.7},
			'bumpscale': {'min': 0.4, 'max': 0.7},
			'loopscale': {'min': 0.7, 'max': 1.2},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(45),'max': math.radians(75)},
			'limit': {'min': 3, 'max': 6},
			}
			
		self.options['secondary'] = {
			'translate': {'min': -1.0, 'max': 2.0},
			'scale': {'min': -0.3, 'max': 0.3},
			'crease': {'min': -0.3, 'max': 0.3},
			'bumpscale': {'min': -0.35, 'max': 0.3},
			'loopscale': {'min': -0.2, 'max': 0.2},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(-15),'max': math.radians(15)},
			'limit': {'min': -2, 'max': 2},
			}
			
		self.options['falloffs'] = {'a': 'LIN', 'b': 'INC', 'c': 'DEC', 'd': 'SWO', 'e': 'SPI', 'f': 'BUM', 'g': 'SWE'}
		
		self.options['bumptypes'] = {'a': 'BUM', 'b': 'SPI', 'c': 'DIM', 'd': 'PIM'}
		
		# Loop corners stands for 0 = circle, 3 = triangle, 4 = square
		self.options['loopcorners'] = {'a': 0, 'b': 3, 'c': 4, 'd': 0}
		self.options['loopshapes'] = {'a': 'STR', 'b': 'BUM', 'c': 'SPI', 'd': 'SWE'}
		
		self.options['selectiontypes'] = {'a': 'direction', 'b': 'joint', 'c': 'all'}
		self.options['selectioneyes'] = {'a': 'direction', 'b': 'joint', 'c': 'all'}
		
		self.options['directions'] = {
			'a': mathutils.Vector((1.0,0.0,0.0)), 	#top
			'b': mathutils.Vector((-1.0,0.0,0.0)),	#bottom
			'c': mathutils.Vector((0.0,1.0,0.0)),		#front
			'd': mathutils.Vector((0.0,-1.0,0.0)),	#rear
			'e': mathutils.Vector((0.0,0.0,1.0)),		#right
			'f': mathutils.Vector((0.0,0.0,-1.0)),		#left
			}
			
		self.options['areatypes'] = {'a': 'area','b': 'polygons','c':'chunks'}
		self.options['frequencies'] = {'a': 1, 'b': 2}
		self.options['colorstyles'] = {'a': 'hard','b': 'soft'}
		
		self.getPalette()
		
		# Set the editing to polygon mode only
		#bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', value="(False, False, True)")
		
		self.startTime = time.time()
		
		self.dnaPos = 0
		self.dnaStep = 1
		self.dna = {'name':'base','strings': []}
		
		self.palette = []

		self.keepgroups = keepgroups
		
		# Total number of strings
		self.stringCount = 0
		
		# Level of deepness
		self.LOD = 2
		
		# If the grow function made a matrix previously, we can remove it now
		try:
			del(self.ob['growmatrix'])
		except:
			pass

		# Make sure we have vertex colors
		if self.me.vertex_colors.active:
			vertex_colors = self.me.vertex_colors.active
		else:
			vertex_colors = self.me.vertex_colors.new(name="color")
			self.me.vertex_colors.active = vertex_colors
		
		# Save the dna string in a property if we want!
		self.ob['dnastring'] = dnaString
			
		# Convert the string to a list
		self.origDNA = dnaString

		self.newGroups = []
		
		# Change Selection mode to face selection
		self.lastSelectioMode = bpy.context.tool_settings.mesh_select_mode[:]
		if bpy.context.tool_settings.mesh_select_mode != (False, False, True):
			bpy.context.tool_settings.mesh_select_mode = (False, False, True)
Esempio n. 10
0
	def setup(self, context, dnaString, steplimit, keepgroups):
	
		print("\n\n->-> Starting Entorform <-<-\n")
		print('  - DNA string',dnaString,"\n")
		
		# Get the active object
		self.ob = context.active_object
		self.me = self.ob.data
		
		self.dnaString = dnaString
		self.steplimit = steplimit
		
		r = round(math.sqrt(math.sqrt(len(self.me.polygons))))
		self.clusterSize = r * r
		print('Settingcluster to',self.clusterSize)
		
		#self.clusterSize = math.floor(math.sqrt(math.sqrt(len(self.me.polygons))))
		
		# Split the dna string into two parts if possible
		prt = dnaString.partition(' ')
		if not prt[2]:
			self.dnaParts = {
				'primary': dnaString,
				'secondary': dnaString
				}
		else:
		
			sec = ''
			for i, p in enumerate(prt):
				if i > 1:
					sec = sec + p
		
			self.dnaParts = {
				'primary': prt[0],
				'secondary': sec
			}
			
		self.primary = liberty.liberty('string', self.dnaParts['secondary'])
		self.secondary = liberty.liberty('string', self.dnaParts['primary'])
		
		self.options = {}
		
		self.options['seed'] = {'min': 0, 'max': 1000000}
		self.options['basecolor'] = [0.0,0.0,0.0]
		self.options['bool'] = {'a': True,'b': False}
		
		self.options['primary'] = {
			'translate': {'min': 2.0, 'max': 5.0},
			'scale': {'min': 0.4, 'max': 0.7},
			'crease': {'min': 0.4, 'max': 0.7},
			'bumpscale': {'min': 0.4, 'max': 0.7},
			'loopscale': {'min': 0.7, 'max': 1.2},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(45),'max': math.radians(75)},
			'limit': {'min': 3, 'max': 6},
			}
			
		self.options['secondary'] = {
			'translate': {'min': -1.0, 'max': 2.0},
			'scale': {'min': -0.3, 'max': 0.3},
			'crease': {'min': -0.3, 'max': 0.3},
			'bumpscale': {'min': -0.35, 'max': 0.3},
			'loopscale': {'min': -0.2, 'max': 0.2},
			'rotation': {'min': math.radians(-60.0), 'max': math.radians(60.0)},
			'divergence': {'min': math.radians(-15),'max': math.radians(15)},
			'limit': {'min': -2, 'max': 2},
			}
			
		self.options['falloffs'] = {'a': 'LIN', 'b': 'INC', 'c': 'DEC', 'd': 'SWO', 'e': 'SPI', 'f': 'BUM', 'g': 'SWE'}
		
		self.options['bumptypes'] = {'a': 'BUM', 'b': 'SPI', 'c': 'DIM', 'd': 'PIM'}
		
		# Loop corners stands for 0 = circle, 3 = triangle, 4 = square
		self.options['loopcorners'] = {'a': 0, 'b': 3, 'c': 4, 'd': 0}
		self.options['loopshapes'] = {'a': 'STR', 'b': 'BUM', 'c': 'SPI', 'd': 'SWE'}
		
		self.options['selectiontypes'] = {'a': 'direction', 'b': 'joint', 'c': 'all'}
		self.options['selectioneyes'] = {'a': 'direction', 'b': 'joint', 'c': 'all'}
		
		self.options['directions'] = {
			'a': mathutils.Vector((1.0,0.0,0.0)), 	#top
			'b': mathutils.Vector((-1.0,0.0,0.0)),	#bottom
			'c': mathutils.Vector((0.0,1.0,0.0)),		#front
			'd': mathutils.Vector((0.0,-1.0,0.0)),	#rear
			'e': mathutils.Vector((0.0,0.0,1.0)),		#right
			'f': mathutils.Vector((0.0,0.0,-1.0)),		#left
			}
			
		self.options['areatypes'] = {'a': 'area','b': 'polygons','c':'chunks'}
		self.options['frequencies'] = {'a': 1, 'b': 2}
		self.options['colorstyles'] = {'a': 'hard','b': 'soft'}
		
		self.getPalette()
		
		# Set the editing to polygon mode only
		#bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode', value="(False, False, True)")
		
		self.startTime = time.time()
		
		self.dnaPos = 0
		self.dnaStep = 1
		self.dna = {'name':'base','strings': []}
		
		self.palette = []

		self.keepgroups = keepgroups
		
		# Total number of strings
		self.stringCount = 0
		
		# Level of deepness
		self.LOD = 2
		
		# If the grow function made a matrix previously, we can remove it now
		try:
			del(self.ob['growmatrix'])
		except:
			pass

		# Make sure we have vertex colors
		if self.me.vertex_colors.active:
			vertex_colors = self.me.vertex_colors.active
		else:
			vertex_colors = self.me.vertex_colors.new(name="color")
			self.me.vertex_colors.active = vertex_colors
		
		# Save the dna string in a property if we want!
		self.ob['dnastring'] = dnaString
			
		# Convert the string to a list
		self.origDNA = dnaString

		self.newGroups = []
		
		# Change Selection mode to face selection
		self.lastSelectioMode = bpy.context.tool_settings.mesh_select_mode[:]
		if bpy.context.tool_settings.mesh_select_mode != (False, False, True):
			bpy.context.tool_settings.mesh_select_mode = (False, False, True)