forked from bartvdbraak/blender
adding a python function for cleaning strings (for filenames and export names) BPySys.py - used fotr obj and fbx export.
view.c - missed one smoothview/camera. Brigg's hide object patch didnt change the object selection flag, other minor changes also.
This commit is contained in:
parent
f5a40315ca
commit
60b3268c32
14
release/scripts/bpymodules/BPySys.py
Normal file
14
release/scripts/bpymodules/BPySys.py
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
## This was used to make V, but faster not to do all that
|
||||
##valid = 'abcdefghijklmnopqrstuvwxyzBCDEFGHIJKLMNOPQRSTUVWXYZ123456789-_'
|
||||
##v = range(255)
|
||||
##for c in valid: v.remove(ord(c))
|
||||
v = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,58,59,60,61,62,63,64,65,91,92,93,94,96,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254]
|
||||
invalid = ''.join([chr(i) for i in v])
|
||||
## del v, c, i, valid
|
||||
del v, i
|
||||
|
||||
def cleanName(name):
|
||||
for ch in invalid: name = name.replace(ch, '_')
|
||||
return name
|
||||
|
@ -43,6 +43,7 @@ will be exported as mesh data.
|
||||
|
||||
import Blender
|
||||
import BPyMesh
|
||||
import BPySys
|
||||
import BPyMessages
|
||||
import time
|
||||
from math import degrees
|
||||
@ -60,8 +61,7 @@ def sane_name(name, dct):
|
||||
except: pass
|
||||
|
||||
orig_name = name
|
||||
for ch in ' /\\~!@#$%^&*()+=[];\':",./<>?\t\r\n':
|
||||
name = name.replace(ch, '_')
|
||||
name = BPySys.cleanName(name)
|
||||
dct[orig_name] = name
|
||||
return name
|
||||
|
||||
|
@ -50,7 +50,7 @@ import Blender
|
||||
from Blender import Mesh, Scene, Window, sys, Image, Draw
|
||||
import BPyMesh
|
||||
import BPyObject
|
||||
|
||||
import BPySys
|
||||
import BPyMessages
|
||||
|
||||
# Returns a tuple - path,extension.
|
||||
@ -69,11 +69,6 @@ def fixName(name):
|
||||
return name.replace(' ', '_')
|
||||
|
||||
# Used to add the scene name into the filename without using odd chars
|
||||
def saneFilechars(name):
|
||||
for ch in ' /\\~!@#$%^&*()+=[];\':",./<>?\t\r\n':
|
||||
name = name.replace(ch, '_')
|
||||
return name
|
||||
|
||||
global MTL_DICT
|
||||
|
||||
# A Dict of Materials
|
||||
@ -615,7 +610,7 @@ def write_ui(filename):
|
||||
orig_frame = Blender.Get('curframe')
|
||||
|
||||
if EXPORT_ALL_SCENES: # Add scene name into the context_name
|
||||
context_name[1] = '_%s' % saneFilechars(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied.
|
||||
context_name[1] = '_%s' % BPySys.cleanName(scn.name) # WARNING, its possible that this could cause a collision. we could fix if were feeling parranoied.
|
||||
|
||||
# Export an animation?
|
||||
if EXPORT_ANIMATION:
|
||||
|
@ -5457,33 +5457,42 @@ void hookmenu(void)
|
||||
|
||||
void hide_objects(int select)
|
||||
{
|
||||
Base *b;
|
||||
int swap;
|
||||
for(b = G.scene->base.first; b; b=b->next){
|
||||
if(TESTBASE(b)==select){
|
||||
b->flag &= ~SELECT;
|
||||
b->object->restrictflag |= OB_RESTRICT_VIEW;
|
||||
DAG_object_flush_update(G.scene, b->object, OB_RECALC_DATA);
|
||||
Base *base;
|
||||
int changed = 0;
|
||||
for(base = FIRSTBASE; base; base=base->next){
|
||||
if(TESTBASE(base)==select){
|
||||
base->flag &= ~SELECT;
|
||||
base->object->flag = base->flag;
|
||||
base->object->restrictflag |= OB_RESTRICT_VIEW;
|
||||
DAG_object_flush_update(G.scene, base->object, OB_RECALC_DATA);
|
||||
changed = 1;
|
||||
if (base==BASACT) BASACT= NULL;
|
||||
}
|
||||
}
|
||||
G.scene->basact = NULL;
|
||||
allqueue(REDRAWVIEW3D,0);
|
||||
allqueue(REDRAWOOPS,0);
|
||||
if(select) BIF_undo_push("Hide Selected Objects");
|
||||
else if(select) BIF_undo_push("Hide Unselected Objects");
|
||||
if (changed) {
|
||||
allqueue(REDRAWVIEW3D,0);
|
||||
allqueue(REDRAWOOPS,0);
|
||||
if(select) BIF_undo_push("Hide Selected Objects");
|
||||
else if(select) BIF_undo_push("Hide Unselected Objects");
|
||||
}
|
||||
}
|
||||
|
||||
void show_objects(void)
|
||||
{
|
||||
Base *b;
|
||||
for(b = G.scene->base.first; b; b=b->next){
|
||||
if((b->lay & G.vd->lay) && b->object->restrictflag & OB_RESTRICT_VIEW){
|
||||
b->flag |= SELECT;
|
||||
b->object->restrictflag &= ~OB_RESTRICT_VIEW;
|
||||
DAG_object_flush_update(G.scene, b->object, OB_RECALC_DATA);
|
||||
Base *base;
|
||||
int changed = 0;
|
||||
for(base = FIRSTBASE; base; base=base->next){
|
||||
if((base->lay & G.vd->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
|
||||
base->flag |= SELECT;
|
||||
base->object->flag = base->flag;
|
||||
base->object->restrictflag &= ~OB_RESTRICT_VIEW;
|
||||
DAG_object_flush_update(G.scene, base->object, OB_RECALC_DATA);
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
BIF_undo_push("Unhide Objects");
|
||||
allqueue(REDRAWVIEW3D,0);
|
||||
allqueue(REDRAWOOPS,0);
|
||||
if (changed) {
|
||||
BIF_undo_push("Unhide Objects");
|
||||
allqueue(REDRAWVIEW3D,0);
|
||||
allqueue(REDRAWOOPS,0);
|
||||
}
|
||||
}
|
||||
|
@ -1414,23 +1414,30 @@ void centerview() /* like a localview without local! */
|
||||
|
||||
new_dist = size;
|
||||
|
||||
// correction for window aspect ratio
|
||||
/* correction for window aspect ratio */
|
||||
if(curarea->winy>2 && curarea->winx>2) {
|
||||
size= (float)curarea->winx/(float)curarea->winy;
|
||||
if(size<1.0) size= 1.0/size;
|
||||
new_dist*= size;
|
||||
}
|
||||
|
||||
if(G.vd->persp>1) {
|
||||
G.vd->persp= 1;
|
||||
}
|
||||
|
||||
G.vd->cursor[0]= -new_ofs[0];
|
||||
G.vd->cursor[1]= -new_ofs[1];
|
||||
G.vd->cursor[2]= -new_ofs[2];
|
||||
|
||||
smooth_view(G.vd, new_ofs, NULL, &new_dist, NULL);
|
||||
|
||||
if (G.vd->persp==2 && G.vd->camera) {
|
||||
float orig_lens= G.vd->lens;
|
||||
|
||||
G.vd->persp=1;
|
||||
G.vd->dist= 0.0;
|
||||
view_settings_from_ob(G.vd->camera, G.vd->ofs, NULL, NULL, &G.vd->lens);
|
||||
smooth_view(G.vd, new_ofs, NULL, &new_dist, &orig_lens);
|
||||
} else {
|
||||
if(G.vd->persp>=2)
|
||||
G.vd->persp= 1;
|
||||
|
||||
smooth_view(G.vd, new_ofs, NULL, &new_dist, NULL);
|
||||
}
|
||||
scrarea_queue_winredraw(curarea);
|
||||
BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user