Exemplo n.º 1
0
def dodialog(newname):
    global newimage, newsize, offsets, rows, cols

    try:
        newimage = Image.Load(newname)
        newsize = newimage.getSize()
    except:
        Draw.PupMenu("Can't read image %s" % newname)
        return

    if newsize[0] == oldsize[0] and newsize[1] == oldsize[1]:
        # same size, just replace
        doapply(0, 0)
        return
    elif newsize[0] < oldsize[0] or newsize[1] < oldsize[1]:
        Draw.PupMenu("The new image must be larger than the old image")
        return
    else:
        if newsize[0] % oldsize[0] == 0:
            xoffs = range(0, newsize[0], oldsize[0])
        else:
            xoffs = [0, newsize[0] - oldsize[0]]
        if newsize[1] % oldsize[1] == 0:
            yoffs = range(newsize[1] - oldsize[1], -oldsize[1], -oldsize[1])
        else:
            yoffs = [newsize[1] - oldsize[1], 0]
        for i in yoffs:
            for j in xoffs:
                offsets.append((j, i))
        cols = len(xoffs)
        rows = len(yoffs)
        Draw.Register(gui, event, bevent)
Exemplo n.º 2
0
def bevent(evt):
    global EVENT_NOEVENT, EVENT_DRAW, EVENT_EXIT

    if (evt == EVENT_EXIT):
        Draw.Exit()
    elif (evt == EVENT_DRAW):
        Draw.Redraw()
    elif (evt == EVENT_EXPORT):
        sce = bpy.data.scenes.active

        if (export_all == 1):
            print "oh ja"
            # get a list of mesh objects
            obs = [ob for ob in sce.objects if ob.type == 'Mesh']

            # export all object names
            for ob in obs:
                me = Mesh.New()
                me.getFromObject(ob, 0)
                print(me.name)
                export_to_as(ob)
            Draw.PupMenu("Export Successful")
        else:
            export_to_as(sce.objects.active)
            Draw.PupMenu("Export Successful")
    elif (evt == EVENT_BROWSEFILE):
        Window.FileSelector(FileSelected, "Export .as", expFileName)
        Draw.Redraw(1)
Exemplo n.º 3
0
def main():
    ret = Draw.PupMenu(
        'Clean Selected Objects Ipos%t|Object IPO%x1|Object Action%x2|%l|All IPOs (be careful!)%x3'
    )

    sce = bpy.data.scenes.active
    ipos = []

    if ret == 3:
        ipos.extend(list(bpy.data.ipos))
    else:
        for ob in sce.objects.context:
            if ret == 1:
                ipo = ob.ipo
                if ipo:
                    ipos.append(ipo)

            elif ret == 2:
                action = ob.action
                if action:
                    ipos.extend([
                        ipo for ipo in action.getAllChannelIpos().values()
                        if ipo
                    ])

    if not ipos:
        Draw.PupMenu('Error%t|No ipos found')
    else:
        total_removed, total = clean_ipos(ipos)
        Draw.PupMenu('Done!%t|Removed ' + str(total_removed) + ' of ' +
                     str(total) + ' points')

    Window.RedrawAll()
Exemplo n.º 4
0
    def export(self, scene):
        theObjects = scene.objects

        print "Starting OBJ export to " + self.filename
        if not checkFile(self.filename):
            return

        Blender.Window.WaitCursor(1)
        Window.DrawProgressBar(0, "Examining textures")
        self.texture = getTexture(self, theObjects, self.iscsl, 7)
        if self.regions:
            (pwidth, pheight) = PanelRegionHandler().panelimage().size
            for img, (n, x1, y1, width, height) in self.regions.iteritems():
                self.regions[img] = (float(x1) / pwidth, float(y1) / pheight,
                                     float(width) / pwidth,
                                     float(height) / pheight)

        #clock=time.clock()	# Processor time

        self.file = open(self.filename, "w")
        self.writeHeader()
        self.writeObjects(theObjects)
        checkLayers(self, theObjects)
        self.file.close()

        Window.DrawProgressBar(1, "Finished")
        #print "%s CPU time" % (time.clock()-clock)
        print "Finished - exported %s primitives\n" % self.nprim
        if self.log:
            r = Draw.PupMenu(("Exported %s primitives%%t|" % self.nprim) +
                             '|'.join([a[0] for a in self.log]))
            if r > 0: raise ExportError(None, self.log[r - 1][1])
        else:
            Draw.PupMenu("Exported %s primitives%%t|OK" % self.nprim)
