[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2210] branches/ivygen/pkhg_ivy/ 2197_pkhg.py: more convenient changes
Peter K.H. Gragert
pkhgragert at gmail.com
Tue Aug 2 08:20:00 CEST 2011
Revision: 2210
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2210
Author: pkhg
Date: 2011-08-02 06:20:00 +0000 (Tue, 02 Aug 2011)
Log Message:
-----------
more convenient changes
deleting last and first Ivy
colors to the trunk of the Ivy too added
Modified Paths:
--------------
branches/ivygen/pkhg_ivy/2197_pkhg.py
Modified: branches/ivygen/pkhg_ivy/2197_pkhg.py
===================================================================
--- branches/ivygen/pkhg_ivy/2197_pkhg.py 2011-08-02 03:47:53 UTC (rev 2209)
+++ branches/ivygen/pkhg_ivy/2197_pkhg.py 2011-08-02 06:20:00 UTC (rev 2210)
@@ -57,8 +57,8 @@
me = ob.data
me.materials.append(mat)
pureLightingGreen = makeMaterial(name="pureLightingGreen", diffuse = [0.0, 10.0, 0.0])
+pureBrown = makeMaterial(name="pureBrown", diffuse = [4.736, .209, 0.0483])
-
def createIvyGeometry(IVY, growLeaves):
'''Create the curve geometry for IVY'''
# Compute the local size and the gauss weight filter
@@ -68,7 +68,7 @@
# Create a new curve and intialise it
curve = bpy.data.curves.new("IVY.000", type='CURVE')
curve.dimensions = '3D'
- curve.bevel_depth = 1
+ curve.bevel_depth = 5 #was 1 pkhg
curve.use_fill_front = curve.use_fill_back = False
if growLeaves:
@@ -184,6 +184,7 @@
# Add the object and link to scene
newCurve = bpy.data.objects.new("IVY_Curve.000", curve)
+ setMaterial(newCurve, pureBrown)
bpy.context.scene.objects.link(newCurve)
if growLeaves:
@@ -298,7 +299,7 @@
#local_ivySize = self.ivySize # * radius
#local_maxFloatLength = self.maxFloatLength # * radius
#local_maxAdhesionDistance = self.maxAdhesionDistance # * radius
-
+
for root in self.ivyRoots:
# Make sure the root is alive, if not, skip
if not root.alive:
@@ -442,7 +443,7 @@
climbing = True
return climbing
-class OBJECT_PT_IvyPanel(bpy.types.Panel):
+class OBJECT_PT_IvyPanelxshell(bpy.types.Panel):
bl_label = "Ivy Panel"
bl_space_type = "VIEW_3D"
bl_region_type = 'TOOL_PROPS'
@@ -451,7 +452,9 @@
sce = bpy.context.scene
layout = self.layout
row = layout.row()
- row.operator('curve.ivy_delete',text="Delete latest Ivy")
+ row.operator('curve.ivy_delete',text="Delete youngest Ivy")
+ row = layout.row()
+ row.operator('curve.ivy_delete_oldest',text="Delete oldest Ivy")
row = layout.row()
row.alignment = 'EXPAND'
@@ -476,6 +479,9 @@
properties.ivyBranchSize = self.ivyBranchSize
properties.ivyLeafSize = self.ivyLeafSize
'''
+ ob = context.scene.objects.active
+# row = layout.row()
+
row = layout.row()
row.operator('curve.ivy_gen', text="Add New Ivy")
@@ -587,9 +593,10 @@
description="The length of an ivy segment in Blender"\
" Units.",
default=0.02,
- min=0.0,
- soft_max=1.0,
- precision=3)
+ min= 0.02,
+ soft_max=.5,
+ max = 1,
+ precision=2)
bpy.types.Scene.ivyLeafSize = FloatProperty(name="Ivy Leaf Size",
description="The size of the ivy leaves",
default=0.02,
@@ -619,7 +626,7 @@
description="The seed governing random generation.",
default=0,
min=0,
- soft_max=10)
+ soft_max=100)
bpy.types.Scene.maxTime = FloatProperty(name="Maximum Time",
description="The maximum time to run the generation for"\
"in seconds generation (0.0 = Disabled)",
@@ -670,6 +677,44 @@
else:
print("***Warning***, confirmation for deletion of latest Ivy not given")
return {'CANCELLED'}
+
+class IvyDeleteOldest(bpy.types.Operator):
+ bl_idname = "curve.ivy_delete_oldest"
+ bl_label = "IvyDelete"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self,context):
+ if bpy.context.scene.deleteLatest:
+ activeObj = bpy.context.scene.objects.active
+ bpy.ops.object.select_all(action='DESELECT')
+ leaves = [el for el in bpy.data.objects if el.name.startswith('IvyLeaf.')]
+ curves = [el for el in bpy.data.objects if el.name.startswith('IVY_Curve.')]
+# print("\n debug ====== leaves, curves",leaves,curves)
+ if len(leaves) > 0 and len(curves) > 0:
+ leavesNr = [el.name.replace("IvyLeaf.","") for el in leaves]
+ leavesNr.sort()
+ curvesNr = [el.name.replace("IVY_Curve.","") for el in curves]
+ curvesNr.sort()
+
+ latestCurve = bpy.data.objects["IVY_Curve." + curvesNr[0]]
+ latestCurve.select = True
+ bpy.context.scene.objects.active = latestCurve
+ bpy.ops.object.delete()
+
+ latestLeave = bpy.data.objects["IvyLeaf." + leavesNr[0]]
+ latestLeave.select = True
+ bpy.context.scene.objects.active = latestLeave
+ bpy.ops.object.delete()
+ else:
+ print("***Warning*** not possible, pair of Ivy-leaves and Ivy-courve needed ")
+ bpy.context.scene.objects.active = activeObj
+ activeObj.select = True
+ return {'FINISHED'}
+
+ else:
+ print("***Warning***, confirmation for deletion of latest Ivy not given")
+ return {'CANCELLED'}
+
class IvyGen(bpy.types.Operator):
bl_idname = "curve.ivy_gen"
bl_label = "IvyGen"
@@ -689,6 +734,11 @@
#PKHG???? updateIvy = BoolProperty(name="Update Ivy", default=False)
def execute(self, context):
+ ob = context.scene.objects.active
+ if ob == None or not(ob.type == 'MESH'):
+ print("*** ERROR ***, no Mesh selected")
+ self.report({'ERROR'}, "No Mesh Active! Select or create one!")
+ return {'CANCELLED'}
sce = bpy.context.scene
if sce.initialVals: #PKHG TODO where???
resetSceneProperties()
@@ -765,8 +815,9 @@
# self.layout.operator(IvyGen.bl_idname, text="Add Ivy to Mesh",
# icon='PLUGIN').updateIvy = True
-
-def register():
+#bpy.types.VIEW3D_PT_tools_objectmode.prepend() !!!!!!!!!!!
+def register():
+#niet zo: bpy.types.VIEW3D_PT_tools_objectmode.prepend(OBJECT_PT_IvyPanelxshell)
bpy.utils.register_module(__name__)
# bpy.types.INFO_MT_curve_add.append(menu_func)
initSceneProperties()
More information about the Bf-extensions-cvs
mailing list