La cosa es que los quesitos, (arepas), están hechos de una manera poco ortodoxa, lo normal hubiese sido fabricar una malla con radianes y ángulos con las librerías que hay para eso, pero en el script lo que hice fué sacar una curva bezier aplanarlo, cambiarle el centro y darle un screw para que luego se pueda animar la vaina con mas fácilidad.
La extrusión está hecha con el solidify, asi que para perfilar el bevel hay que subir demasiado la resolución de la curva, si lo quieres mas perfilado prueba a quitar el solidify y a setear la curva a 2d y extrusión.
..otro tip!
Sabias Que..?
..manteniendo Shift es posible elegir múltiples opciones en los widgets de transformación? (por ejemplo: mostrar el widget de posición y escala simultáneamente)
23 mensajes
• Página 1 de 2 • 1, 2
No.. lo de la curve (que no se si te iria mejor con una Path) ya esta bien, y lo de solidify, porque si no, no tendría volumen.
Y Bevel, que yo haya visto no tiene...
Se trataría como te he dicho de colocarle luego del solidify, un modifier de tipo EDGE_SPLIT
Pero tranquilo, que no pasa nada, si no se puede, no se puede.
Gracias por tu tiempo.
Y Bevel, que yo haya visto no tiene...
Se trataría como te he dicho de colocarle luego del solidify, un modifier de tipo EDGE_SPLIT
Pero tranquilo, que no pasa nada, si no se puede, no se puede.
Gracias por tu tiempo.
-

soliman - Face
- 239 Mensajes
hola,
Gracias por su guión.
A mí me gusta mucho.
Mi amigo PKHG ha hecho algunos cambios para Blender 2.59
He hecho una descarga en mi colección de secuencias de comandos svn.
Esperamos que de esta manera.
Usted es bienvenido a unirse a este proyecto aquí:
https://sourceforge.net/projects/blenderpython/
Que se inscribe en Sourceforge https://sourceforge.net/
Que me haga saber su nombre de usuario y te puedo dar acceso a SVN para desarrollar su guión
Gracias.
Brendon Murphy
Addona dev y colector de guión
Nota: Tus amigos aquí son bienvenidos a unirse al proyecto.
Nota 2: I utilizar el traductor de Google para este post
Gracias por su guión.
A mí me gusta mucho.
Mi amigo PKHG ha hecho algunos cambios para Blender 2.59
He hecho una descarga en mi colección de secuencias de comandos svn.
Esperamos que de esta manera.
Usted es bienvenido a unirse a este proyecto aquí:
https://sourceforge.net/projects/blenderpython/
Que se inscribe en Sourceforge https://sourceforge.net/
Que me haga saber su nombre de usuario y te puedo dar acceso a SVN para desarrollar su guión
Gracias.
Brendon Murphy
Addona dev y colector de guión
Nota: Tus amigos aquí son bienvenidos a unirse al proyecto.
Nota 2: I utilizar el traductor de Google para este post
-

meta-androcto - Recién llegado!
- 3 Mensajes
Enlace a la actualización del guión
http://blenderpython.svn.sourceforge.net/viewvc/blenderpython/259/scripts/addons_extern/chart_generator/?view=tar
http://blenderpython.svn.sourceforge.net/viewvc/blenderpython/259/scripts/addons_extern/chart_generator/?view=tar
-

meta-androcto - Recién llegado!
- 3 Mensajes
Excelente que alguien esté metiendo mano a esto, yo ando liadito con otras cosas, mucha gente necesitaba que las gráficas se animaran solas por si a tu amigo le apetece hacerlo, sería genial.
Dale las gracias de mi parte. :-)
Dale las gracias de mi parte. :-)
-

klibre - Face
- Desde: Caracas
- 108 Mensajes
Muy buen aporte!!!!
"... Si lo que quieren es ahorrar trabajo ¿que demonios hacen en animación? es demasiado trabajo..." Richard Williams
web: http://www.ideasfijas.com - Blog: http://www.alejandrocarlini.com.ar
web: http://www.ideasfijas.com - Blog: http://www.alejandrocarlini.com.ar
-

Ales - Edge
- Desde: San Luis - Argentina
- 82 Mensajes
hola,
Gracias,
Te he añadido a la colección aquí:
https://sourceforge.net/projects/blenderpython/
Usted puede usar SVN para hacer de su escritura y cualquier otra que se escribe
Sus amigos también son bienvenidos.
Gracias por tu trabajo.
Brendon.
Gracias,
Te he añadido a la colección aquí:
https://sourceforge.net/projects/blenderpython/
Usted puede usar SVN para hacer de su escritura y cualquier otra que se escribe

Sus amigos también son bienvenidos.
Gracias por tu trabajo.
Brendon.
-

meta-androcto - Recién llegado!
- 3 Mensajes
Gracias meta-androcto, ya estoy dando una vuelta por el svn voy a ver que se puede hacer por allí, corto y cierro.
-