Exemplo n.º 5
0
def button_event(evt):
    global config_data

    if (evt == BROWSE_HOME_CLICKED):
        default_path = "C:\\"
        if (Blender.sys.exists(config_data["home"])):
            default_path = config_data["home"]
        Window.FileSelector(SetHomeDir, "Nebula Home", default_path)
    if (evt == BROWSE_PROJ_CLICKED):
        default_path = "C:\\"
        if (Blender.sys.exists(config_data["home"])):
            default_path = config_data["proj"]
        Window.FileSelector(SetProjDir, "Project Dir", default_path)

    if (evt == ASSIGN_DIR_CHANGED):
        for data in config_data:
            if (data != "home" and data != "texture_dir" and data != "proj"):
                config_data[data] = dir_assigns[data].val

    if (evt == OK_CLICKED):
        SaveConfig()
        result = Draw.PupMenu("Saved%t|Do you want to exit?")
        if (result != -1):
            Draw.Exit()
            return

    if (evt == CANCEL_CLICKED):
        result = Draw.PupMenu("Exit%t|Exit and Discard Changes?")
        if (result != -1):
            Draw.Exit()
            return
Exemplo n.º 6
0
def getparents():
    global lookup, hierarchy, firstlevel, has_sim, armature, bones, theobject

    if Window.EditMode():
        objects = [Scene.GetCurrent().objects.active]
    else:
        objects = Object.GetSelected()
    for theobject in objects:
        parent = theobject.parent
        if not parent or parent.getType() != 'Armature':
            Draw.PupMenu('Object "%s" is not a child of a bone.' %
                         theobject.name)
            return None
        bonename = theobject.getParentBoneName()
        if not bonename:
            Draw.PupMenu(
                'Object "%s" is the child of an armature. It should be the child of a bone.'
                % theobject.name)
            return None
        thisbones = parent.getData().bones
        if bonename in thisbones.keys():
            bone = thisbones[bonename]
        else:
            Draw.PupMenu('Object "%s" has a deleted bone as its parent.' %
                         theobject.name)
            return None
        if armature and (parent != armature or bone != bones[0]):
            Draw.PupMenu(
                'You have selected multiple objects with different parents.')
            return None
        else:
            armature = parent
            bones = [bone]

    if not bones: return
    bone = bones[0]
    while bone.parent:
        bones.append(bone.parent)
        bone = bone.parent

    try:
        has_sim = False
        (lookup, hierarchy) = getDatarefs()
        firstlevel = []
        for key in lookup:
            if lookup[key]:
                (path, n) = lookup[key]
                ref = path.split('/')
                if not ref[0] in firstlevel:
                    firstlevel.append(ref[0])
        if len(firstlevel) == 1:
            firstlevel = hierarchy['sim'].keys()
            has_sim = True
        firstlevel.sort(lambda x, y: -cmp(x.lower(), y.lower()))

    except IOError, e:
        Draw.PupMenu(str(e))
        return None
