[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2408] branches/geodesic_domes: My way of working (Peter)

Peter K.H. Gragert pkhgragert at gmail.com
Sun Oct 9 15:03:57 CEST 2011


Revision: 2408
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2408
Author:   pkhg
Date:     2011-10-09 13:03:57 +0000 (Sun, 09 Oct 2011)
Log Message:
-----------
My way of working (Peter)
my first try of a replacement GUI

Added Paths:
-----------
    branches/geodesic_domes/Peter_way_of_working.txt
    branches/geodesic_domes/start1.py

Added: branches/geodesic_domes/Peter_way_of_working.txt
===================================================================
--- branches/geodesic_domes/Peter_way_of_working.txt	                        (rev 0)
+++ branches/geodesic_domes/Peter_way_of_working.txt	2011-10-09 13:03:57 UTC (rev 2408)
@@ -0,0 +1,21 @@
+My way of working, while converting addons from 2.49 to >=2.59.4
+
+Once and for all
+1. make sure that the breakpoint.py from http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Development/BreakPoint
+is in your addons directory
+2. start Blender and addon breakpoint (found under develloper)
+3. save as configure
+
+Now phase of understanding a 2.49 version
+0. run Blender in a nice command window! (ask me!)
+1. Take or create a *.py you want to convert to 2.59 
+2. aktivate Scripting in Blender
+3. add the file into text
+4. open the same file in a for you most easy and good text-editor
+   XEmacs, Geany, (Vim) or what you are comfortable with!
+5. probably add a breakpoint ... (more about later)
+6. run your script and see what happens!
+7. correct errors in your TEXT editor!
+8. see the button to reload in Blender do reload, execute again  etc.!
+9. save now and then your *.blend (use eventuall F2 and Numpd +!)
+