klibre - Face
- Desde: Caracas
- 108 Mensajes
Les dejo el script actualizado con algunas funcionalidades más, tal como factor de escala, multicolumnas, animación y alineación de los textos a la cámara.
Espero que nunca les encarguen en el laburo hacer gráficas de barras, en caso contrario espero que les sirva..
http://www.klibre.net.ve/descargas/generador.txt
Pd: El que quiera cambiar el time de la animación hay una variable global para eso, se me olvidó explicarlo en el tuto.
Espero que nunca les encarguen en el laburo hacer gráficas de barras, en caso contrario espero que les sirva..
http://www.klibre.net.ve/descargas/generador.txt
- Código: Seleccionar todo
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Chart Graphics Generator",
"author": "klibre, PKHG, thanks to JesterKing, Oscurart, Carlos Guerrero",
"version": (0,0,4),
"blender": (2, 5, 9),
"api": 40101,
"category": "Add Curve",
"location": "View3d > Tools",
"description": "Tool to build bar graphics from csv databases,",
"warning": "",
"wiki_url": "",
"tracker_url": "http://blenderpython.svn.sourceforge.net/viewvc/blenderpython/259/scripts/addons_extern/chart_generator/",}
#----------------------------------------------------
import bpy
import csv
from math import pi
import mathutils
import random
import sys
#-------------------globals---------------------------------
pid2 = pi * 0.5
sce = bpy.context.scene
obj = bpy.context.object
bc = bpy.context
boo = bpy.ops.object
bot = bpy.ops.transform
suma = 0
chartType = '' #not yet used
negativValueSeen = False
sizesCVSfile = None
colnrPKHG = '-1'
factorescala = 5
cvs_colums = 0
allData = None
sce.frame_start = 0
#sce.frame_end = 500
time = 20
origin = bc.scene.cursor_location
#-------------------end globals---------------------------------
def interuptMe(where,debug = True):
if debug:
print(where);
__import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()})
def getCSV(path):
global sizesCVSfile, cvs_colums
result = False
try:
csvfile = open(path, 'r')
dialect = csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
# reader = csv.DictReader(csvfile, dialect=dialect) #no not needed
reader = csv.reader(csvfile, dialect=dialect)
csvData = []
for data in reader:
csvData.append(data)
result = csvData
cvs_rows = len(result)
cvs_colums = len(result[0])
sizesCVSfile = [cvs_colums, cvs_rows]
csvfile.close()
except:
print("no good csv file adress given!")
self.report({'INFO'}, "no good csv file adress given!")
return result
#
#
#def finalfps():
# if bpy.ops.screen.keyframe_jump(next=True) == true :
#
# bpy.ops.screen.keyframe_jump(next=True)
#
# else :
#
# return {"FINISHED"}
class ImportadorUI(bpy.types.Panel):
bl_label = "Generador de Graficas"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
def draw(self, context):
global colnrPKHG, allData, cvs_colums, time
layout = self.layout
col = layout.column(align=1)
row = layout.row()
split=row.split()
col.label("Path of the CSV file:")
row.operator("lee.ruta",icon="FILE_SCRIPT")
col = split.column()
col.prop(bc.scene,"importPydataPath")
row = layout.row()
row.prop(bc.scene,"useColumnNr")
colnrPKHG = bc.scene.useColumnNr
path = bc.scene.importPydataPath
check = getCSV(path)
if colnrPKHG >= cvs_colums:
print("column ", colnrPKHG," not possible")
elif check:
allData = check
row=layout.row()
split=row.split()
colL0 = split.column()
colL0.label("Graphic Type:")
row = layout.row()
row.prop(bc.scene,"scaleFactor")
factorescala = bc.scene.scaleFactor
row=layout.row()
split=row.split()
colL1 = split.column()
colL1.operator("importador.cubos", icon="MESH_CUBE")
colR1 = split.column()
colR1.operator("importador.cilindros", icon="MESH_CYLINDER")
colL3 = split.column()
colL3.operator("fabricar.quesito", icon="MESH_CIRCLE")
row=layout.row()
split=row.split()
colL5 = split.column()
if suma <= 1:
print("build graphic before")
elif check:
allData = check
colL5.label("Configuration:")
row=layout.row()
split=row.split()
colR2 = split.column()
colR2.operator("calculo.porcentajes", icon="LINENUMBERS_ON")
split=row.split()
colL4 = split.column()
colL4.operator("align.data", icon="FONTPREVIEW")
colL5 = split.column()
colL5.operator("colorear.grafica", icon="MATERIAL")
row=layout.row()
split=row.split()
colL2 = split.column()
colL2.operator("hard.edges", icon="MOD_EDGESPLIT")
class leeruta (bpy.types.Operator):
bl_idname = "lee.ruta"
bl_label = "Leer"
def execute(self,context):
global path
path = bc.scene.importPydataPath
return {"FINISHED"}
class formatcurves (bpy.types.Operator):
'''format data for values'''
bl_idname = "format.curves"
bl_label = "format curves"
def execute(self,context):
# boo.convert(target='CURVE', keep_original=False)
bc.selected_objects[0].data.extrude = 0.01
bc.selected_objects[0].data.bevel_depth = 0.005
return {"FINISHED"}
class importadorcubos(bpy.types.Operator):
"""importa data, fabica cubos con los datos"""
bl_idname = "importador.cubos"
bl_label = "Cubes"
def execute(self,context):
global colnrPKHG, allData, chartType, time, factorescala, origin
chartType = 'cubos'
distancia= 0
iescalado = 0
factorescala = bc.scene.scaleFactor
for data in allData:
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
if escalado >= 0:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2]+((escalado)*2)+0.2)),rotation=(pid2, 0, 0))
else:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2] + 0.2)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[colnrPKHG], accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
bpy.ops.mesh.primitive_cube_add(location=((origin[0] + distancia+1),(origin[1] +1.5),(origin[2] + escalado)))
bot.resize(value=(1,1,escalado))
# [end a simple animation]
boo.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
boo.transform_apply(scale=True)
iescalado += escalado + 10
bpy.ops.anim.change_frame(frame = (iescalado+time))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
bpy.ops.anim.change_frame(frame = (iescalado))
bot.resize(value=(1,1,0.01))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
# [end a simple animation]
boo.modifier_add(type='BEVEL')
boo.editmode_toggle()
bpy.ops.mesh.faces_shade_smooth()
boo.editmode_toggle()
boo.select_all(action='DESELECT')
bpy.ops.ver.nombres()
bpy.ops.calculo.total()
return {"FINISHED"}
class importadorcilindros (bpy.types.Operator):
"""importa data, fabica cilindros y los textcurves con la data"""
bl_idname = "importador.cilindros"
bl_label = "Cylinders"
def execute(self,context):
global colnrPKHG, allData, chartType, origin
factorescala = bc.scene.scaleFactor
chartType = 'cylinders'
distancia= 0
iescalado = 0
bpy.ops.ver.nombres()
bpy.ops.calculo.total()
for data in allData:
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
if escalado >= 0:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2]+((escalado)*2)+0.2)),rotation=(pid2, 0, 0))
else:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2] + 0.2)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[colnrPKHG], accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
bpy.ops.mesh.primitive_cylinder_add(location=((origin[0] + distancia+1),(origin[1] +1.5),(origin[2] + escalado)))
bot.resize(value=(1,1,escalado))
# [end a simple animation]
boo.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
boo.transform_apply(scale=True)
iescalado += escalado + 10
bpy.ops.anim.change_frame(frame = (iescalado+time))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
bpy.ops.anim.change_frame(frame = (iescalado))
bot.resize(value=(1,1,0.01))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
# [end a simple animation]
boo.modifier_add(type='BEVEL')
boo.editmode_toggle()
bpy.ops.mesh.faces_shade_smooth()
boo.editmode_toggle()
boo.select_all(action='DESELECT')
bpy.ops.ver.nombres()
bpy.ops.calculo.total()
return {"FINISHED"}
class calculototal (bpy.types.Operator):
"""muestra la suma total de los elementos"""
bl_idname = "calculo.total"
bl_label = "Total"
def execute(self,context):
global colnrPKHG, allData, suma , negativValueSeen, factorescala, origin
negativValueSeen = False #assume OK at start
suma = 0
for data in allData:
tmp = float(data[colnrPKHG])
if tmp < 0:
negativValueSeen = True
self.report({'WARNING'}, "negative value occured")
print("error: not meaningfull with negativ values")
return {"CANCELLED"}
suma += tmp
sumados ="total:" + str(suma)
boo.text_add(location=((origin[0]-1.5),origin[1],(origin[2] + 3)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(sumados), accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
sce.frame_end = suma + 30
boo.select_all(action='DESELECT')
return {"FINISHED"}
class calculoporcentajes (bpy.types.Operator):
bl_idname = "calculo.porcentajes"
bl_label = "percentages"
def execute(self,context):
global colnrPKHG, allData, suma, negativValueSeen, factorescala, origin
distancia= 0
bpy.ops.calculo.total()
print("\n?????? negativValueSeen", negativValueSeen)
if negativValueSeen:
self.report({'WARNING'}, "negative value occured")
return {'CANCELLED'}
for data in allData:
distancia += 3
sumando = float(data[colnrPKHG])
if sumando >= 0:
porciento = '{:.2%}.'.format(sumando/suma)
escalado = float(data[colnrPKHG])/factorescala
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2] + (escalado*2)+1.1)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(porciento), accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
boo.select_all(action='DESELECT')
else:
print("negativ value for percentage not meaningful+ ")
return {"FINISHED"}
class vernombres (bpy.types.Operator):
"""importa data, fabica cilindros y los textcurves con la data"""
bl_idname = "ver.nombres"
bl_label = "Names"
def execute(self,context):
global factorescala, origin
path = bc.scene.importPydataPath
reader = csv.reader(open(path, 'r'))
distancia= 0
#separacion de las cajitas
for data in reader:
distancia += 3
data[0]=data[0].replace(' ', '\n')
boo.text_add(location=((origin[0] + distancia),origin[1],(origin[2]+0.3)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[0], accent=False)
boo.editmode_toggle()
bot.resize(value=(0.6,0.6,0.6))
bpy.ops.format.curves()
boo.select_all(action='DESELECT')
return {"FINISHED"}
# Material by http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Materials_and_textures
class coloreargrafica (bpy.types.Operator):
"""asigna un material a la grafica azar"""
bl_idname = "colorear.grafica"
bl_label = "Paint it!"
def execute(self,context):
for ob in bpy.data.objects:
if ob.type == 'CURVE' or ob.type == 'MESH':
boo.material_slot_remove() #TODO PKHG??? i think for apply a second time
x = random.uniform(0.05, 0.95)
y = random.uniform(0.05, 0.95)
z = random.uniform(0.05, 0.95)
colordifuso = bpy.data.materials.new('RandomColor')
colordifuso.diffuse_color = (x,y,z)
colordifuso.specular_color = ((x+0.4),(y+0.4),(z+0.4))
colordifuso.specular_intensity = (0.7)
boo.select_all(action='DESELECT')
boo.select_by_type(extend=False, type='MESH')
# boo.join()
bc.object.data.materials.append(colordifuso)
boo.select_all(action='DESELECT')
else:
self.report({'INFO'}, "Please. select any object before")
return{'FINISHED'}
class fabricarquesito (bpy.types.Operator):
"""Viva la arepa"""
bl_idname = "fabricar.quesito"
bl_label = "Arepas"
def execute(self,context):
global colnrPKHG, allData, chartType, suma
chartType = 'arepas'
tmp = [ float(el[colnrPKHG]) for el in allData if float(el[colnrPKHG]) > 0]
suma = sum(tmp)
if suma == 0:
self.report({'WARNING'}, "not one positive value given")
print("\n***error*** a pie-chart needs at least ONE positive value!")
return {'CANCELLED'}
origin = bpy.context.scene.cursor_location
distancia= 0
desfase = 1.1
objList = []
counter = 0
for data in allData:
counter += 1
sumando = float(data[colnrPKHG])
if sumando <= 0:
#PKHG zero and negative not handled, not meaningful in pie-charts
message = "not strict positiv value seen: " + str(sumando) + " at row " + str(counter)
self.report({'WARNING'}, message) #only two parameters allowed!
# print({'WARNING'}, "not strict positiv value seen: ", sumando," not used")
continue
porciento = sumando/suma
porciento2 = porciento * pi * 2
bpy.ops.curve.primitive_bezier_curve_add( location=(origin[0],origin[1],origin[2]))
bot.translate(value=(desfase,0,0))
boo.editmode_toggle()
bot.translate(value=(1,0,0))
bot.resize(value=(1,0,0))
boo.editmode_toggle()
boo.modifier_add(type='SCREW')
obj = bc.selected_objects[0]
obj.modifiers['Screw'].angle = 0
print(sumando, suma, porciento, porciento2)
obj.keyframe_insert(data_path='modifiers["Screw"].angle', frame = sumando)
obj.modifiers['Screw'].angle = porciento2
boo.select_all(action='TOGGLE')
boo.select_all(action='TOGGLE')
bot.rotate(value=(-porciento2,), axis=(0,0,1), constraint_orientation='GLOBAL')
obj.keyframe_insert(data_path='modifiers["Screw"].angle', frame = (sumando+time))
boo.modifier_add(type='SOLIDIFY')
obj.modifiers['Solidify'].thickness = 0.7
boo.modifier_add(type='EDGE_SPLIT')
porciento3 = '{:.2%}.'.format(sumando/suma)
objList.append(bc.active_object)
boo.text_add(location=((origin[0]),(origin[1]),(origin[2]+0.3)),rotation=(pi/2, 0, porciento2/2))
objList.append(bc.active_object)
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(" "+porciento3), accent=False)
boo.editmode_toggle()
bot.rotate(value=(-porciento2,), axis=(0,0,1), constraint_orientation='GLOBAL')
bot.resize(value=(0.5,0.5,0.5))
bot.translate(value=(4, 0, 0), constraint_axis=(True,False,False), constraint_orientation='NORMAL')
bpy.ops.format.curves()
for el in objList:
el.location = origin
bpy.ops.calculo.total()
return{'FINISHED'}
class aligncurvestocamera (bpy.types.Operator):
"""Align data to camera"""
bl_idname = "align.data"
bl_label = "Align data"
def execute(self,context):
boo.select_by_type(type='FONT')
if bc.selected_objects[0].type == 'FONT':
boo.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
boo.visual_transform_apply()
bot.select_orientation(orientation='VIEW')
bot.transform(mode='ALIGN', constraint_orientation='VIEW')
boo.select_all(action='DESELECT')
#
# else:
# message = "You have to build data before"
# self.report({'WARNING'}, message)
#
return{'FINISHED'}
class hardedges (bpy.types.Operator):
"""hARD EDGES gracias Soliman"""
bl_idname = "hard.edges"
bl_label = "Hard Edges"
global allData
def execute(self,context):
boo.modifier_add(type='EDGE_SPLIT')
return{'FINISHED'}
#-----REGISTROS------------------------
def register():
## CREO DATA FILEPATH
bpy.types.Scene.importPydataPath=bpy.props.StringProperty(default="ruta.csv")
bpy.types.Scene.useColumnNr=bpy.props.IntProperty(name = "Nr. of column to use",min = 1, max = 100, soft_max = 5, default = 1)
bpy.types.Scene.scaleFactor=bpy.props.IntProperty(name = "Scale factor",min = 1, max = 1000, soft_max = 100, default = 10)
## REGISTRA CLASSES
burc = bpy.utils.register_class
def unregister():
## DESREGISTRA CLASSES
burc = bpy.utils.unregister_class
if __name__ == "__main__":
register()
# bye bye register one to one
bpy.utils.register_module(__name__)
Pd: El que quiera cambiar el time de la animación hay una variable global para eso, se me olvidó explicarlo en el tuto.