Exemplo n.º 7
0
def button_event(evt):  # gui button events

    global SCREEN, START_SCREEN, SCRIPT_SCREEN
    global BEVT_LINK, BEVT_EMAIL, BEVT_GMENU, BUT_GMENU, SCRIPT_INFO
    global SCROLL_DOWN, FMODE

    if evt >= 100:  # group menus
        for i in range(len(BUT_GMENU)):
            if evt == BEVT_GMENU[i]:
                group = AllGroups[i]
                index = BUT_GMENU[i].val - 1
                if index < 0: return  # user didn't pick a menu entry
                script = group.get_scripts()[BUT_GMENU[i].val - 1]
                if parse_help_info(script):
                    SCREEN = SCRIPT_SCREEN
                    BEVT_LINK = range(20, len(SCRIPT_INFO.d['__url__']) + 20)
                    BEVT_EMAIL = range(50,
                                       len(SCRIPT_INFO.d['__email__']) + 50)
                    Draw.Redraw()
                else:
                    res = Draw.PupMenu(
                        "No help available%t|View Source|Cancel")
                    if res == 1:
                        load_script_text(script)
    elif evt >= 20:
        if not WEBBROWSER:
            Draw.PupMenu(
                'Missing standard Python module%t|You need module "webbrowser" to access the web'
            )
            return

        if evt >= 50:  # script screen email buttons
            email = SCRIPT_INFO.d['__email__'][evt - 50][1]
            webbrowser.open("mailto:%s" % email)
        else:  # >= 20: script screen link buttons
            link = SCRIPT_INFO.d['__url__'][evt - 20][1]
            webbrowser.open(link)
    elif evt == BEVT_VIEWSOURCE:
        if SCREEN == SCRIPT_SCREEN: load_script_text(SCRIPT_INFO.script)
    elif evt == BEVT_EXIT:
        Draw.Exit()
        return
    elif evt == BEVT_BACK:
        if SCREEN == SCRIPT_SCREEN and not FMODE:
            SCREEN = START_SCREEN
            SCRIPT_INFO = None
            SCROLL_DOWN = 0
            Draw.Redraw()
    elif evt == BEVT_EXEC:  # Execute script
        exec_line = ''
        if SCRIPT_INFO.script.userdir:
            exec_line = bsys.join(Blender.Get('uscriptsdir'),
                                  SCRIPT_INFO.script.fname)
        else:
            exec_line = bsys.join(Blender.Get('scriptsdir'),
                                  SCRIPT_INFO.script.fname)

        Blender.Run(exec_line)
Exemplo n.º 8
0
def main():
    scn = bpy.data.scenes.active
    ob_sel = list(scn.objects.context)

    PREF_KEEP_ASPECT = False

    # Error Checking
    if len(ob_sel) < 2:
        Draw.PupMenu("Error%t|Select 2 mesh objects")
        return

    me_ob = scn.objects.active

    if not me_ob:
        Draw.PupMenu("Error%t|No active mesh selected.")

    try:
        ob_sel.remove(me_ob)
    except:
        pass

    if me_ob.type != 'Mesh':
        Draw.PupMenu(
            "Error%t|Active Object must be a mesh to write billboard images too"
        )
        return

    me_data = me_ob.getData(mesh=1)

    for f in me_data.faces:
        if len(f) != 4:
            Draw.PupMenu("Error%t|Active mesh must have only quads")
            return

    # Get user input
    block = [\
    'Image Pixel Size',\
    ("Packed Size: ", PREF_RES, 128, 2048, "Pixel width and height to render the billboard to"),\
    ("Tile Size: ", PREF_TILE_RES, 64, 1024, "Pixel  width and height for each tile to render to"),\
    'Render Settings',\
    ("Pack Final", PREF_IMG_PACK , "Pack the image for each face into images into a single image"),\
    ("Oversampling", PREF_AA , "Higher quality woth extra sampling"),\
    ("Alpha Clipping", PREF_ALPHA , "Render empty areas as transparent"),\
    ("Cam ZOffset: ", PREF_Z_OFFSET, 0.1, 100, "Distance to place the camera away from the quad when rendering")\
    ]

    if not Draw.PupBlock("Billboard Render", block):
        return

    # Set globals
    GLOBALS['ob_sel'] = ob_sel
    GLOBALS['me_ob'] = me_ob
    GLOBALS['me_data'] = me_data

    Blender.Window.FileSelector(save_billboard, 'SAVE BILLBOARD',
                                Blender.sys.makename(ext='.png'))
Exemplo n.º 9
0
 def CheckSelection():
 	selob = Object.GetSelected()
 	if not selob: 
 		Draw.PupMenu("Warning%t|Please make a selection.")
 	elif ob and selob[0].name == ob.name: 
 		Draw.PupMenu("Warning%t|Object already selected.")
 	else:
 		return selob[0]
 	
 	return None