Added: branches/geodesic_domes/start1.py
===================================================================
--- branches/geodesic_domes/start1.py	                        (rev 0)
+++ branches/geodesic_domes/start1.py	2011-10-09 13:03:57 UTC (rev 2408)
@@ -0,0 +1,929 @@
+# ##### 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 #####
+
+#  first try for an GUI : step1.py will be renamed later
+bl_info = {
+    "name": "Geodesic Dome",
+    "author": "PKHG, Kilon, original for 2.49 from Andy Houston'",
+    "version": (0,0,1),
+    "blender": (2, 5, 9),
+    "api": 39685,
+    "location": "View3D > Tool Shelf > Geodesic Dome Panel",
+    "description": "Choice for objects",
+    "warning": "",
+    "wiki_url": "",
+    "tracker_url": "",
+    "category": "Mesh"}
+
+"""
+Rev 0.1 building menues
+"""
+
+import bpy
+from math import *
+from bpy.props import EnumProperty, IntProperty, FloatProperty, StringProperty, BoolProperty
+import sys
+
+typesOfObjects =["Geodesic", "Grid", "Cylinder", "Parabola", "Torus", "Ball", "Your mesh"]
+
+
+sys.path.append("c:\\Users\\Peter\\25blender\\blenderlatest\\2.59\\scripts\\addons\\geodesicDome")
+#import geodesic259 #AttributeError: 'geodesic' object has no attribute 'vertskeleton'
+# This routine takes an object and deletes all of the geometry in it
+# and adds a bounding box to it.
+# It will add or subtract the bound box size by the variable sizeDifference.
+
+
+
+def getMeshandPutinEditMode(scene, object):
+    
+     # Go into Object Mode
+    bpy.ops.object.mode_set(mode='OBJECT')   
+    
+    # Deselect All
+    bpy.ops.object.select_all(action='DESELECT')
+
+    # Select the object
+    object.select = True
+    scene.objects.active = object
+    
+    # Go into Edit Mode
+    bpy.ops.object.mode_set(mode='EDIT')
+
+    return object.data
+   
+def maxAndMinVerts(scene, object):
+    
+    mesh = getMeshandPutinEditMode(scene, object)
+    verts = mesh.vertices
+
+    #Set the max and min verts to the first vertex on the list
+    maxVert = [verts[0].co[0], verts[0].co[1], verts[0].co[2]]
+    minVert = [verts[0].co[0], verts[0].co[1], verts[0].co[2]]
+
+    #Create Max and Min Vertex array for the outer corners of the box
+    for vert in verts:
+        #Max vertex
+        if vert.co[0] > maxVert[0]:
+            maxVert[0] = vert.co[0]
+        if vert.co[1] > maxVert[1]:
+            maxVert[1] = vert.co[1]
+        if vert.co[2] > maxVert[2]:
+            maxVert[2] = vert.co[2]
+
+        #Min Vertex
+        if vert.co[0] < minVert[0]:
+            minVert[0] = vert.co[0]
+        if vert.co[1] < minVert[1]:
+            minVert[1] = vert.co[1]
+        if vert.co[2] < minVert[2]:
+            minVert[2] = vert.co[2]
+            
+    return [maxVert, minVert]
+    
+def makeObjectIntoBoundBox(scene, object, sizeDifference, takeFromObject):
+    
+    #Let's find the max and min of the reference object, it can be the same as the destination object
+    [maxVert, minVert] = maxAndMinVerts(scene, takeFromObject)
+
+    #get objects mesh
+    mesh = getMeshandPutinEditMode(scene, object)
+
+    #Add the size difference to the max size of the box
+    maxVert[0] = maxVert[0] + sizeDifference
+    maxVert[1] = maxVert[1] + sizeDifference
+    maxVert[2] = maxVert[2] + sizeDifference
+
+    #subtract the size difference to the min size of the box
+    minVert[0] = minVert[0] - sizeDifference
+    minVert[1] = minVert[1] - sizeDifference
+    minVert[2] = minVert[2] - sizeDifference
+
+    #Create arrays of verts and faces to be added to the mesh
+    addVerts = []
+
+    #X high loop
+    addVerts.append([maxVert[0], maxVert[1], maxVert[2]])
+    addVerts.append([maxVert[0], maxVert[1], minVert[2]])
+    addVerts.append([maxVert[0], minVert[1], minVert[2]])
+    addVerts.append([maxVert[0], minVert[1], maxVert[2]])
+
+    #x low loop
+    addVerts.append([minVert[0], maxVert[1], maxVert[2]])
+    addVerts.append([minVert[0], maxVert[1], minVert[2]])
+    addVerts.append([minVert[0], minVert[1], minVert[2]])
+    addVerts.append([minVert[0], minVert[1], maxVert[2]])
+
+    # Make the faces of the bounding box.
+    addFaces = []
+
+    # Draw a box on paper and number the vertices.
+    # Use right hand rule to come up with number orders for faces on
+    # the box (with normals pointing out).
+    addFaces.append([0, 3, 2, 1])
+    addFaces.append([4, 5, 6, 7])
+    addFaces.append([0, 1, 5, 4])
+    addFaces.append([1, 2, 6, 5])
+    addFaces.append([2, 3, 7, 6])
+    addFaces.append([0, 4, 7, 3])
+
+    # Delete all geometry from the object.
+    bpy.ops.mesh.select_all(action='SELECT')
+    bpy.ops.mesh.delete(type='ALL')
+
+    # Must be in object mode for from_pydata to work
+    bpy.ops.object.mode_set(mode='OBJECT')
+
+    # Add the mesh data.
+    mesh.from_pydata(addVerts, [], addFaces)
+
+    # Update the mesh
+    mesh.update()
+
+def applyScaleRotLoc(scene, obj):
+    # Deselect All
+    bpy.ops.object.select_all(action='DESELECT')
+
+    # Select the object
+    obj.select = True
+    scene.objects.active = obj
+
+    bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
+   
+def totallyDeleteObject(scene, obj):
+    #remove users?
+    scene.objects.unlink(obj)
+    bpy.data.objects.remove(obj)
+
+
+def makeParent(parentobj, childobj, scene):
+
+    applyScaleRotLoc(scene, parentobj)
+    applyScaleRotLoc(scene, childobj)
+    childobj.parent = parentobj
+
+
+def addNewObject(scene, name, copyobj):
+
+    # Create new mesh
+    mesh = bpy.data.meshes.new(name)
+
+    # Create a new object.
+    ob_new = bpy.data.objects.new(name, mesh)
+    tempme = copyobj.data
+    ob_new.data = tempme.copy()
+    ob_new.scale = copyobj.scale
+    ob_new.location = copyobj.location
+
+    # Link new object to the given scene and select it.
+    scene.objects.link(ob_new)
+    ob_new.select = True
+
+    return ob_new
+
+def getpdensitytexture(object):
+    
+    for mslot in object.material_slots:
+        mat = mslot.material
+        for tslot in mat.texture_slots:
+            if tslot!= 'NoneType':
+                tex = tslot.texture
+                if tex.type == 'POINT_DENSITY':
+                    if tex.point_density.point_source == 'PARTICLE_SYSTEM':
+                        return tex
+    
+def removeParticleSystemFromObj(scene, object):
+
+    # Deselect All
+    bpy.ops.object.select_all(action='DESELECT')
+
+    # Select the object.
+    object.select = True
+    scene.objects.active = object
+
+    bpy.ops.object.particle_system_remove()
+
+    # Deselect All
+    bpy.ops.object.select_all(action='DESELECT')
+    
+def convertParticlesToMesh(scene, particlesobj, destobj, replacemesh):
+    
+    # Select the Destination object.
+    destobj.select = True
+    scene.objects.active = destobj
+    
+    #Go to Edit Mode
+    bpy.ops.object.mode_set(mode='EDIT',toggle=False)
+    
+    #Delete everything in mesh if replace true
+    if replacemesh:
+        bpy.ops.mesh.select_all(action='SELECT')
+        bpy.ops.mesh.delete(type='ALL')
+
+    meshPnts = destobj.data
+
+    listCloudParticles = particlesobj.particles
+
+    listMeshPnts = []
+    for pTicle in listCloudParticles:
+        listMeshPnts.append(pTicle.location)
+
+    # Must be in object mode for from_pydata to work.
+    bpy.ops.object.mode_set(mode='OBJECT')
+
+    # Add in the mesh data.
+    meshPnts.from_pydata(listMeshPnts, [], [])
+
+    # Update the mesh.
+    meshPnts.update()
+
+def combineObjects(scene, combined, listobjs):
+    # scene is the current scene
+    # combined is the object we want to combine everything into
+    # listobjs is the list of objects to stick into combined
+
+    # Deselect All
+    bpy.ops.object.select_all(action='DESELECT')
+
+    # Select the new object.
+    combined.select = True
+    scene.objects.active = combined
+
+    # Add data
+    if (len(listobjs) > 0):
+            for i in listobjs:
+                # Add a modifier
+                bpy.ops.object.modifier_add(type='BOOLEAN')
+
+                union = combined.modifiers
+                union[0].name = "AddEmUp"
+                union[0].object = i
+                union[0].operation = 'UNION'
+
+                # Apply modifier
+                bpy.ops.object.modifier_apply(apply_as='DATA', modifier=union[0].name)
+
+# Returns the action we want to take
+def getActionToDo(obj):
+    return 'GENERATE'
+    '''
+    if not obj or obj.type != 'MESH':
+        return 'NOT_OBJ_DO_NOTHING'
+    elif obj is None:
+        return 'NO_SELECTION_DO_NOTHING'

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list