-

klibre - Face
- Desde: Caracas
- 108 Mensajes
Gracias por el agradecimiento.. je, je.
De todas formas, yo sigo creyendo que lo que son las columnas, como también las arepas, no llevan BEVEL.
Por eso yo creía que era mejor, quitar la parte en la que añades el modificador bevel. (imagen 1)
De todas formas, si crees que si que deben de llevar le veo una solución el aplicarle el EDGE_SPLIT detrás del BEVEL (imagen 2)
Y si se puede, que ese Bevel sea un poco más pequeño...
Gracias y suerte.


De todas formas, yo sigo creyendo que lo que son las columnas, como también las arepas, no llevan BEVEL.
Por eso yo creía que era mejor, quitar la parte en la que añades el modificador bevel. (imagen 1)
De todas formas, si crees que si que deben de llevar le veo una solución el aplicarle el EDGE_SPLIT detrás del BEVEL (imagen 2)
Y si se puede, que ese Bevel sea un poco más pequeño...
Gracias y suerte.


-

soliman - Face
- 239 Mensajes
siii me imagino que mas adelante abrá algún botón para elegir entre ambas, igual que unos preset de materiales automáticos en un enumproperties pero bueno, es el primer script y todavía me lleva mucho tiempo encontrar las funciones en la api, asi que de poco a poco,
Aquí en esta línea tienes lo del bevel a tu gusto
para bajarlo un poco
Aquí en esta línea tienes lo del bevel a tu gusto
para bajarlo un poco- Código: Seleccionar todo
bpy.context.selected_objects[0].modifiers['Bevel'].width = 0.2
-