Exemplo n.º 10
0
def runAsTextPlugin():
    '''Called when run as a text plugin.'''

    import Blender
    from Blender import Window, sys, Draw
    import BPyTextPlugin, bpy

    message = ("Convert Game Engine script from 4.48 API to 2.49 API%t|"
               "Run on active script only%x1|"
               "Run on ALL text buffers%x2")
    convertAllBuffers = Draw.PupMenu(message) == 2

    Window.WaitCursor(1)
    try:
        nconverted = 0
        nerrors = 0

        if convertAllBuffers:
            texts = bpy.data.texts
        else:
            if not bpy.data.texts.active:
                Draw.PupMenu("No active buffer.")
                return
            texts = [bpy.data.texts.active]

        Blender.SaveUndoState('Convert BGE 2.49')

        for txt in texts:
            bufName = txt.name
            if txt.lib:
                bufName = txt.lib + '/' + bufName
            lines = txt.asLines()
            for i in range(0, len(lines)):
                if not lines[i].endswith('\n'):
                    lines[i] = lines[i] + '\n'

            nc, ne = convert248to249(lines, fileName=bufName)
            nconverted = nconverted + nc
            nerrors = nerrors + ne
            txt.clear()
            for line in lines:
                txt.write(line)

    finally:
        Window.WaitCursor(0)

        message = "Converted %d attributes." % nconverted
        if nerrors == 1:
            message = message + " There was 1 error (see console)."
        if nerrors > 1:
            message = message + " There were %d errors (see console)." % nerrors
        message = message + "|Please review all the changes."
        Draw.PupMenu(message)
Exemplo n.º 11
0
def event(evt, val):  # function that handles keyboard and mouse events
    #global mouseX, mouseY
    global stop, showHelp
    if evt == Draw.ESCKEY or evt == Draw.QKEY:
        stop = Draw.PupMenu("OK?%t|Stop script %x1")
        if stop == 1:
            Draw.Exit()
            return
    if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE] and val:
        showHelp = Draw.PupMenu("Show Help?%t|Ok%x1")
        if showHelp == 1:
            ShowHelp("i3dExporter.py")
Exemplo n.º 12
0
def event(evt, val):  # input events

    global SCREEN, START_SCREEN, CONFIG_SCREEN
    global SCROLL_DOWN, CFGKEY

    if not val: return

    if evt == Draw.ESCKEY:
        if SCREEN == START_SCREEN: Draw.Exit()
        else:
            if CFGKEY.needs_update():
                if Draw.PupMenu('UPDATE?%t|Data was changed') == 1:
                    CFGKEY.update()
            SCREEN = START_SCREEN
            SCROLL_DOWN = 0
            Draw.Redraw()
        return
    elif evt == Draw.QKEY:
        if SCREEN == CONFIG_SCREEN and CFGKEY.needs_update():
            if Draw.PupMenu('UPDATE?%t|Data was changed') == 1:
                CFGKEY.update()
        Draw.Exit()
        return
    elif evt == Draw.HKEY:
        if SCREEN == START_SCREEN: show_help()
        elif CFGKEY.scriptname: show_help(CFGKEY.scriptname)
        return

    elif SCREEN == CONFIG_SCREEN:
        if evt in [Draw.DOWNARROWKEY, Draw.WHEELDOWNMOUSE]:
            SCROLL_DOWN += 1
            fit_scroll()
        elif evt in [Draw.UPARROWKEY, Draw.WHEELUPMOUSE]:
            SCROLL_DOWN -= 1
            fit_scroll()
        elif evt == Draw.UKEY:
            if CFGKEY.needs_update():
                CFGKEY.revert()
        elif evt == Draw.RETKEY or evt == Draw.PADENTER:
            if CFGKEY.needs_update():
                CFGKEY.update()
        elif evt == Draw.DELKEY:
            if CFGKEY.delete():
                reset()
                init_data()
                SCREEN = START_SCREEN
                SCROLL_DOWN = 0
        else:
            return
        Draw.Redraw()
Exemplo n.º 13
0
    def export(self, scene):
        print 'Starting road.net export to ' + self.filename

        if not checkFile(self.filename):
            return

        self.file = open(self.filename, 'w')
        self.file.write("A\n800\nROADS\n\n")

        self.shaders = SHADER_SET()

        header = text_for_obj('header')
        for h in header:
            self.file.write("%s\n" % h)
            if self.shaders.is_shader_line(h):
                self.shaders.handle_shader_line(h)

        scenes = Scene.Get()
        for s in scenes:
