forked from bartvdbraak/blender
Gui:
[ #4581 ] related to scripts window updates, details here: http://projects.blender.org/tracker/index.php?func=detail&aid=4581&group_id=9&atid=125 Scripts updated: -Jean-Michel Soler updated some of his scripts: paths importer (ai, eps, gimp, svg), kml / kmz importer and also updated Axiscopy.py by A Vanpoucke (xand) and the knife script (this version handles multiple materials) by Stefano Selleri and Wim Van Hoydonck. Thanks!
This commit is contained in:
parent
46110ec06b
commit
8aed0ead0b
@ -4,7 +4,7 @@
|
||||
Name: 'Axis Orientation Copy'
|
||||
Blender: 239
|
||||
Group: 'Object'
|
||||
Tip: 'Copy the axis orientation of the active object to all selected mesh objects'
|
||||
Tip: 'Copy local axis orientation of active object to all selected meshes (changes mesh data)'
|
||||
"""
|
||||
|
||||
__author__ = "A Vanpoucke (xand)"
|
||||
@ -27,14 +27,16 @@ selection), then select the object whose orientation will be copied from and
|
||||
finally run this script to update the angles.
|
||||
|
||||
Notes:<br>
|
||||
Before copying the orientation to each object, the script stores its
|
||||
transformation matrix. Then the angles are copied and after that the object's
|
||||
This script changes mesh data: the vertices are transformed.<br>
|
||||
Before copying the orientation to each object, the script stores its
|
||||
transformation matrix. Then the angles are copied and after that the object's
|
||||
vertices are transformed "back" so that they still have the same positions as
|
||||
before. In other words, the rotations are updated, but you won't notice that
|
||||
just from looking at the objects.<br>
|
||||
Checking their X, Y and Z rotation values with "Transform Properties" in
|
||||
Checking their X, Y and Z rotation values with "Transform Properties" in
|
||||
the 3D View's Object menu shows the angles are now the same of the active
|
||||
object.
|
||||
object. Or simply look at the transform manipulator handles in local transform
|
||||
orientation.
|
||||
"""
|
||||
|
||||
|
||||
@ -45,7 +47,7 @@ object.
|
||||
#from the previous script realignaxis
|
||||
#----------------------------------------------
|
||||
# Communiquer les problemes et erreurs sur:
|
||||
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
|
||||
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
@ -58,7 +60,7 @@ object.
|
||||
#
|
||||
# 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
|
||||
# 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
|
||||
@ -75,8 +77,8 @@ from Blender.Mathutils import *
|
||||
|
||||
def applyTransform(mesh,mat):
|
||||
for v in mesh.verts:
|
||||
vec = v.co*mat
|
||||
v.co[0], v.co[1], v.co[2] = vec[0], vec[1], vec[2]
|
||||
vec = v.co*mat
|
||||
v.co[0], v.co[1], v.co[2] = vec[0], vec[1], vec[2]
|
||||
|
||||
|
||||
|
||||
@ -86,30 +88,32 @@ lenob=len(oblist)
|
||||
|
||||
error = 0
|
||||
for o in oblist[1:]:
|
||||
if o.getType() != "Mesh":
|
||||
Draw.PupMenu("Error: selected objects must be meshes")
|
||||
error = 1
|
||||
if o.getType() != "Mesh":
|
||||
Draw.PupMenu("Error: selected objects must be meshes")
|
||||
error = 1
|
||||
|
||||
if not error:
|
||||
if lenob<2:
|
||||
Draw.PupMenu("Error: you must select at least 2 objects")
|
||||
else :
|
||||
source=oblist[0]
|
||||
nsource=source.name
|
||||
texte="Copy axis orientation from: " + nsource + " ?%t|OK"
|
||||
result=Draw.PupMenu(texte)
|
||||
if lenob<2:
|
||||
Draw.PupMenu("Error: you must select at least 2 objects")
|
||||
else :
|
||||
source=oblist[0]
|
||||
nsource=source.name
|
||||
texte="Copy axis orientation from: " + nsource + " ?%t|OK"
|
||||
result=Draw.PupMenu(texte)
|
||||
|
||||
|
||||
for cible in oblist[1:]:
|
||||
if source.rot!=cible.rot:
|
||||
rotcible=cible.mat.rotationPart().toEuler().toMatrix()
|
||||
rotsource=source.mat.rotationPart().toEuler().toMatrix()
|
||||
rotsourcet = Matrix(rotsource)
|
||||
rotsourcet.invert()
|
||||
mat=rotcible*rotsourcet
|
||||
ncible=cible.name
|
||||
me=NMesh.GetRaw(ncible)
|
||||
applyTransform(me,mat)
|
||||
NMesh.PutRaw(me,ncible)
|
||||
cible.makeDisplayList()
|
||||
cible.rot=source.rot
|
||||
for cible in oblist[1:]:
|
||||
if source.rot!=cible.rot:
|
||||
rotcible=cible.mat.rotationPart().toEuler().toMatrix()
|
||||
rotsource=source.mat.rotationPart().toEuler().toMatrix()
|
||||
rotsourcet = Matrix(rotsource)
|
||||
rotsourcet.invert()
|
||||
mat=rotcible*rotsourcet
|
||||
me=cible.getData()
|
||||
#ncible=cible.name
|
||||
#me=NMesh.GetRaw(ncible)
|
||||
applyTransform(me,mat)
|
||||
#NMesh.PutRaw(me,ncible)
|
||||
me.update()
|
||||
cible.makeDisplayList()
|
||||
cible.rot=source.rot
|
||||
|
@ -18,6 +18,8 @@
|
||||
compatibility increased up to AI 10.0 plain text
|
||||
# 0.1.7 : 2005/06/25, two more closepath improvements
|
||||
#
|
||||
# 0.1.8 : 2006/07/03, two more closepath improvements
|
||||
|
||||
"""
|
||||
SHARP_IMPORT=0
|
||||
SCALE=1
|
||||
@ -431,7 +433,17 @@ def scan_FILE(nom):
|
||||
|
||||
t=create_GEOtext(courbes)
|
||||
save_GEOfile(dir,name[0],t)
|
||||
|
||||
# 0.1.8 ---------------------------------
|
||||
# [O.select(0) for O in Blender.Scene.getCurrent().getChildren()]
|
||||
# 0.1.8 ---------------------------------
|
||||
|
||||
Open_GEOfile(dir,name[0])
|
||||
|
||||
# 0.1.8 ---------------------------------
|
||||
Blender.Object.Get()[-1].setName(name[0])
|
||||
# 0.1.8 ---------------------------------
|
||||
|
||||
else:
|
||||
pass
|
||||
#=====================================================================
|
||||
|
@ -1,6 +1,8 @@
|
||||
#----------------------------------------------
|
||||
# (c) jm soler juillet 2004-juin 2005 , released under Blender Artistic Licence
|
||||
# for the Blender 2.34-2.37 Python Scripts Bundle.
|
||||
#
|
||||
# July, 3rd, 2006 , juillet 2006
|
||||
#----------------------------------------------
|
||||
# Page officielle :
|
||||
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_import_eps.htm
|
||||
@ -427,6 +429,11 @@ def scan_FILE(nom):
|
||||
t=create_GEOtext(courbes)
|
||||
save_GEOfile(dir,name[0],t)
|
||||
Open_GEOfile(dir,name[0])
|
||||
|
||||
# 03 juillet 2006 ----------------------
|
||||
Blender.Object.Get()[-1].setName(name[0])
|
||||
# 03 juillet 2006 ----------------------
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#----------------------------------------------
|
||||
# (c) jm soler juillet 2004, released under Blender Artistic Licence
|
||||
# for the Blender 2.34 Python Scripts Bundle.
|
||||
# update : 04/07/2006
|
||||
#----------------------------------------------
|
||||
# Page officielle :
|
||||
# http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_import_gimp.htm
|
||||
@ -303,6 +304,10 @@ def scan_FILE(nom):
|
||||
t=create_GEOtext(courbes)
|
||||
save_GEOfile(dir,name[0],t)
|
||||
Open_GEOfile(dir,name[0])
|
||||
# 0.1.8 ---------------------------------
|
||||
Blender.Object.Get()[-1].setName(name[0])
|
||||
# 0.1.8 ---------------------------------
|
||||
|
||||
else:
|
||||
pass
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
# -*- coding: latin-1 -*-
|
||||
"""
|
||||
SVG 2 OBJ translater, 0.4.8
|
||||
Copyright (c) jm soler juillet/novembre 2004-janvier 2006,
|
||||
SVG 2 OBJ translater, 0.5.0
|
||||
Copyright (c) jm soler juillet/novembre 2004-juillet 2006,
|
||||
# ---------------------------------------------------------------
|
||||
released under GNU Licence
|
||||
for the Blender 2.40 Python Scripts Bundle.
|
||||
for the Blender 2.42 Python Scripts Bundle.
|
||||
Ce programme est libre, vous pouvez le redistribuer et/ou
|
||||
le modifier selon les termes de la Licence Publique Générale GNU
|
||||
publiée par la Free Software Foundation (version 2 ou bien toute
|
||||
@ -178,7 +178,22 @@ Changelog:
|
||||
('viewbox' is written 'viewBox', for instance) .
|
||||
Note that (at this time, 2006/05/01, 1OOo exports in svg
|
||||
but does not read its own export
|
||||
|
||||
|
||||
0.4.9 : - skipped version : private test
|
||||
|
||||
0.5.0 : - the script worked perfectly with Blender 2.41 but in Blender
|
||||
2.42, use the original svg name file + 'OOO.obj' to
|
||||
write a videoscape file made blender crash under window XP when
|
||||
the script loaded it . Curiously, use a more simple
|
||||
name with a sole 'O' solved this problem .
|
||||
|
||||
- script returned errors on open path : corrected
|
||||
|
||||
- in b2.42, several successive imports seem to be added to
|
||||
the same original curve . So now the script automaticaly
|
||||
renames the last group of imported curve with the original
|
||||
name file .
|
||||
|
||||
==================================================================================
|
||||
=================================================================================="""
|
||||
|
||||
@ -350,6 +365,7 @@ n0=0
|
||||
#=====================================================================
|
||||
CP=[0.0,0.0] #currentPoint
|
||||
|
||||
|
||||
#=====================================================================
|
||||
#===== to compare last position to the original move to displacement =
|
||||
#===== needed for cyclic definition inAI, EPS forma ================
|
||||
@ -363,8 +379,9 @@ def test_egalitedespositions(f1,f2):
|
||||
|
||||
def Open_GEOfile(dir,nom):
|
||||
global SCALE,BOUNDINGBOX, scale_
|
||||
#print 'test', dir+nom+'OOO.obj'
|
||||
if BLversion>=233:
|
||||
Blender.Load(dir+nom+'OOO.obj', 1)
|
||||
Blender.Load(dir+'O.obj', 1)
|
||||
BO=Blender.Object.Get()
|
||||
|
||||
BO[-1].RotY=3.1416
|
||||
@ -407,27 +424,30 @@ def create_GEOtext(courbes):
|
||||
t.append("%s %s \n"%(courbes.ITEM[k].flagUV[0],courbes.ITEM[k].flagUV[1]))
|
||||
|
||||
flag =0#courbes.ITEM[k].flagUV[0]
|
||||
|
||||
courbes.ITEM[k]
|
||||
for k2 in range(flag,len(courbes.ITEM[k].beziers_knot)):
|
||||
#k1 =courbes.ITEM[k].beziers_knot[k2]
|
||||
k1=ajustement(courbes.ITEM[k].beziers_knot[k2], SCALE)
|
||||
|
||||
t.append("%4f 0.0 %4f \n"%(k1[4],k1[5]))
|
||||
t.append("%4f 0.0 %4f \n"%(k1[0],k1[1]))
|
||||
t.append("%4f 0.0 %4f \n"%(k1[2],k1[3]))
|
||||
t.append("%4f 0.0 %4f\n"%(k1[4],k1[5]))
|
||||
t.append("%4f 0.0 %4f\n"%(k1[0],k1[1]))
|
||||
t.append("%4f 0.0 %4f\n"%(k1[2],k1[3]))
|
||||
t.append(str(courbes.ITEM[k].beziers_knot[k2].ha[0])+' '+str(courbes.ITEM[k].beziers_knot[k2].ha[1])+'\n')
|
||||
|
||||
return t
|
||||
|
||||
def save_GEOfile(dir,nom,t):
|
||||
f=open(dir+nom+'OOO.obj','w')
|
||||
# f=open(dir+nom+'OOO.obj','w')
|
||||
f=open(dir+'O.obj','w')
|
||||
f.writelines(t)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
#--------------------
|
||||
# 0.4.5 : for blender cvs 2.38 ....
|
||||
#--------------------
|
||||
def createCURVES(courbes):
|
||||
def createCURVES(courbes, name):
|
||||
global SCALE, B, BOUNDINGBOX,scale_
|
||||
from Blender import Curve, Object, Scene, BezTriple
|
||||
|
||||
@ -439,7 +459,9 @@ def createCURVES(courbes):
|
||||
elif scale_==3:
|
||||
SCALE=r[3]-r[1]
|
||||
|
||||
[o.select(0) for o in Scene.GetCurrent().getChildren()] #[o.select(0) for o in Object.Get()] - will not work
|
||||
#[o.select(0) for o in Object.Get()]
|
||||
OBJECT_LIST=[]
|
||||
|
||||
for I in courbes.ITEM:
|
||||
c = Curve.New()
|
||||
# ----------
|
||||
@ -447,10 +469,12 @@ def createCURVES(courbes):
|
||||
# ----------
|
||||
c.setResolu(24)
|
||||
scene = Scene.getCurrent()
|
||||
ob = Object.New('Curve')
|
||||
ob = Object.New('Curve',name+str(I))
|
||||
ob.link(c)
|
||||
scene.link(ob)
|
||||
ob.select(1)
|
||||
OBJECT_LIST.append(ob)
|
||||
|
||||
bzn=0
|
||||
#for b in courbes.ITEM[I].beziers_knot:
|
||||
for k2 in range(0,len(courbes.ITEM[I].beziers_knot)):
|
||||
@ -466,13 +490,21 @@ def createCURVES(courbes):
|
||||
cp2 = bz[4],bz[5],0.0 , bz[0],bz[1],0.0, bz[2],bz[3],0.0
|
||||
beztriple2 = BezTriple.New(cp2)
|
||||
bez.append(beztriple2)
|
||||
|
||||
|
||||
if courbes.ITEM[I].flagUV[0]==1 :
|
||||
#--------------------
|
||||
# 0.4.6 : cyclic flag ...
|
||||
#--------------------
|
||||
bez.flagU += 1
|
||||
|
||||
print 'done'
|
||||
OB_JOIN=OBJECT_LIST.pop()
|
||||
print 'done 2'
|
||||
|
||||
OB_JOIN.join(OBJECT_LIST)
|
||||
print 'done 3'
|
||||
for OBJ_DEL in OBJECT_LIST:
|
||||
scene.unlink(OBJ_DEL)
|
||||
|
||||
|
||||
|
||||
#=====================================================================
|
||||
@ -926,6 +958,7 @@ def ligne_tracee_h(c,D,n0,CP): #H,h
|
||||
l=[float(D[c[1]+1])+float(CP[0]),CP[1]]
|
||||
else:
|
||||
l=[float(D[c[1]+1]),CP[1]]
|
||||
|
||||
B=Bez()
|
||||
B.co=[l[0],l[1],l[0],l[1],l[0],l[1]]
|
||||
B.ha=[0,0]
|
||||
@ -983,7 +1016,9 @@ TAGtransform=['M','L','C','S','H','V','T','Q']
|
||||
tagTRANSFORM=0
|
||||
|
||||
def wash_DATA(ndata):
|
||||
|
||||
if ndata!='':
|
||||
print ndata
|
||||
while ndata[0]==' ':
|
||||
ndata=ndata[1:]
|
||||
while ndata[-1]==' ':
|
||||
@ -1013,29 +1048,42 @@ def list_DATA(DATA):
|
||||
Par exemple :
|
||||
d="'M0,14.0 z" devient ['M','0.0','14.0','z']
|
||||
"""
|
||||
# ----------------------------------------
|
||||
# 1 / reprer la position des differents tag
|
||||
# ----------------------------------------
|
||||
tagplace=[]
|
||||
|
||||
# ----------------------------------------
|
||||
# construire une liste avec chaque emplacement
|
||||
# ----------------------------------------
|
||||
for d in Actions.keys():
|
||||
b1=0
|
||||
b2=len(DATA)
|
||||
while DATA.find(d,b1,b2)!=-1 :
|
||||
tagplace.append(DATA.find(d,b1,b2))
|
||||
b1=DATA.find(d,b1,b2)+1
|
||||
# ----------------------------------------
|
||||
# remettre la liste dans l'ordre de presentation
|
||||
# des donnes
|
||||
# ----------------------------------------
|
||||
tagplace.sort()
|
||||
tpn=range(len(tagplace)-1)
|
||||
|
||||
tpn=range(len(tagplace))
|
||||
#--------------------
|
||||
# 0.3.5 :: short data,only one tag
|
||||
# 0.3.5 :: short data, only one tag
|
||||
#--------------------
|
||||
if len(tagplace)-1>0:
|
||||
DATA2=[]
|
||||
for t in tpn:
|
||||
for t in tpn[:-1]:
|
||||
DATA2.append(DATA[tagplace[t]:tagplace[t]+1])
|
||||
ndata=DATA[tagplace[t]+1:tagplace[t+1]]
|
||||
if DATA2[-1] not in ['z','Z'] :
|
||||
ndata=wash_DATA(ndata)
|
||||
for n in ndata : DATA2.append(n)
|
||||
DATA2.append(DATA[tagplace[t+1]:tagplace[t+1]+1])
|
||||
DATA2.append(DATA[tagplace[t+1]:tagplace[t+1]+1])
|
||||
|
||||
if DATA2[-1] not in ['z','Z'] and len(DATA)-1>=tagplace[t+1]+1:
|
||||
ndata=DATA[tagplace[t+1]+1:-1]
|
||||
ndata=DATA[tagplace[t+1]+1:]
|
||||
ndata=wash_DATA(ndata)
|
||||
for n in ndata : DATA2.append(n)
|
||||
else:
|
||||
@ -1309,11 +1357,15 @@ def scan_FILE(nom):
|
||||
save_GEOfile(dir,name[0],t)
|
||||
Open_GEOfile(dir,name[0])
|
||||
|
||||
# 0.4.9 ----------------------
|
||||
Blender.Object.Get()[-1].setName(name[0])
|
||||
# 0.4.9 ----------------------
|
||||
|
||||
elif courbes.number_of_items>0 and CVS==1 :
|
||||
#--------------------
|
||||
# 0.4.5
|
||||
# 0.4.5 and 0.4.9
|
||||
#--------------------
|
||||
createCURVES(courbes)
|
||||
createCURVES(courbes, name[0])
|
||||
|
||||
else:
|
||||
pass
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ Tooltip: 'Cut selected mesh(es) along an active plane w/o creating doubles'
|
||||
|
||||
__author__ = ["Stefano <S68> Selleri", "Wim Van Hoydonck"]
|
||||
__url__ = ("blender", "elysiun")
|
||||
__version__ = "0.0.8a 03/31/04"
|
||||
__version__ = "0.0.8b 05/13/06"
|
||||
|
||||
__bpydoc__ = """\
|
||||
"Blender Knife Tool" uses the active mesh plane to cut all selected meshes.
|
||||
@ -33,26 +33,28 @@ new objects;<br>
|
||||
|
||||
# $Id$
|
||||
#
|
||||
###################################################################
|
||||
# #
|
||||
# Blender Knife Tool #
|
||||
# #
|
||||
# v. 0.0.0 - 0.0.6 (C) December 2002 Stefano <S68> Selleri #
|
||||
# v. 0.0.7 (C) March 2004 Wim Van Hoydonck #
|
||||
# v. 0.0.8 (C) March 2004 Wim Van Hoydonck & Stefano <S68> Selleri#
|
||||
# #
|
||||
# Released under the Blender Artistic Licence (BAL) #
|
||||
# See www.blender.org #
|
||||
# #
|
||||
# Works in Blender 2.32 and higher #
|
||||
# #
|
||||
# this script can be found online at: #
|
||||
# http://users.pandora.be/tuinbels/scripts/knife-0.0.8.py #
|
||||
# http://www.selleri.org/Blender #
|
||||
# #
|
||||
# email: tuinbels@hotmail.com #
|
||||
# selleri@det.unifi.it #
|
||||
###################################################################
|
||||
####################################################################
|
||||
# #
|
||||
# Blender Knife Tool #
|
||||
# #
|
||||
# v. 0.0.0 - 0.0.6 (C) December 2002 Stefano <S68> Selleri #
|
||||
# v. 0.0.7 (C) March 2004 Wim Van Hoydonck #
|
||||
# v. 0.0.8 (C) March 2004 Wim Van Hoydonck & Stefano <S68> Selleri #
|
||||
# ( May 2006 jm soler( jms) for material management )#
|
||||
# #
|
||||
# Released under the Blender Artistic Licence (BAL) #
|
||||
# See www.blender.org #
|
||||
# #
|
||||
# Works in Blender 2.32 and higher #
|
||||
# #
|
||||
# this script can be found online at: #
|
||||
# http://users.pandora.be/tuinbels/scripts/knife-0.0.8.py #
|
||||
# http://www.selleri.org/Blender #
|
||||
# http://cobalt3d.free.fr/didacticiel/blender/tutor/images/python/knife_in_color/knife_color.py
|
||||
# #
|
||||
# email: tuinbels@hotmail.com #
|
||||
# selleri@det.unifi.it #
|
||||
####################################################################
|
||||
# History #
|
||||
# V: 0.0.0 - 08-12-02 - The script starts to take shape, a #
|
||||
# history is now deserved :) #
|
||||
@ -91,6 +93,7 @@ new objects;<br>
|
||||
# 0.0.8a- 31-03-04 - Added some error messages #
|
||||
# - Cut multiple meshes at once #
|
||||
# #
|
||||
# O.0.8b -13-05-06 - Added multi-material management (jms) #
|
||||
###################################################################
|
||||
|
||||
import Blender
|
||||
@ -118,6 +121,12 @@ BL_VERSION = Blender.Get('version')
|
||||
if (BL_VERSION<=223):
|
||||
import Blender210
|
||||
|
||||
lenface = []
|
||||
vertglob = []
|
||||
vertidx = []
|
||||
vertdist = []
|
||||
facemat = []
|
||||
|
||||
#=================================#
|
||||
# Vector and matrix manipulations #
|
||||
#=================================#
|
||||
@ -265,17 +274,19 @@ def FacePosition(dist):
|
||||
# Append existing faces / create new faces #
|
||||
#==========================================#
|
||||
|
||||
def FaceAppend(me, fidx):
|
||||
def FaceAppend(me, fidx, fmat):
|
||||
#
|
||||
# append a face to a mesh based on a list of vertex-indices
|
||||
#
|
||||
nf = NMesh.Face()
|
||||
|
||||
nf.mat=fmat
|
||||
|
||||
for i in fidx:
|
||||
nf.v.append(me.verts[i])
|
||||
|
||||
me.faces.append(nf)
|
||||
|
||||
def FaceMake(me, vl):
|
||||
def FaceMake(me, vl, fmat):
|
||||
#
|
||||
# make one or two new faces based on a list of vertex-indices
|
||||
#
|
||||
@ -283,11 +294,13 @@ def FaceMake(me, vl):
|
||||
|
||||
if len(vl) <= 4:
|
||||
nf = NMesh.Face()
|
||||
nf.mat=fmat
|
||||
for i in range(len(vl)):
|
||||
nf.v.append(me.verts[vl[i]])
|
||||
me.faces.append(nf)
|
||||
else:
|
||||
nf = NMesh.Face()
|
||||
nf.mat=fmat
|
||||
nf.v.append(me.verts[vl[0]])
|
||||
nf.v.append(me.verts[vl[1]])
|
||||
nf.v.append(me.verts[vl[2]])
|
||||
@ -295,6 +308,7 @@ def FaceMake(me, vl):
|
||||
me.faces.append(nf)
|
||||
|
||||
nf = NMesh.Face()
|
||||
nf.mat=fmat
|
||||
nf.v.append(me.verts[vl[3]])
|
||||
nf.v.append(me.verts[vl[4]])
|
||||
nf.v.append(me.verts[vl[0]])
|
||||
@ -419,6 +433,8 @@ def Split(Obj, MeshPos, MeshNeg, Vglob, Vidx, N, d0, newvidx, newvcoo, totverts,
|
||||
def CutMesh():
|
||||
global msg
|
||||
global RBmesh0,RBmesh1,RBmesh2
|
||||
global lenface, vertglob, vertidx, vertdist, facemat
|
||||
|
||||
#if timport == 1:
|
||||
# start = time.clock()
|
||||
start = time()
|
||||
@ -454,32 +470,26 @@ def CutMesh():
|
||||
|
||||
# loop to cut multiple meshes at once
|
||||
for o in range(1, total):
|
||||
|
||||
Obj = selected_obs[o]
|
||||
|
||||
if (NoErrors == 0) :
|
||||
|
||||
m = Obj.getData()
|
||||
|
||||
if RBmesh1.val == 1:
|
||||
|
||||
MeshNew = NMesh.GetRaw()
|
||||
|
||||
MeshNew.materials = m.materials[:]
|
||||
if RBmesh2.val == 1:
|
||||
|
||||
MeshPos = NMesh.GetRaw()
|
||||
MeshPos.materials = m.materials[:]
|
||||
MeshNeg = NMesh.GetRaw()
|
||||
|
||||
MeshNeg.materials = m.materials[:]
|
||||
# get the indices of the faces of the mesh
|
||||
idx = []
|
||||
for i in range(len(m.faces)):
|
||||
idx.append(i)
|
||||
|
||||
# if idx is not reversed, this results in a list index out of range if
|
||||
# the original mesh is used (RBmesh1 == 0)
|
||||
idx.reverse()
|
||||
|
||||
lenface, vertglob, vertidx, vertdist = [], [], [], []
|
||||
lenface, vertglob, vertidx, vertdist, facemat = [], [], [], [], []
|
||||
|
||||
# total number of vertices
|
||||
totverts = len(m.verts)
|
||||
@ -491,6 +501,7 @@ def CutMesh():
|
||||
for i in idx:
|
||||
fvertidx, Ve, dist = [], [], []
|
||||
fa = m.faces[i]
|
||||
facemat.append(fa.mat)
|
||||
lenface.append(len(fa))
|
||||
for v in fa.v:
|
||||
globpos = GlobalPosition(v.co, Obj)
|
||||
@ -531,24 +542,24 @@ def CutMesh():
|
||||
# no intersection
|
||||
if fp > 0:
|
||||
if RBmesh0.val == 1:
|
||||
FaceAppend(m, vertidx[i])
|
||||
FaceAppend(m, vertidx[i], facemat[i])
|
||||
|
||||
elif RBmesh1.val == 1:
|
||||
FaceAppend(MeshNew, vertidx[i])
|
||||
FaceAppend(MeshNew, vertidx[i], facemat[i])
|
||||
|
||||
elif RBmesh2.val == 1:
|
||||
FaceAppend(MeshPos, vertidx[i])
|
||||
FaceAppend(MeshPos, vertidx[i], facemat[i])
|
||||
|
||||
if testidxpos == []:
|
||||
testidxpos = vertidx[i]
|
||||
elif fp < 0:
|
||||
if RBmesh0.val == 1:
|
||||
FaceAppend(m, vertidx[i])
|
||||
FaceAppend(m, vertidx[i],facemat[i])
|
||||
elif RBmesh1.val == 1:
|
||||
FaceAppend(MeshNew, vertidx[i])
|
||||
FaceAppend(MeshNew, vertidx[i],facemat[i])
|
||||
|
||||
elif RBmesh2.val == 1:
|
||||
FaceAppend(MeshNeg, vertidx[i])
|
||||
FaceAppend(MeshNeg, vertidx[i],facemat[i])
|
||||
|
||||
if testidxneg == []:
|
||||
testidxneg = vertidx[i]
|
||||
@ -560,15 +571,15 @@ def CutMesh():
|
||||
vlp, vln, newvidx, newvcoo = Split(Obj, MeshNew, MeshNew, vertglob[i], vertidx[i], PNormal, POffset, newvidx, newvcoo, totverts, vertdist[i])
|
||||
|
||||
if vlp != 0 and vln != 0:
|
||||
FaceMake(MeshNew, vlp)
|
||||
FaceMake(MeshNew, vln)
|
||||
FaceMake(MeshNew, vlp, facemat[i])
|
||||
FaceMake(MeshNew, vln, facemat[i] )
|
||||
# two new meshes
|
||||
elif RBmesh2.val == 1:
|
||||
vlp, vln, newvidx, newvcoo = Split(Obj, MeshPos, MeshNeg, vertglob[i], vertidx[i], PNormal, POffset, newvidx, newvcoo, totverts, vertdist[i])
|
||||
|
||||
if vlp != 0 and vln != 0:
|
||||
FaceMake(MeshPos, vlp)
|
||||
FaceMake(MeshNeg, vln)
|
||||
FaceMake(MeshPos, vlp, facemat[i])
|
||||
FaceMake(MeshNeg, vln, facemat[i])
|
||||
|
||||
# use old mesh
|
||||
elif RBmesh0.val == 1:
|
||||
@ -576,8 +587,8 @@ def CutMesh():
|
||||
vlp, vln, newvidx, newvcoo = Split(Obj, m, m, vertglob[i], vertidx[i], PNormal, POffset, newvidx, newvcoo, totverts, vertdist[i])
|
||||
|
||||
if vlp != 0 and vln != 0:
|
||||
FaceMake(m, vlp)
|
||||
FaceMake(m, vln)
|
||||
FaceMake(m, vlp, facemat[i])
|
||||
FaceMake(m, vln, facemat[i])
|
||||
|
||||
if RBmesh1.val == 1:
|
||||
|
||||
@ -652,9 +663,9 @@ def draw():
|
||||
|
||||
BGL.glColor3f(1, 1, 1)
|
||||
BGL.glRasterPos2d(8, 200)
|
||||
Draw.Text("Blender Knife Tool - V. 0.0.8a - 26 March 2004")
|
||||
Draw.Text("Blender Knife Tool - V. 0.0.8b - 13 May 2006")
|
||||
BGL.glRasterPos2d(8, 185)
|
||||
Draw.Text("by Wim <tuinbels> Van Hoydonck & Stefano <S68> Selleri")
|
||||
Draw.Text("by Wim <tuinbels> Van Hoydonck & Stefano <S68> Selleri (+ <jms> ) ")
|
||||
Draw.Button("Exit", 1, 430, 185, 40, 20)
|
||||
|
||||
RBmesh0 = Draw.Toggle("Edit Object", 10,10,157,153,18,RBmesh0.val, "The knife creates new vertices in the selected object.");
|
||||
|
@ -91,19 +91,6 @@ void drawscriptspace(ScrArea *sa, void *spacedata)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
myortho2(-0.5, curarea->winrct.xmax-curarea->winrct.xmin-0.5, -0.5, curarea->winrct.ymax-curarea->winrct.ymin-0.5);
|
||||
|
||||
if (!sc->script) {
|
||||
script = G.main->script.first;
|
||||
|
||||
while (script) {
|
||||
|
||||
if (script->py_draw || script->py_event || script->py_button) {
|
||||
sc->script = script;
|
||||
break;
|
||||
}
|
||||
else script = script->id.next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sc->script) return;
|
||||
|
||||
script = sc->script;
|
||||
|
Loading…
Reference in New Issue
Block a user