[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2429] branches/geodesic_domes: basic implementation of gui_259. py but i still need to move non gui code to geodesic_259.py

james bond thekilon at yahoo.co.uk
Thu Oct 13 12:25:43 CEST 2011


Revision: 2429
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2429
Author:   kilon
Date:     2011-10-13 10:25:42 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
basic implementation of gui_259.py but i still need to move non gui code to geodesic_259.py 

Modified Paths:
--------------
    branches/geodesic_domes/__init__.py
    branches/geodesic_domes/gui_259.py

Modified: branches/geodesic_domes/__init__.py
===================================================================
--- branches/geodesic_domes/__init__.py	2011-10-13 07:45:35 UTC (rev 2428)
+++ branches/geodesic_domes/__init__.py	2011-10-13 10:25:42 UTC (rev 2429)
@@ -33,897 +33,27 @@
 """
 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):
+if "bpy" in locals():
+    import imp
+    imp.reload(gui_259)
     
-     # 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
+else:
+    from geodesic_domes import gui_259
    
-def maxAndMinVerts(scene, object):
     
-    mesh = getMeshandPutinEditMode(scene, object)
-    verts = mesh.vertices
+import bpy
+from bpy.props import *
 
-    #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'
-    elif "CloudMember" in obj:
-        if obj["CloudMember"] != None:
-            if obj["CloudMember"] == "MainObj":
-                return 'DEGENERATE'            
-            elif obj["CloudMember"] == "CreatedObj" and len(obj.particle_systems) > 0:
-                return 'CLOUD_CONVERT_TO_MESH'
-            else:
-                return 'CLOUD_DO_NOTHING'
-    elif obj.type == 'MESH':
-        return 'GENERATE'
-    else:
-        return 'DO_NOTHING'
-    '''
-    
-class VIEW3D_PT_tools_cloud(bpy.types.Panel):
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'TOOLS'
-
-    bl_label = "Geodesic Dome"
-    bl_context = "objectmode"
-    
-
-    def draw(self, context):
-        active_obj = context.active_object
-        layout = self.layout
-        col = layout.column(align=True)
-
-        WhatToDo = getActionToDo(active_obj)
-
-        if WhatToDo == 'DEGENERATE':
-            col.operator("cloud.generate_cloud", text="DeGenerate")
-
-        elif WhatToDo == 'CLOUD_CONVERT_TO_MESH':
-            col.operator("cloud.generate_cloud", text="Convert to Mesh")
-
-        elif WhatToDo == 'NO_SELECTION_DO_NOTHING':
-            col.label(text="Select one or more")
-            col.label(text="objects to generate")
-            col.label(text="a cloud.")
-
-        elif WhatToDo == 'CLOUD_DO_NOTHING':
-            col.label(text="Must select")
-            col.label(text="bound box")
-           
-        elif WhatToDo == 'GENERATE':
-            col.operator("geodesic.generate_geodesic", text="Generate Geodesic")
-            col = layout.column()
-            col.label("First choice")
-            col.prop(context.scene,"choose_type")
-            tmp = int(context.scene.choose_type)
-#pkhg ok            print("\n ======= type =",typesOfObjects[tmp])
-            if tmp == 0:
-                row = layout.row()            
-                if context.scene.class_one:
-                    row.label("Class 1 AKTIV")
-                elif context.scene.class_two:
-                    row.label("Class 2 AKTIVE")
-    #            elif context.scene.class_two and context.scene.class_one:
-    #                row.label("Class1 takes prererence")
-                else:
-                    row.label("Make a choice of class!")
-                row = layout.row()                

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list