# ALEX - COMMENT OUT THIS LINE TO EXPORT EVERY SCENE!  LEAVE IT IN TO GET ONLY THE CURRENT SCENE.
            if s == scene:
                self.file.write("# Scene %s:\n" % s.getName())
                things = getAllDepth(0,s.objects)
                self.export_things(things,s.objects)

        footer = text_for_obj('footer')
        for f in footer:
            self.file.write("%s\n" % f)

        self.file.close
        if self.log:
            r=Draw.PupMenu('|'.join([a[0] for a in self.log]))
Exemplo n.º 14
0
def main():
    scn = Scene.GetCurrent()
    ob = scn.objects.active

    if not ob or ob.type != 'Mesh':
        Draw.PupMenu('Error, no active mesh object, aborting.')
        return

    me = ob.getData(mesh=1)

    PREF_PEAKWEIGHT = Draw.Create(1.0)
    PREF_ACTIVE_ONLY = Draw.Create(1)
    PREF_KEEP_PROPORTION = Draw.Create(1)
    PREF_ARMATURE_ONLY = Draw.Create(0)

    pup_block= [\
    ('Peak Weight:', PREF_PEAKWEIGHT, 0.01, 1.0, 'Upper weight for normalizing.'),\
    ('Active Only', PREF_ACTIVE_ONLY, 'Only Normalize groups that have matching bones in an armature (when an armature is used).'),\
    ('Proportional', PREF_KEEP_PROPORTION, 'Scale other weights so verts (Keep weights with other groups in proportion).'),\
    ('Armature Only', PREF_ARMATURE_ONLY, 'Only Normalize groups that have matching bones in an armature (when an armature is used).'),\
    ]

    if not Draw.PupBlock('Clean Selected Meshes...', pup_block):
        return

    actWeightNormalize(me, ob, PREF_PEAKWEIGHT.val, PREF_ACTIVE_ONLY.val,
                       PREF_ARMATURE_ONLY.val, PREF_KEEP_PROPORTION.val)
Exemplo n.º 15
0
def selectASF(filename):
    """ Import the ASF file """
    global ASFString
    if os.path.splitext(filename)[1] != '.asf':
        Draw.PupMenu('Invalid file extension! You need a *.asf file')
        return
    ASFString = filename
Exemplo n.º 16
0
def file_callback(filename):
    obj = NETimport(filename)
    try:
        obj.doimport()
        Blender.Scene.GetCurrent().update()
    except ParseError, e:
        Window.WaitCursor(0)
        Window.DrawProgressBar(0, 'ERROR')
        if e.type == ParseError.HEADER:
            msg = 'This is not a valid X-Plane v6, v7 or v8 OBJ file'
        elif e.type == ParseError.NAME:
            msg = 'Missing dataref or light name at line %s\n' % obj.m.lineno
        elif e.type == ParseError.MISC:
            msg = '%s at line %s' % (e.value, obj.m.lineno)
        else:
            thing = ParseError.TEXT[e.type]
            if e.value:
                msg = 'Expecting a %s, found "%s" at line %s' % (
                    thing, e.value, obj.m.lineno)
            else:
                msg = 'Missing %s at line %s' % (thing, obj.m.lineno)
        print "ERROR:\t%s\n" % msg
        Draw.PupMenu("ERROR%%t|%s" % msg)
        Window.RedrawAll()
        Window.DrawProgressBar(1, 'ERROR')
Exemplo n.º 17
0
def main():
    
    # Gets the current scene, there can be many scenes in 1 blend file.
    sce = bpy.data.scenes.active
    
    # Get the active object, there can only ever be 1
    # and the active object is always the editmode object.
    ob_act = sce.objects.active
    
    if not ob_act or ob_act.type != 'Mesh':
        BPyMessages.Error_NoMeshActive()
        return 
    
    
    # Saves the editmode state and go's out of 
    # editmode if its enabled, we cant make
    # changes to the mesh data while in editmode.
    is_editmode = Window.EditMode()
    if is_editmode: Window.EditMode(0)
    
    Window.WaitCursor(1)
    t = sys.time()
    
    # Run the mesh editing function
    report = find_unassigned_verts(ob_act)
    
    # Restore editmode if it was enabled
    if is_editmode: Window.EditMode(1)

    if report != "":
        report = report + "!!! I have selected all affected verts. Please lookup your mesh in edit mode !!!"
        text = "Report: %t|" + report +"|OK"
        Draw.PupMenu(text)  
    
    Window.WaitCursor(0)