klibre - Face
- Desde: Caracas
- 108 Mensajes
Les dejo el script de las gráficas actualizado y el video de lo nuevo, no está muy mejorado pero tiene una nueva función para líneas comparativas múltiples, quizá a alguien le esté haciendo falta..
- Código: Seleccionar todo
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Chart Graphics Generator",
"author": "klibre, PKHG, thanks to JesterKing, Oscurart, Carlos Guerrero",
"version": (0,0,4),
"blender": (2, 5, 9),
"api": 40101,
"category": "Add Curve",
"location": "View3d > Tools",
"description": "Tool to build bar graphics from csv databases,",
"warning": "",
"wiki_url": "",
"tracker_url": "http://www.klibre.net"}
#----------------------------------------------------
import bpy
import csv
from math import pi
import mathutils
import random
import sys
#-------------------globals---------------------------------
pid2 = pi * 0.5
sce = bpy.context.scene
obj = bpy.context.object
bc = bpy.context
boo = bpy.ops.object
boc = bpy.ops.curve
bot = bpy.ops.transform
suma = 0
chartType = '' #not yet used
negativValueSeen = False
sizesCVSfile = None
colnrPKHG = '-1'
factorescala = 5
cvs_colums = 0
allData = None
sce.frame_start = 0
#sce.frame_end = 500
time = 20
origin = bc.scene.cursor_location
#-------------------end globals---------------------------------
def interuptMe(where,debug = True):
if debug:
print(where);
__import__('code').interact(local={k: v for ns in (globals(), locals()) for k, v in ns.items()})
def getCSV(path):
global sizesCVSfile, cvs_colums
result = False
try:
csvfile = open(path, 'r')
dialect = csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
reader = csv.reader(csvfile, dialect=dialect)
csvData = []
for data in reader:
csvData.append(data)
result = csvData
cvs_rows = len(result)
cvs_colums = len(result[0])
sizesCVSfile = [cvs_colums, cvs_rows]
csvfile.close()
except:
print("no good csv file adress given!")
self.report({'INFO'}, "no good csv file adress given!")
return result
#
#
#def finalfps():
# if bpy.ops.screen.keyframe_jump(next=True) == true :
#
# bpy.ops.screen.keyframe_jump(next=True)
#
# else :
#
# return {"FINISHED"}
class ImportadorUI(bpy.types.Panel):
bl_label = "Generador de Graficas"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
def draw(self, context):
global colnrPKHG, allData, cvs_colums, time
layout = self.layout
col = layout.column(align=1)
row = layout.row()
split=row.split()
col.label("Path of the CSV file:")
row.operator("lee.ruta",icon="FILE_SCRIPT")
col = split.column()
col.prop(bc.scene,"importPydataPath")
row = layout.row()
row.prop(bc.scene,"useColumnNr")
colnrPKHG = bc.scene.useColumnNr
path = bc.scene.importPydataPath
check = getCSV(path)
if colnrPKHG >= cvs_colums:
print("column ", colnrPKHG," not possible")
elif check:
allData = check
row=layout.row()
split=row.split()
colL0 = split.column()
colL0.label("Graphic Type:")
row = layout.row()
row.prop(bc.scene,"scaleFactor")
factorescala = bc.scene.scaleFactor
row=layout.row()
split=row.split()
colL1 = split.column()
colL1.operator("importador.cubos", icon="MESH_CUBE")
colR1 = split.column()
colR1.operator("importador.cilindros", icon="MESH_CYLINDER")
colL3 = split.column()
colL3.operator("importador.trazos", icon="CURVE_DATA")
colL6 = split.column()
colL6.operator("fabricar.quesito", icon="MESH_CIRCLE")
row=layout.row()
split=row.split()
colL5 = split.column()
if suma <= 1:
print("build graphic before")
elif check:
allData = check
colL5.label("Configuration:")
row=layout.row()
split=row.split()
colR2 = split.column()
colR2.operator("calculo.porcentajes", icon="LINENUMBERS_ON")
split=row.split()
colL4 = split.column()
colL4.operator("align.data", icon="FONTPREVIEW")
colL5 = split.column()
colL5.operator("colorear.grafica", icon="MATERIAL")
row=layout.row()
class leeruta (bpy.types.Operator):
bl_idname = "lee.ruta"
bl_label = "Leer"
def execute(self,context):
global path
path = bc.scene.importPydataPath
return {"FINISHED"}
class formatcurves (bpy.types.Operator):
'''format data for values'''
bl_idname = "format.curves"
bl_label = "format curves"
def execute(self,context):
# boo.convert(target='CURVE', keep_original=False)
bc.selected_objects[0].data.extrude = 0.01
bc.selected_objects[0].data.bevel_depth = 0.005
return {"FINISHED"}
class importadorcubos(bpy.types.Operator):
"""importa data, fabica cubos con los datos"""
bl_idname = "importador.cubos"
bl_label = "Cubes"
def execute(self,context):
global colnrPKHG, allData, chartType, origin
factorescala = bc.scene.scaleFactor
chartType = 'cubes'
distancia= 0
iescalado = 0
bpy.ops.ver.nombres()
bpy.ops.calculo.total()
for data in allData:
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
if escalado >= 0:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2]+((escalado)*2)+0.2)),rotation=(pid2, 0, 0))
else:
negativValueSeen = True
self.report({'WARNING'}, "negative value occured")
print("error: not meaningfull with negativ values")
return {"CANCELLED"}
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[colnrPKHG], accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
bpy.ops.mesh.primitive_cube_add(location=((origin[0] + distancia+1),(origin[1] +1.5),(origin[2] + escalado)))
bot.resize(value=(1,1,escalado))
# [end a simple animation]
boo.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
boo.transform_apply(scale=True)
iescalado += escalado + 10
bpy.ops.anim.change_frame(frame = (iescalado+time))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
bpy.ops.anim.change_frame(frame = (iescalado))
bot.resize(value=(1,1,0.01))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
# [end a simple animation]
boo.editmode_toggle()
bpy.ops.mesh.faces_shade_smooth()
boo.editmode_toggle()
boo.select_all(action='DESELECT')
return {"FINISHED"}
class importadorcilindros (bpy.types.Operator):
"""importa data, fabica cilindros y los textcurves con la data"""
bl_idname = "importador.cilindros"
bl_label = "Cylinders"
def execute(self,context):
global colnrPKHG, allData, chartType, origin
factorescala = bc.scene.scaleFactor
chartType = 'cylinders'
distancia= 0
iescalado = 0
bpy.ops.ver.nombres()
bpy.ops.calculo.total()
for data in allData:
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
if escalado >= 0:
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2]+((escalado)*2)+0.2)),rotation=(pid2, 0, 0))
else:
negativValueSeen = True
self.report({'WARNING'}, "negative value occured")
print("error: not meaningfull with negativ values")
return {"CANCELLED"}
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[colnrPKHG], accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
bpy.ops.mesh.primitive_cylinder_add(location=((origin[0] + distancia+1),(origin[1] +1.5),(origin[2] + escalado)))
bot.resize(value=(1,1,escalado))
# [end a simple animation]
boo.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
boo.transform_apply(scale=True)
iescalado += escalado + 10
bpy.ops.anim.change_frame(frame = (iescalado+time))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
bpy.ops.anim.change_frame(frame = (iescalado))
bot.resize(value=(1,1,0.01))
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
# [end a simple animation]
boo.editmode_toggle()
bpy.ops.mesh.faces_shade_smooth()
boo.editmode_toggle()
boo.select_all(action='DESELECT')
return {"FINISHED"}
class trazador (bpy.types.Operator):
"""importa data, fabica lineas y los textcurves con la data"""
bl_idname = "importador.trazos"
bl_label = "Lineas"
def execute(self,context):
global colnrPKHG, allData, chartType, origin
factorescala = bc.scene.scaleFactor
chartType = 'trazos'
bpy.ops.ver.nombres()
count = 0
while colnrPKHG > 0:
boc.primitive_bezier_curve_add(enter_editmode=True, location=((origin[0]),origin[1],origin[2]))
boc.delete(type='ALL')
curvita2 = bc.selected_objects[0]
curvita2.data.extrude = 0.3 /factorescala
distancia= 0
for data in allData:
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
boc.vertex_add(location=(origin[0] + distancia + 0.5,origin[1],(origin[2]+(escalado)+0.2)))
boc.handle_type_set(type='VECTOR')
bpy.ops.curve.select_all(action='TOGGLE')
bpy.ops.curve.select_all(action='TOGGLE')
boc.subdivide(number_cuts=1)
boo.modifier_add(type='BUILD')
boc.handle_type_set(type='FREE_ALIGN')
boo.editmode_toggle()
boo.convert(target='MESH')
boo.modifier_add(type='BUILD')
distancia= 0
for data in allData:
++count
print (count)
distancia += 3
escalado = float(data[colnrPKHG])/factorescala
if escalado >= 0:
boo.text_add(location=((origin[0] + distancia ),(origin[1]-0.2),(origin[2]+escalado+0.8)),rotation=(pid2, 0, 0))
else:
negativValueSeen = True
self.report({'WARNING'}, "negative value occured")
print("error: not meaningfull with negativ values")
return {"CANCELLED"}
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[colnrPKHG], accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
colnrPKHG -=1
return {"FINISHED"}
class calculototal (bpy.types.Operator):
"""muestra la suma total de los elementos"""
bl_idname = "calculo.total"
bl_label = "Total"
def execute(self,context):
global colnrPKHG, allData, suma , negativValueSeen, factorescala, origin
negativValueSeen = False #assume OK at start
suma = 0
for data in allData:
tmp = float(data[colnrPKHG])
if tmp < 0:
negativValueSeen = True
self.report({'WARNING'}, "negative value occured")
print("error: not meaningfull with negativ values")
return {"CANCELLED"}
suma += tmp
sumados ="total:" + str(suma)
boo.text_add(location=((origin[0]-1.5),origin[1],(origin[2] + 3)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(sumados), accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
sce.frame_end = suma + 30
boo.select_all(action='DESELECT')
return {"FINISHED"}
class calculoporcentajes (bpy.types.Operator):
bl_idname = "calculo.porcentajes"
bl_label = "percentages"
def execute(self,context):
global colnrPKHG, allData, suma, negativValueSeen, factorescala, origin
distancia= 0
bpy.ops.calculo.total()
print("\n?????? negativValueSeen", negativValueSeen)
if negativValueSeen:
self.report({'WARNING'}, "negative value occured")
return {'CANCELLED'}
for data in allData:
distancia += 3
sumando = float(data[colnrPKHG])
if sumando >= 0:
porciento = '{:.2%}.'.format(sumando/suma)
escalado = float(data[colnrPKHG])/factorescala
boo.text_add(location=((origin[0] + distancia),(origin[1]+1.5),(origin[2] + (escalado*2)+1.1)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(porciento), accent=False)
boo.editmode_toggle()
bpy.ops.format.curves()
boo.select_all(action='DESELECT')
else:
print("negativ value for percentage not meaningful+ ")
return {"FINISHED"}
class vernombres (bpy.types.Operator):
"""importa data, fabica cilindros y los textcurves con la data"""
bl_idname = "ver.nombres"
bl_label = "Names"
def execute(self,context):
global factorescala, origin
path = bc.scene.importPydataPath
reader = csv.reader(open(path, 'r'))
distancia= 0
#separacion de las cajitas
for data in reader:
distancia += 3
data[0]=data[0].replace(' ', '\n')
boo.text_add(location=((origin[0] + distancia),origin[1],(origin[2]+0.3)),rotation=(pid2, 0, 0))
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=data[0], accent=False)
boo.editmode_toggle()
bot.resize(value=(0.6,0.6,0.6))
bpy.ops.format.curves()
boo.select_all(action='DESELECT')
return {"FINISHED"}
# Material by http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Materials_and_textures
class coloreargrafica (bpy.types.Operator):
"""asigna un material a la grafica azar"""
bl_idname = "colorear.grafica"
bl_label = "Paint it!"
def execute(self,context):
for ob in bpy.data.objects:
if ob.type == 'CURVE' or ob.type == 'MESH':
boo.material_slot_remove() #TODO PKHG??? i think for apply a second time
x = random.uniform(0.05, 0.95)
y = random.uniform(0.05, 0.95)
z = random.uniform(0.05, 0.95)
colordifuso = bpy.data.materials.new('RandomColor')
colordifuso.diffuse_color = (x,y,z)
colordifuso.specular_color = ((x+0.4),(y+0.4),(z+0.4))
colordifuso.specular_intensity = (0.7)
boo.select_all(action='DESELECT')
boo.select_by_type(extend=False, type='MESH')
bc.object.data.materials.append(colordifuso)
boo.select_all(action='DESELECT')
else:
self.report({'INFO'}, "Please. select any object before")
return{'FINISHED'}
class fabricarquesito (bpy.types.Operator):
"""Viva la arepa"""
bl_idname = "fabricar.quesito"
bl_label = "Arepas"
def execute(self,context):
global colnrPKHG, allData, chartType, suma
chartType = 'arepas'
tmp = [ float(el[colnrPKHG]) for el in allData if float(el[colnrPKHG]) > 0]
suma = sum(tmp)
if suma == 0:
self.report({'WARNING'}, "not one positive value given")
print("\n***error*** a pie-chart needs at least ONE positive value!")
return {'CANCELLED'}
origin = bpy.context.scene.cursor_location
distancia= 0
desfase = 1.1
objList = []
counter = 0
for data in allData:
counter += 1
sumando = float(data[colnrPKHG])
if sumando <= 0:
#PKHG zero and negative not handled, not meaningful in pie-charts
message = "not strict positiv value seen: " + str(sumando) + " at row " + str(counter)
self.report({'WARNING'}, message) #only two parameters allowed!
# print({'WARNING'}, "not strict positiv value seen: ", sumando," not used")
continue
porciento = sumando/suma
porciento2 = porciento * pi * 2
bpy.ops.curve.primitive_bezier_curve_add( location=(origin[0],origin[1],origin[2]))
bot.translate(value=(desfase,0,0))
boo.editmode_toggle()
bot.translate(value=(1,0,0))
bot.resize(value=(1,0,0))
boo.editmode_toggle()
boo.modifier_add(type='SCREW')
obj = bc.selected_objects[0]
obj.modifiers['Screw'].angle = 0
obj.keyframe_insert(data_path='modifiers["Screw"].angle', frame = sumando)
obj.modifiers['Screw'].angle = porciento2
boo.select_all(action='TOGGLE')
boo.select_all(action='TOGGLE')
bot.rotate(value=(-porciento2,), axis=(0,0,1), constraint_orientation='GLOBAL')
obj.keyframe_insert(data_path='modifiers["Screw"].angle', frame = (sumando+time))
boo.modifier_add(type='SOLIDIFY')
obj.modifiers['Solidify'].thickness = 0.7
boo.modifier_add(type='EDGE_SPLIT')
porciento3 = '{:.2%}.'.format(sumando/suma)
objList.append(bc.active_object)
boo.text_add(location=((origin[0]),(origin[1]),(origin[2]+0.3)),rotation=(pi/2, 0, porciento2/2))
objList.append(bc.active_object)
boo.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=(" "+porciento3), accent=False)
boo.editmode_toggle()
bot.rotate(value=(-porciento2,), axis=(0,0,1), constraint_orientation='GLOBAL')
bot.resize(value=(0.5,0.5,0.5))
bot.translate(value=(4, 0, 0), constraint_axis=(True,False,False), constraint_orientation='NORMAL')
bpy.ops.format.curves()
for el in objList:
el.location = origin
bpy.ops.calculo.total()
return{'FINISHED'}
class aligncurvestocamera (bpy.types.Operator):
"""Align data to camera"""
bl_idname = "align.data"
bl_label = "Align data"
def execute(self,context):
boo.select_by_type(type='FONT')
if bc.selected_objects[0].type == 'FONT':
boo.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
boo.visual_transform_apply()
bot.select_orientation(orientation='VIEW')
bot.transform(mode='ALIGN', constraint_orientation='VIEW')
boo.select_all(action='DESELECT')
#
# else:
# message = "You have to build data before"
# self.report({'WARNING'}, message)
#
return{'FINISHED'}
#-----REGISTROS------------------------
def register():
## CREO DATA FILEPATH
bpy.types.Scene.importPydataPath=bpy.props.StringProperty(default="ruta.csv")
bpy.types.Scene.useColumnNr=bpy.props.IntProperty(name = "Nr. of column to use",min = 1, max = 100, soft_max = 5, default = 1)
bpy.types.Scene.scaleFactor=bpy.props.IntProperty(name = "Scale factor",min = 1, max = 1000, soft_max = 100, default = 10)
## REGISTRA CLASSES
burc = bpy.utils.register_class
def unregister():
## DESREGISTRA CLASSES
burc = bpy.utils.unregister_class
if __name__ == "__main__":
register()
# bye bye register one to one
bpy.utils.register_module(__name__)
-

klibre - Face
- Desde: Caracas
- 108 Mensajes
23 mensajes
• Página 1 de 2 • 1, 2
Volver a Programación y Scripts
¿Quién está conectado?
Blenderheads navegando por este Foro: No hay Blenderheads registrados visitando el Foro y 1 invitado