Exemplo n.º 18
0
def edl_reload():
    Window.WaitCursor(1)
    filename = PREF['filename'].val
    sce = bpy.data.scenes.active
    fps = sce.render.fps

    elist = EditList()

    if filename:
        if not elist.parse(filename, fps):
            Draw.PupMenu('Error%t|Could not open the file "' + filename + '"')
        reels = elist.getReels()
    else:
        reels = {}

    REEL_UI.clear()
    for reel_key, edits in reels.iteritems():

        if reel_key == 'bw':
            continue

        flag = 0
        for edit in edits:
            flag |= edit.edit_type

        reel_item = REEL_UI[reel_key] = ReelItemUI()

        reel_item.ui_text = '%s (%s): ' % (reel_key, editFlagsToText(flag))

    Window.WaitCursor(0)
Exemplo n.º 19
0
def main():
    scn = Scene.GetCurrent()
    ob = scn.objects.active

    if not ob or ob.type != 'Mesh':
        Draw.PupMenu('Error, no active mesh object, aborting.')
        return

    me = ob.getData(mesh=1)
    act_group = me.activeGroup

    PREF_NAME = Draw.Create(act_group + '_copy')
    PREF_SEL_ONLY = Draw.Create(0)

    pup_block= [\
    ('', PREF_NAME, 0, 31, 'Name of group copy.'),\
    ('Only Selected', PREF_SEL_ONLY, 'Only include selected faces in the new grop.'),\
    ]

    if not Draw.PupBlock('New Name...', pup_block):
        return
    PREF_NAME = PREF_NAME.val
    PREF_SEL_ONLY = PREF_SEL_ONLY.val
    copy_act_vgroup(me, PREF_NAME, PREF_SEL_ONLY)

    try:
        me.activeGroup = PREF_NAME
    except:
        pass
Exemplo n.º 20
0
def main():

    # Gets the current scene, there can be many scenes in 1 blend file.
    sce = bpy.data.scenes.active

    # Get the active object, there can only ever be 1
    # and the active object is always the editmode object.
    ob_act = sce.objects.active

    if not ob_act or ob_act.type != 'Mesh':
        BPyMessages.Error_NoMeshActive()
        return

    # Saves the editmode state and go's out of
    # editmode if its enabled, we cant make
    # changes to the mesh data while in editmode.
    is_editmode = Window.EditMode()
    Window.EditMode(0)

    PREF_ALL_VGROUPS = Draw.PupMenu(
        "All Groups?%t|All Groups%x1|Active Group Only%x0")
    if PREF_ALL_VGROUPS == -1:
        return

    Window.WaitCursor(1)
    me = ob_act.getData(mesh=1)  # old NMesh api is default
    t = sys.time()

    # Run the mesh editing function
    vgroup_average(ob_act, me, sce, PREF_ALL_VGROUPS)

    # Timing the script is a good way to be aware on any speed hits when scripting
    print 'Average VGroups in %.2f seconds' % (sys.time() - t)
    Window.WaitCursor(0)
    if is_editmode: Window.EditMode(1)
Exemplo n.º 21
0
def selectAMC5(filename):
    """ Import the fifth AMC file """
    global AMC5String
    if os.path.splitext(filename)[1] != '.amc':
        Draw.PupMenu('Invalid file extension! You need a *.amc file')
        return
    AMC5String = filename
Exemplo n.º 22
0
def main():
	scn= Scene.GetCurrent()
	ob= scn.objects.active
	
	if not ob or ob.type != 'Mesh':
		Draw.PupMenu('Error, no active mesh object, aborting.')
		return
	
	me= ob.getData(mesh=1)
	
	PREF_MAXDIST= Draw.Create(0.0)
	PREF_STRENGTH= Draw.Create(1.0)
	PREF_MODE= Draw.Create(0)
	PREF_ITERATIONS= Draw.Create(1)
	
	pup_block= [\
	('Bleed Dist:', PREF_MAXDIST, 0.0, 1.0, 'Set a distance limit for bleeding.'),\
	('Bleed Strength:', PREF_STRENGTH, 0.01, 1.0, 'Bleed strength between adjacent verts weight. 1:full, 0:None'),\
	('Iterations', PREF_ITERATIONS, 1, 20, 'Number of times to run the blending calculation.'),\
	('Contract (Shrink)', PREF_MODE, 'Shrink instead of growing.'),\
	]
	
	if not Draw.PupBlock('Grow/Shrink...', pup_block):
		return
	
	actWeightNormalize(me, PREF_MODE.val, PREF_MAXDIST.val, PREF_STRENGTH.val, PREF_ITERATIONS.val)
Exemplo n.º 23
0
def event(evt, val):
    global vertical, mousex, mousey, anchor, offset

    if evt == Draw.ESCKEY and not val:
        if anchor:
            anchor = None
        else:
            Draw.Exit()  # exit when user releases ESC
    elif evt == Draw.MOUSEX:
        mousex = val
        if anchor:
            offset = (max(0, anchor[0] - mousex), offset[1])
            Draw.Redraw()
    elif evt == Draw.MOUSEY:
        mousey = val
        if anchor:
            offset = (offset[0], min(0, anchor[1] - mousey))
            Draw.Redraw()
    elif evt == Draw.MIDDLEMOUSE and val:
        anchor = (mousex + offset[0], mousey + offset[1])
    elif evt == Draw.MIDDLEMOUSE and not val:
        anchor = None
    elif anchor:
        pass  # suppress other activity while panning
    elif evt == Draw.RIGHTMOUSE and val:
        r = Draw.PupMenu('Panel Alignment%t|Horizontal|Vertical')
        if r == 1:
            vertical = False
        elif r == 2:
            vertical = True
        else:
            return
        Draw.Redraw()
Exemplo n.º 24
0
def button_event(evt):
    global persist_server, mesh_format, window_width, window_height, fullscreen, renderpath, filename, group, aa

    if (evt == CANCEL_CLICKED):
        SavePrefs()
        Draw.Exit()
        return

    if (evt == PERSIST_SERVER_CHANGED):
        persist_server = mnu_persist_servers.val

    if (evt == MESH_FORMAT_CHANGED):
        mesh_format = mnu_mesh_formats.val

    if (evt == WIDTH_CHANGED):
        window_width = mnu_width.val

    if (evt == HEIGHT_CHANGED):
        window_height = mnu_height.val

    if (evt == FULLSCREEN_CHANGED):
        fullscreen = 1 - fullscreen

    if (evt == AA_CHANGED):
        aa = mnu_aa.val

    if (evt == FILENAME_CHANGED):
        filename = mnu_filename.val

    if (evt == GROUP_CHANGED):
        file2 = n2.lookup("/sys/servers/file2")
        path = ""
        is_valid = True
        if (mnu_group.val):
            path = file2.manglepath("gfxlib:") + "/" + mnu_group.val
        else:
            path = file2.manglepath("gfxlib:")
        if (not Blender.sys.exists(path)):
            is_valid = False
        path = ""
        if (mnu_group.val):
            path = file2.manglepath("meshes:") + "/" + mnu_group.val
        else:
            path = file2.manglepath("meshes:")
        if (not Blender.sys.exists(path)):
            is_valid = False
        if (is_valid):
            group = mnu_group.val
        else:
            err = "The directory ' %s ' must exist in both gfxlib and meshes folders" % mnu_group.val
            Draw.PupMenu("Invalid Group%t|" + err)
            Draw.Redraw(1)

    if (evt == RENDERPATH_CHANGED):
        renderpath = mnu_renderpath.val

    if (evt == OK_CLICKED):
        SavePrefs()
        DoExport()
Exemplo n.º 25
0
def display_menu(caption, items, choice_required=False):
    b = True
    while b:
        choice = Draw.PupMenu(
            '%s%%t|' % caption + "|".join('%s%%x%i' % (s, i)
                                          for i, s in enumerate(items)), 0x100)
        b = choice_required and choice < 0
    return choice
Exemplo n.º 26
0
def Warning_SaveOver(path):
    '''Returns - True to save, False dont save'''
    if sys.exists(sys.expandpath(path)):
        ret = Draw.PupMenu('Save over%t|' + path)
        if ret == -1:
            return False

    return True
Exemplo n.º 27
0
def deform2rvk():
    scn = Blender.Scene.GetCurrent()
    #	=================================================================
    # at leat 2 objects ===============================================
    #	=================================================================
    if len(scn.objects.selected) > 1:
        RVK1 = Object.GetSelected()[0]
        RVK2 = Object.GetSelected()[1]
        if RVK2.getType() == 'Mesh':
            copy_shapes(RVK1, RVK2)
    #	=================================================================
    # ... but if only one...===========================================
    #	=================================================================
    elif len(scn.objects.selected) == 1:
        name = "At least 2 Meshes  must be selected %t| Ok. %x1| Add one ? %x2"
        result = Draw.PupMenu(name)
        RVK1 = Object.GetSelected()[0]
        if result and RVK1.getType() == 'Mesh':
            Blender.Object.Duplicate(mesh=1)
            RVK2 = scn.objects.active
            mod = RVK2.modifiers
            for m in mod:
                RVK2.modifiers.remove(m)
            RVK2.LocX += 2.0
            copy_shapes(RVK1, RVK2)
            scn.objects.selected = []
            RVK2.sel = 1
            RVK1.sel = 1
        #	================================================================
        # ... and not a mesh...===========================================
        #	================================================================
        elif result:
            name = "Selected object must be a mesh %t| Ok. %x1"
            result = Draw.PupMenu(name)
            return
        else:
            return
    #	================================================================
    # ... if not object at all.  =====================================
    #	================================================================
    else:
        name = "At least one Mesh object must be selected %t| Ok. %x1"
        result = Draw.PupMenu(name)
        return

    Blender.Redraw()
Exemplo n.º 28
0
def do_export(sel_group, filepath):
	Window.WaitCursor(1)
	t = sys.time()

	#init Drawing ---------------------
	d=Drawing()
	#add Tables -----------------
	#d.blocks.append(b)					#table blocks
	d.styles.append(Style())			#table styles
	d.views.append(View('Normal'))		#table view
	d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1)))  #idem

	#add Entities --------------------
	something_ready = False
	#ViewVector = Mathutils.Vector(Window.GetViewVector())
	#print 'deb: ViewVector=', ViewVector #------------------
	mw0 = Window.GetViewMatrix()
	#mw0 = Window.GetPerspMatrix() #TODO: how get it working?
	mw = mw0.copy()
	if FLATTEN:
		m0 = Mathutils.Matrix()
		m0[2][2]=0.0
		mw *= m0 #flatten ViewMatrix

	for ob in sel_group:
		entities = []
		mx = ob.matrix.copy()
		mb = mx.copy()
		#print 'deb: mb    =\n', mb     #---------
		#print 'deb: mw0    =\n', mw0     #---------
		mx_n = mx.rotationPart() * mw0.rotationPart() #trans-matrix for normal_vectors
		if SCALE_FACTOR!=1.0: mx *= SCALE_FACTOR
		if FLATTEN:	mx *= mw
			
		#mx_inv = mx.copy().invert()
		#print 'deb: mx    =\n', mx     #---------
		#print 'deb: mx_inv=\n', mx_inv #---------

		if (ob.type == 'Mesh'):
			entities = exportMesh(ob, mx, mx_n)
		elif (ob.type == 'Curve'):
			entities = exportCurve(ob, mx)

		for e in entities:
			d.append(e)
			something_ready = True

	if something_ready:
		d.saveas(filepath)
		Window.WaitCursor(0)
		#Draw.PupMenu('DXF Exporter: job finished')
		print 'exported to %s' % filepath
		print 'finished in %.2f seconds' % (sys.time()-t)
	else:
		Window.WaitCursor(0)
		print "Abort: selected objects dont mach choosen export option, nothing exported!"
		Draw.PupMenu('DXF Exporter:   nothing exported!|selected objects dont mach choosen export option!')
Exemplo n.º 29
0
 def LoadSettings(targetob):
 	notloaded = 0
 	try: 
 		data = dBICG[targetob]
 		SetData(data, dwidget)
 		return not notloaded
 	except KeyError:
 		Draw.PupMenu("ERROR: OOPS. This objects data does not exist in the registry.")	
 		return notloaded
Exemplo n.º 30
0
def checkFile (filename):
    try:
        file = open(filename, "rb")
    except IOError:
        return 1
    file.close()
    if Draw.PupMenu("Overwrite?%%t|Overwrite file: %s" % filename)!=1:
        print "Cancelled\n"
        return 0
    return 1