Compare commits
20 Commits
temp-ghash
...
blender2.4
Author | SHA1 | Date | |
---|---|---|---|
ea6fd84d6d | |||
ea1eca85a5 | |||
0f1eea37f3 | |||
422cc6ac3f | |||
470f124e89 | |||
2662d36a50 | |||
8c6243b508 | |||
e22aab98d5 | |||
330dbe577b | |||
5d7e15b80d | |||
ec2db89d1d | |||
9927b361bd | |||
f0b048bf3c | |||
5a70fc9045 | |||
![]() |
06f515e15e | ||
a5e5a05fc2 | |||
b7863917b7 | |||
9a1cb75d01 | |||
43fc13ed34 | |||
c9fcaff607 |
@@ -99,4 +99,8 @@ MACRO(SETUP_LIBLINKS
|
||||
IF(WIN32)
|
||||
TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB})
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX AND NOT APPLE)
|
||||
TARGET_LINK_LIBRARIES(${target} ${CMAKE_DL_LIBS})
|
||||
TARGET_LINK_LIBRARIES(${target} ${X11_X11_LIB})
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
ENDMACRO(SETUP_LIBLINKS)
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "guardedalloc/MEM_guardedalloc.h"
|
||||
#include "guardedalloc/BLO_sys_types.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#dxfLibrary.py : provides functions for generating DXF files
|
||||
# --------------------------------------------------------------------------
|
||||
__version__ = "v1.33 - 2009.06.16"
|
||||
__version__ = "v1.35 - 2010.06.23"
|
||||
__author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
|
||||
__license__ = "GPL"
|
||||
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
|
||||
__url__ = "http://wiki.blender.org/index.php/Extensions:2.4/Py/Scripts/Export/DXF"
|
||||
__bpydoc__ ="""The library to export geometry data to DXF format r12 version.
|
||||
|
||||
Copyright %s
|
||||
@@ -18,12 +18,19 @@ IDEAs:
|
||||
-
|
||||
|
||||
TODO:
|
||||
- add support for DXFr14 (needs extended file header)
|
||||
- add support for SPLINEs (possible first in DXFr14 version)
|
||||
- add support for DXFr14 version (needs extended file header)
|
||||
- add support for DXF-SPLINEs (possible first in DXFr14 version)
|
||||
- add support for DXF-MTEXT
|
||||
- add user preset for floating point precision (3-16?)
|
||||
|
||||
History
|
||||
v1.33 - 2009.06.16 by migius
|
||||
v1.35 - 2010.06.23 by migius
|
||||
- added (as default) writing to DXF file without RAM-buffering: faster and low-RAM-machines friendly
|
||||
v1.34 - 2010.06.20 by migius
|
||||
- bugfix POLYFACE
|
||||
- added DXF-flags for POLYLINE and VERTEX class (NURBS-export)
|
||||
v1.33 - 2009.07.03 by migius
|
||||
- fix MTEXT newline bug (not supported by DXF-Exporter yet)
|
||||
- modif _point(): converts all coords to floats
|
||||
- modif LineType class: implement elements
|
||||
- added VPORT class, incl. defaults
|
||||
@@ -93,7 +100,6 @@ _HEADER_POINTS=['insbase','extmin','extmax']
|
||||
#---helper functions-----------------------------------
|
||||
def _point(x,index=0):
|
||||
"""Convert tuple to a dxf point"""
|
||||
#print 'deb: _point=', x #-------------
|
||||
return '\n'.join([' %s\n%s'%((i+1)*10+index,float(x[i])) for i in range(len(x))])
|
||||
|
||||
def _points(plist):
|
||||
@@ -205,7 +211,7 @@ BY_STYLE = 5 #the flow direction is inherited from the associated text style
|
||||
AT_LEAST = 1 #taller characters will override
|
||||
EXACT = 2 #taller characters will not override
|
||||
|
||||
#---polyline flags
|
||||
#---polyline flag 70
|
||||
CLOSED =1 # This is a closed polyline (or a polygon mesh closed in the M direction)
|
||||
CURVE_FIT =2 # Curve-fit vertices have been added
|
||||
SPLINE_FIT =4 # Spline-fit vertices have been added
|
||||
@@ -215,6 +221,12 @@ CLOSED_N =32 # The polygon mesh is closed in the N direction
|
||||
POLYFACE_MESH =64 # The polyline is a polyface mesh
|
||||
CONTINOUS_LINETYPE_PATTERN =128 # The linetype pattern is generated continuously around the vertices of this polyline
|
||||
|
||||
#---polyline flag 75, = curve type
|
||||
QUADRIC_NURBS = 5
|
||||
CUBIC_NURBS = 6
|
||||
BEZIER_CURVE = 8
|
||||
|
||||
|
||||
#---text flags
|
||||
#horizontal
|
||||
LEFT = 0
|
||||
@@ -269,7 +281,6 @@ class Face(_Entity):
|
||||
|
||||
def __str__(self):
|
||||
out = ' 0\n3DFACE\n%s%s\n' %(self._common(),_points(self.points))
|
||||
#print 'deb:out=', out #-------------------
|
||||
return out
|
||||
|
||||
#-----------------------------------------------
|
||||
@@ -318,34 +329,34 @@ class Line(_Entity):
|
||||
|
||||
#-----------------------------------------------
|
||||
class PolyLine(_Entity):
|
||||
def __init__(self,points,org_point=[0,0,0],flag=0,width=None,**common):
|
||||
def __init__(self,points,org_point=[0,0,0],flag70=0,flag75=0,width=None,**common):
|
||||
#width = number, or width = list [width_start=None, width_end=None]
|
||||
#for 2d-polyline: points = [ [x, y, z, width_start=None, width_end=None, bulge=0 or None], ...]
|
||||
#for 3d-polyline: points = [ [x, y, z], ...]
|
||||
#for 2d-polyline: points = [ [[x, y, z], vflag=None, [width_start=None, width_end=None], bulge=0 or None] ...]
|
||||
#for 3d-polyline: points = [ [[x, y, z], vflag=None], ...]
|
||||
#for polyface: points = [points_list, faces_list]
|
||||
_Entity.__init__(self,**common)
|
||||
self.points=points
|
||||
self.org_point=org_point
|
||||
self.flag=flag
|
||||
self.pflag70 = flag70
|
||||
self.pflag75 = flag75
|
||||
self.polyface = False
|
||||
self.polyline2d = False
|
||||
self.faces = [] # dummy value
|
||||
self.width= None # dummy value
|
||||
if self.flag & POLYFACE_MESH:
|
||||
if self.pflag70 & POLYFACE_MESH:
|
||||
self.polyface=True
|
||||
self.points=points[0]
|
||||
self.faces=points[1]
|
||||
self.p_count=len(self.points)
|
||||
self.f_count=len(self.faces)
|
||||
elif not self.flag & POLYLINE_3D:
|
||||
elif not (self.pflag70 & POLYLINE_3D):
|
||||
self.polyline2d = True
|
||||
if width:
|
||||
if type(width)!='list':
|
||||
width=[width,width]
|
||||
if type(width)!='list': width=[width,width]
|
||||
self.width=width
|
||||
|
||||
def __str__(self):
|
||||
result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.flag)
|
||||
result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.pflag70)
|
||||
result+=' 66\n1\n'
|
||||
result+='%s\n' %_point(self.org_point)
|
||||
if self.polyface:
|
||||
@@ -353,23 +364,32 @@ class PolyLine(_Entity):
|
||||
result+=' 72\n%s\n' %self.f_count
|
||||
elif self.polyline2d:
|
||||
if self.width!=None: result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
|
||||
if self.pflag75:
|
||||
result+=' 75\n%s\n' %self.pflag75
|
||||
for point in self.points:
|
||||
result+=' 0\nVERTEX\n'
|
||||
result+=' 8\n%s\n' %self.layer
|
||||
if self.polyface:
|
||||
result+='%s\n' %_point(point[0:3])
|
||||
result+='%s\n' %_point(point)
|
||||
result+=' 70\n192\n'
|
||||
elif self.polyline2d:
|
||||
result+='%s\n' %_point(point[0:2])
|
||||
if len(point)>4:
|
||||
width1, width2 = point[3], point[4]
|
||||
result+='%s\n' %_point(point[0])
|
||||
flag = point[1]
|
||||
if len(point)>2:
|
||||
[width1, width2] = point[2]
|
||||
if width1!=None: result+=' 40\n%s\n' %width1
|
||||
if width2!=None: result+=' 41\n%s\n' %width2
|
||||
if len(point)==6:
|
||||
bulge = point[5]
|
||||
if len(point)==4:
|
||||
bulge = point[3]
|
||||
if bulge: result+=' 42\n%s\n' %bulge
|
||||
if flag:
|
||||
result+=' 70\n%s\n' %flag
|
||||
else:
|
||||
result+='%s\n' %_point(point[0:3])
|
||||
result+='%s\n' %_point(point[0])
|
||||
flag = point[1]
|
||||
if flag:
|
||||
result+=' 70\n%s\n' %flag
|
||||
|
||||
for face in self.faces:
|
||||
result+=' 0\nVERTEX\n'
|
||||
result+=' 8\n%s\n' %self.layer
|
||||
@@ -456,7 +476,7 @@ class Mtext(Text):
|
||||
else:spacingWidth=self.height*self.spacingFactor
|
||||
for text in texts:
|
||||
while text:
|
||||
result+='%s\n'%Text(text[:self.width],
|
||||
result+='%s' %Text(text[:self.width],
|
||||
point=(self.point[0]+x*spacingWidth,
|
||||
self.point[1]+y*spacingWidth,
|
||||
self.point[2]),
|
||||
@@ -472,43 +492,46 @@ class Mtext(Text):
|
||||
|
||||
#-----------------------------------------------
|
||||
##class _Mtext(_Entity):
|
||||
## """Mtext not functioning for minimal dxf."""
|
||||
## def __init__(self,text='',point=(0,0,0),attachment=1,
|
||||
## charWidth=None,charHeight=1,direction=1,height=100,rotation=0,
|
||||
## spacingStyle=None,spacingFactor=None,style=None,width=100,
|
||||
## xdirection=None,**common):
|
||||
## _Entity.__init__(self,**common)
|
||||
## self.text=text
|
||||
## self.point=point
|
||||
## self.attachment=attachment
|
||||
## self.charWidth=charWidth
|
||||
## self.charHeight=charHeight
|
||||
## self.direction=direction
|
||||
## self.height=height
|
||||
## self.rotation=rotation
|
||||
## self.spacingStyle=spacingStyle
|
||||
## self.spacingFactor=spacingFactor
|
||||
## self.style=style
|
||||
## self.width=width
|
||||
## self.xdirection=xdirection
|
||||
## def __str__(self):
|
||||
## input=self.text
|
||||
## text=''
|
||||
## while len(input)>250:
|
||||
## text+='3\n%s\n'%input[:250]
|
||||
## input=input[250:]
|
||||
## text+='1\n%s\n'%input
|
||||
## result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s\n'%\
|
||||
## (self._common(),_point(self.point),self.charHeight,self.width,
|
||||
## self.attachment,self.direction,text,
|
||||
## self.height,
|
||||
## self.rotation)
|
||||
## if self.style:result+='7\n%s\n'%self.style
|
||||
## if self.xdirection:result+='%s\n'%_point(self.xdirection,1)
|
||||
## if self.charWidth:result+='42\n%s\n'%self.charWidth
|
||||
## if self.spacingStyle:result+='73\n%s\n'%self.spacingStyle
|
||||
## if self.spacingFactor:result+='44\n%s\n'%self.spacingFactor
|
||||
## return result
|
||||
"""Mtext not functioning for minimal dxf."""
|
||||
"""
|
||||
def __init__(self,text='',point=(0,0,0),attachment=1,
|
||||
charWidth=None,charHeight=1,direction=1,height=100,rotation=0,
|
||||
spacingStyle=None,spacingFactor=None,style=None,width=100,
|
||||
xdirection=None,**common):
|
||||
_Entity.__init__(self,**common)
|
||||
self.text=text
|
||||
self.point=point
|
||||
self.attachment=attachment
|
||||
self.charWidth=charWidth
|
||||
self.charHeight=charHeight
|
||||
self.direction=direction
|
||||
self.height=height
|
||||
self.rotation=rotation
|
||||
self.spacingStyle=spacingStyle
|
||||
self.spacingFactor=spacingFactor
|
||||
self.style=style
|
||||
self.width=width
|
||||
self.xdirection=xdirection
|
||||
def __str__(self):
|
||||
input=self.text
|
||||
text=''
|
||||
while len(input)>250:
|
||||
text+='3\n%s\n'%input[:250]
|
||||
input=input[250:]
|
||||
text+='1\n%s\n'%input
|
||||
result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s\n'%\
|
||||
(self._common(),_point(self.point),self.charHeight,self.width,
|
||||
self.attachment,self.direction,text,
|
||||
self.height,
|
||||
self.rotation)
|
||||
if self.style:result+='7\n%s\n'%self.style
|
||||
if self.xdirection:result+='%s\n'%_point(self.xdirection,1)
|
||||
if self.charWidth:result+='42\n%s\n'%self.charWidth
|
||||
if self.spacingStyle:result+='73\n%s\n'%self.spacingStyle
|
||||
if self.spacingFactor:result+='44\n%s\n'%self.spacingFactor
|
||||
return result
|
||||
"""
|
||||
|
||||
|
||||
#---tables ---------------------------------------------------
|
||||
#-----------------------------------------------
|
||||
@@ -591,11 +614,11 @@ class VPort(_Call):
|
||||
target=(0.0,0.0,0.0),
|
||||
height=1.0,
|
||||
ratio=1.0,
|
||||
lens=50,
|
||||
frontClipping=0,
|
||||
backClipping=0,
|
||||
snap_rotation=0,
|
||||
twist=0,
|
||||
lens=50.0,
|
||||
frontClipping=0.0,
|
||||
backClipping=0.0,
|
||||
snap_rotation=0.0,
|
||||
twist=0.0,
|
||||
mode=0,
|
||||
circle_zoom=100,
|
||||
fast_zoom=1,
|
||||
@@ -669,15 +692,15 @@ class VPort(_Call):
|
||||
#-----------------------------------------------
|
||||
class View(_Call):
|
||||
def __init__(self,name,flag=0,
|
||||
width=1,
|
||||
height=1,
|
||||
width=1.0,
|
||||
height=1.0,
|
||||
center=(0.5,0.5),
|
||||
direction=(0,0,1),
|
||||
target=(0,0,0),
|
||||
lens=50,
|
||||
frontClipping=0,
|
||||
backClipping=0,
|
||||
twist=0,mode=0
|
||||
direction=(0.0,0.0,1.0),
|
||||
target=(0.0,0.0,0.0),
|
||||
lens=50.0,
|
||||
frontClipping=0.0,
|
||||
backClipping=0.0,
|
||||
twist=0.0,mode=0
|
||||
):
|
||||
self.name=name
|
||||
self.flag=flag
|
||||
@@ -739,10 +762,11 @@ class Drawing(_Collection):
|
||||
self.vports=copy.copy(vports)
|
||||
self.blocks=copy.copy(blocks)
|
||||
self.fileName=fileName
|
||||
#print 'deb: blocks=',blocks #----------
|
||||
#private
|
||||
#self.acadver='9\n$ACADVER\n1\nAC1006\n'
|
||||
self.acadver=' 9\n$ACADVER\n 1\nAC1009\n'
|
||||
"""DXF AutoCAD-Release format codes
|
||||
"""DXF AutoCAD-Release format codes:
|
||||
AC1021 2008, 2007
|
||||
AC1018 2006, 2005, 2004
|
||||
AC1015 2002, 2000i, 2000
|
||||
@@ -787,22 +811,44 @@ class Drawing(_Collection):
|
||||
self._table('view',[str(x) for x in self.views]),
|
||||
]
|
||||
tables=self._section('tables',tables)
|
||||
|
||||
blocks=self._section('blocks',[str(x) for x in self.blocks])
|
||||
|
||||
entities=self._section('entities',[str(x) for x in self.entities])
|
||||
|
||||
all=''.join([header,tables,blocks,entities,' 0\nEOF\n'])
|
||||
return all
|
||||
|
||||
def _write_section(self,file,name,data):
|
||||
file.write(' 0\nSECTION\n 2\n%s\n'%name.upper())
|
||||
for x in data:
|
||||
file.write(str(x))
|
||||
file.write(' 0\nENDSEC\n')
|
||||
|
||||
def saveas(self,fileName):
|
||||
def saveas(self,fileName,buffer=0):
|
||||
"""Writes DXF file. Needs target file name. If optional parameter buffer>0, then switch to old behavior: store entire output string in RAM.
|
||||
"""
|
||||
self.fileName=fileName
|
||||
self.save()
|
||||
if buffer: self.save()
|
||||
else: self.export()
|
||||
|
||||
def save(self):
|
||||
test=open(self.fileName,'w')
|
||||
test.write(str(self))
|
||||
test.close()
|
||||
outfile=open(self.fileName,'w')
|
||||
outfile.write(str(self))
|
||||
outfile.close()
|
||||
|
||||
def export(self):
|
||||
outfile=open(self.fileName,'w')
|
||||
header=[self.acadver]+[self._point(attr,getattr(self,attr))+'\n' for attr in _HEADER_POINTS]
|
||||
self._write_section(outfile,'header',header)
|
||||
tables=[self._table('vport',[str(x) for x in self.vports]),
|
||||
self._table('ltype',[str(x) for x in self.linetypes]),
|
||||
self._table('layer',[str(x) for x in self.layers]),
|
||||
self._table('style',[str(x) for x in self.styles]),
|
||||
self._table('view',[str(x) for x in self.views]),
|
||||
]
|
||||
self._write_section(outfile,'tables',tables)
|
||||
self._write_section(outfile,'blocks',self.blocks)
|
||||
self._write_section(outfile,'entities',self.entities)
|
||||
outfile.write(' 0\nEOF\n')
|
||||
outfile.close()
|
||||
|
||||
|
||||
#---extras
|
||||
@@ -836,11 +882,12 @@ class LineList(_Entity):
|
||||
self.closed=closed
|
||||
self.points=copy.copy(points)
|
||||
def __str__(self):
|
||||
if self.closed:points=self.points+[self.points[0]]
|
||||
if self.closed:
|
||||
points=self.points+[self.points[0]]
|
||||
else: points=self.points
|
||||
result=''
|
||||
for i in range(len(points)-1):
|
||||
result+= Line(points=[points[i],points[i+1]],parent=self)
|
||||
result+= Line(points=[points[i][0],points[i+1][0]],parent=self)
|
||||
return result[1:]
|
||||
|
||||
#-----------------------------------------------------
|
||||
|
297
release/scripts/bvh_export.py
Normal file
297
release/scripts/bvh_export.py
Normal file
@@ -0,0 +1,297 @@
|
||||
#!BPY
|
||||
|
||||
"""
|
||||
Name: 'Motion Capture (.bvh)...'
|
||||
Blender: 249.2
|
||||
Group: 'Export'
|
||||
Tooltip: 'Active Armature to BVH'
|
||||
"""
|
||||
|
||||
|
||||
__author__ = "Campbell Barton, Andrea Rugliancich"
|
||||
__url__ = ("blender.org", "blenderartists.org")
|
||||
__version__ = "10/12/30"
|
||||
__bpydoc__ = """\
|
||||
This script exports Blender armature motion data to BHV motion capture format
|
||||
"""
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# BVH Export by Campbell Barton (AKA Ideasman), Andrea Rugliancich
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
import Blender
|
||||
from Blender import Scene, Mathutils, Window, sys
|
||||
TranslationMatrix = Mathutils.TranslationMatrix
|
||||
Matrix = Blender.Mathutils.Matrix
|
||||
Vector = Blender.Mathutils.Vector
|
||||
|
||||
import BPyMessages
|
||||
|
||||
|
||||
def bvh_export(filepath, ob, pref_startframe, pref_endframe, pref_scale=1.0):
|
||||
|
||||
Window.EditMode(0)
|
||||
Blender.Window.WaitCursor(1)
|
||||
|
||||
file = open(filepath, 'w')
|
||||
|
||||
# bvh_nodes = {}
|
||||
arm_data = ob.data
|
||||
bones = arm_data.bones.values()
|
||||
|
||||
# Build a dictionary of bone children.
|
||||
# None is for parentless bones
|
||||
bone_children = {None: []}
|
||||
|
||||
# initialize with blank lists
|
||||
for bone in bones:
|
||||
bone_children[bone.name] = []
|
||||
|
||||
for bone in bones:
|
||||
parent = bone.parent
|
||||
bone_name = bone.name
|
||||
if parent:
|
||||
bone_children[parent.name].append(bone_name)
|
||||
else: # root node
|
||||
bone_children[None].append(bone_name)
|
||||
|
||||
# sort the children
|
||||
for children_list in bone_children.itervalues():
|
||||
children_list.sort()
|
||||
|
||||
# build a (name:bone) mapping dict
|
||||
bone_dict = {}
|
||||
for bone in bones:
|
||||
bone_dict[bone.name] = bone
|
||||
|
||||
# bone name list in the order that the bones are written
|
||||
bones_serialized_names = []
|
||||
|
||||
bone_locs = {}
|
||||
|
||||
file.write('HIERARCHY\n')
|
||||
|
||||
def write_bones_recursive(bone_name, indent):
|
||||
my_bone_children = bone_children[bone_name]
|
||||
|
||||
indent_str = '\t' * indent # cache?
|
||||
|
||||
bone = bone_dict[bone_name]
|
||||
loc = bone.head['ARMATURESPACE']
|
||||
bone_locs[bone_name] = loc
|
||||
|
||||
# make relative if we can
|
||||
if bone.parent:
|
||||
loc = loc - bone_locs[bone.parent.name]
|
||||
|
||||
if indent:
|
||||
file.write('%sJOINT %s\n' % (indent_str, bone_name))
|
||||
else:
|
||||
file.write('%sROOT %s\n' % (indent_str, bone_name))
|
||||
|
||||
file.write('%s{\n' % indent_str)
|
||||
file.write('%s\tOFFSET %.6f %.6f %.6f\n' % (indent_str, loc.x * pref_scale, loc.y * pref_scale, loc.z * pref_scale))
|
||||
file.write('%s\tCHANNELS 6 Xposition Yposition Zposition Xrotation Yrotation Zrotation\n' % indent_str)
|
||||
|
||||
|
||||
if my_bone_children:
|
||||
|
||||
# store the location for the children
|
||||
# to het their relative offset
|
||||
|
||||
# Write children
|
||||
for child_bone in my_bone_children:
|
||||
bones_serialized_names.append(child_bone)
|
||||
write_bones_recursive(child_bone, indent + 1)
|
||||
|
||||
else:
|
||||
# Write the bone end.
|
||||
file.write('%s\tEnd Site\n' % indent_str)
|
||||
file.write('%s\t{\n' % indent_str)
|
||||
loc = bone.tail['ARMATURESPACE'] - bone_locs[bone_name]
|
||||
file.write('%s\t\tOFFSET %.6f %.6f %.6f\n' % (indent_str, loc.x * pref_scale, loc.y * pref_scale, loc.z * pref_scale))
|
||||
file.write('%s\t}\n' % indent_str)
|
||||
|
||||
file.write('%s}\n' % indent_str)
|
||||
|
||||
|
||||
|
||||
if len(bone_children[None])==1:
|
||||
key = bone_children[None][0]
|
||||
bones_serialized_names.append(key)
|
||||
indent = 0
|
||||
|
||||
write_bones_recursive(key, indent)
|
||||
|
||||
else:
|
||||
# Write a dummy parent node
|
||||
file.write('ROOT %s\n' % key)
|
||||
file.write('{\n')
|
||||
file.write('\tOFFSET 0.0 0.0 0.0\n')
|
||||
file.write('\tCHANNELS 0\n') # Xposition Yposition Zposition Xrotation Yrotation Zrotation
|
||||
key = None
|
||||
indent = 1
|
||||
|
||||
write_bones_recursive(key, indent)
|
||||
|
||||
file.write('}\n')
|
||||
|
||||
|
||||
# redefine bones as sorted by bones_serialized_names
|
||||
# se we can write motion
|
||||
|
||||
pose_dict = ob.getPose().bones
|
||||
#pose_bones = [(pose_dict[bone_name], bone_dict[bone_name].matrix['ARMATURESPACE'].copy().invert()) for bone_name in bones_serialized_names]
|
||||
|
||||
class decorated_bone(object):
|
||||
__slots__ = (\
|
||||
'name',# bone name, used as key in many places
|
||||
'parent',# decorated bone parent, set in a later loop
|
||||
'rest_bone',# blender armature bone
|
||||
'pose_bone',# blender pose bone
|
||||
'pose_mat',# blender pose matrix
|
||||
'rest_arm_mat',# blender rest matrix (armature space)
|
||||
'rest_local_mat',# blender rest batrix (local space)
|
||||
'pose_imat',# pose_mat inverted
|
||||
'rest_arm_imat',# rest_arm_mat inverted
|
||||
'rest_local_imat') # rest_local_mat inverted
|
||||
|
||||
def __init__(self, bone_name):
|
||||
self.name = bone_name
|
||||
self.rest_bone = bone_dict[bone_name]
|
||||
self.pose_bone = pose_dict[bone_name]
|
||||
|
||||
|
||||
self.pose_mat = self.pose_bone.poseMatrix
|
||||
|
||||
mat = self.rest_bone.matrix
|
||||
self.rest_arm_mat = mat['ARMATURESPACE'].copy()
|
||||
self.rest_local_mat = mat['BONESPACE'].copy().resize4x4()
|
||||
|
||||
# inverted mats
|
||||
self.pose_imat = self.pose_mat.copy().invert()
|
||||
self.rest_arm_imat = self.rest_arm_mat.copy().invert()
|
||||
self.rest_local_imat = self.rest_local_mat.copy().invert()
|
||||
|
||||
self.parent = None
|
||||
|
||||
def update_posedata(self):
|
||||
self.pose_mat = self.pose_bone.poseMatrix
|
||||
self.pose_imat = self.pose_mat.copy().invert()
|
||||
|
||||
def __repr__(self):
|
||||
if self.parent:
|
||||
return '["%s" child on "%s"]\n' % (self.name, self.parent.name)
|
||||
else:
|
||||
return '["%s" root bone]\n' % (self.name)
|
||||
|
||||
|
||||
bones_decorated = [decorated_bone(bone_name) for bone_name in bones_serialized_names]
|
||||
|
||||
# Assign parents
|
||||
bones_decorated_dict = {}
|
||||
for dbone in bones_decorated:
|
||||
bones_decorated_dict[dbone.name] = dbone
|
||||
|
||||
for dbone in bones_decorated:
|
||||
parent = dbone.rest_bone.parent
|
||||
if parent:
|
||||
dbone.parent = bones_decorated_dict[parent.name]
|
||||
del bones_decorated_dict
|
||||
# finish assigning parents
|
||||
|
||||
file.write('MOTION\n')
|
||||
file.write('Frames: %d\n' % (pref_endframe - pref_startframe + 1))
|
||||
file.write('Frame Time: %.6f\n' % 0.03)
|
||||
|
||||
triple = '%.6f %.6f %.6f '
|
||||
for frame in xrange(pref_startframe, pref_endframe + 1):
|
||||
Blender.Set('curframe', frame)
|
||||
for dbone in bones_decorated:
|
||||
dbone.update_posedata()
|
||||
for dbone in bones_decorated:
|
||||
if dbone.parent:
|
||||
trans = TranslationMatrix(dbone.rest_bone.head['ARMATURESPACE'])
|
||||
itrans = TranslationMatrix(-dbone.rest_bone.head['ARMATURESPACE'])
|
||||
mat2 = dbone.rest_arm_imat * dbone.pose_mat * dbone.parent.pose_imat *dbone.parent.rest_arm_mat #FASTER
|
||||
mat2 = trans * mat2 * itrans
|
||||
myloc = mat2.translationPart() + (dbone.rest_bone.head['ARMATURESPACE'] - dbone.parent.rest_bone.head['ARMATURESPACE'])
|
||||
rot = mat2.copy().transpose().toEuler()
|
||||
else:
|
||||
trans = TranslationMatrix(dbone.rest_bone.head['ARMATURESPACE'])
|
||||
itrans = TranslationMatrix(-dbone.rest_bone.head['ARMATURESPACE'])
|
||||
mat2 = dbone.rest_arm_imat * dbone.pose_mat
|
||||
mat2 = trans * mat2 * itrans
|
||||
myloc = mat2.translationPart() + dbone.rest_bone.head['ARMATURESPACE']
|
||||
rot = mat2.copy().transpose().toEuler()
|
||||
|
||||
file.write(triple % (myloc[0] * pref_scale, myloc[1] * pref_scale, myloc[2] * pref_scale))
|
||||
file.write(triple % (-rot[0], -rot[1], -rot[2])) #NEGATED
|
||||
|
||||
file.write('\n')
|
||||
|
||||
numframes = pref_endframe - pref_startframe + 1
|
||||
file.close()
|
||||
|
||||
print'BVH Exported: %s frames:%d\n' % (filepath, numframes)
|
||||
Blender.Window.WaitCursor(0)
|
||||
|
||||
|
||||
def bvh_export_ui(filepath):
|
||||
# Dont overwrite
|
||||
if not BPyMessages.Warning_SaveOver(filepath):
|
||||
return
|
||||
|
||||
scn = Scene.GetCurrent()
|
||||
ob_act = scn.objects.active
|
||||
if not ob_act or ob_act.type != 'Armature':
|
||||
BPyMessages.Error_NoArmatureActive()
|
||||
|
||||
arm_ob = scn.objects.active
|
||||
|
||||
if not arm_ob or arm_ob.type != 'Armature':
|
||||
Blender.Draw.PupMenu('No Armature object selected.')
|
||||
return
|
||||
|
||||
ctx = scn.getRenderingContext()
|
||||
orig_frame = Blender.Get('curframe')
|
||||
pref_startframe = Blender.Draw.Create(int(ctx.startFrame()))
|
||||
pref_endframe = Blender.Draw.Create(int(ctx.endFrame()))
|
||||
|
||||
block = [\
|
||||
("Start Frame: ", pref_startframe, 1, 30000, "Start Bake from what frame?: Default 1"),\
|
||||
("End Frame: ", pref_endframe, 1, 30000, "End Bake on what Frame?"),\
|
||||
]
|
||||
|
||||
if not Blender.Draw.PupBlock("Export MDD", block):
|
||||
return
|
||||
|
||||
pref_startframe, pref_endframe = \
|
||||
min(pref_startframe.val, pref_endframe.val),\
|
||||
max(pref_startframe.val, pref_endframe.val)
|
||||
|
||||
bvh_export(filepath, ob_act, pref_startframe, pref_endframe)
|
||||
Blender.Set('curframe', orig_frame)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Blender.Window.FileSelector(bvh_export_ui, 'EXPORT BVH', sys.makename(ext='.bvh'))
|
@@ -2,14 +2,14 @@
|
||||
|
||||
"""
|
||||
Name: 'Motion Capture (.bvh)...'
|
||||
Blender: 242
|
||||
Blender: 249
|
||||
Group: 'Import'
|
||||
Tip: 'Import a (.bvh) motion capture file'
|
||||
"""
|
||||
|
||||
__author__ = "Campbell Barton"
|
||||
__author__ = "Campbell Barton / Martin Knauf(BugFix)"
|
||||
__url__ = ("blender.org", "blenderartists.org")
|
||||
__version__ = "1.90 06/08/01"
|
||||
__version__ = "1.91 11/27/09"
|
||||
|
||||
__bpydoc__ = """\
|
||||
This script imports BVH motion capture data to Blender.
|
||||
@@ -206,7 +206,7 @@ def read_bvh(file_path, GLOBAL_SCALE=1.0):
|
||||
rest_tail = Vector( GLOBAL_SCALE*float(file_lines[lineIdx][1]), GLOBAL_SCALE*float(file_lines[lineIdx][2]), GLOBAL_SCALE*float(file_lines[lineIdx][3]) )
|
||||
|
||||
bvh_nodes_serial[-1].rest_tail_world= bvh_nodes_serial[-1].rest_head_world + rest_tail
|
||||
bvh_nodes_serial[-1].rest_tail_local= rest_tail
|
||||
bvh_nodes_serial[-1].rest_tail_local= bvh_nodes_serial[-1].rest_head_local + rest_tail
|
||||
|
||||
|
||||
# Just so we can remove the Parents in a uniform way- End end never has kids
|
||||
@@ -283,7 +283,7 @@ def read_bvh(file_path, GLOBAL_SCALE=1.0):
|
||||
bvh_node.rest_tail_local = Vector(bvh_node.rest_head_local)
|
||||
elif len(bvh_node.children)==1:
|
||||
bvh_node.rest_tail_world= Vector(bvh_node.children[0].rest_head_world)
|
||||
bvh_node.rest_tail_local= Vector(bvh_node.children[0].rest_head_local)
|
||||
bvh_node.rest_tail_local= bvh_node.rest_head_local + bvh_node.children[0].rest_head_local
|
||||
else:
|
||||
# allow this, see above
|
||||
#if not bvh_node.children:
|
||||
@@ -698,7 +698,7 @@ def load_bvh_ui(file, PREF_UI= True):
|
||||
|
||||
Draw= Blender.Draw
|
||||
|
||||
IMPORT_SCALE = Draw.Create(0.1)
|
||||
IMPORT_SCALE = Draw.Create(1.0)
|
||||
IMPORT_START_FRAME = Draw.Create(1)
|
||||
IMPORT_AS_ARMATURE = Draw.Create(1)
|
||||
IMPORT_AS_EMPTIES = Draw.Create(0)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
Tooltip: 'Export geometry to DXF/DWG-r12 (Drawing eXchange Format).'
|
||||
"""
|
||||
|
||||
__version__ = "1.35 - 2009.06.18"
|
||||
__version__ = "1.37 - 2010.06.23"
|
||||
__author__ = "Remigiusz Fiedler (AKA migius)"
|
||||
__license__ = "GPL"
|
||||
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
|
||||
@@ -34,7 +34,7 @@ TODO:
|
||||
- export dupligroups and dupliverts as blocks (as option)
|
||||
- optimize POLYFACE routine: remove double-vertices
|
||||
- fix support for X,Y-rotated curves(to POLYLINEs): fix blender negative-matrix.invert()
|
||||
- support hierarchies: groups, instances, parented structures
|
||||
- support hierarchies: groups, instances(done), parented structures
|
||||
- support n/f-gons as POLYFACEs with invisible edges
|
||||
- mapping materials to DXF-styles
|
||||
- ProgressBar
|
||||
@@ -46,6 +46,11 @@ TODO:
|
||||
- wip: fix support Include-Duplis, cause not conform with INSERT-method
|
||||
|
||||
History
|
||||
v1.37 - 2010.06.23 by migius
|
||||
- APPLY-MODIFIER: added exception for modifier-free instances to export them as BLOCK/INSERTs
|
||||
v1.36 - 2010.06.20 by migius
|
||||
- added export Nurbs-Curves (3,4,5th-degree) into POLYLINE-NURBS(quad,cubic)
|
||||
caution: no Bezier-Curves support in autoCAD nor in DXF-specification
|
||||
v1.35 - 2009.06.18 by migius
|
||||
- export multiple-instances of Curve-Objects as BLOCK/INSERTs
|
||||
- added export Cameras (ortho and persp) to VPORTs, incl. clipping
|
||||
@@ -509,17 +514,19 @@ def isLeftHand(matrix):
|
||||
|
||||
|
||||
#-----------------------------------------------------
|
||||
def exportMesh(ob, mx, mx_n, me=None, **common):
|
||||
def exportMesh(ob, mx, mx_n, **common):
|
||||
"""converts Mesh-Object to desired projection and representation(DXF-Entity type)
|
||||
"""
|
||||
global BLOCKREGISTRY
|
||||
entities = []
|
||||
block = None
|
||||
#print 'deb:exportMesh() given common=', common #---------
|
||||
if me==None:
|
||||
me = ob.getData(mesh=1)
|
||||
if ob.modifiers and APPLY_MODIFIERS:
|
||||
me = Mesh.New()
|
||||
me.getFromObject(ob) #this gets mesh with applied modifiers
|
||||
else:
|
||||
me.getFromObject(ob)
|
||||
me = ob.getData(mesh=1) # is a Mesh if mesh>0 (otherwise it is a NMesh)
|
||||
#print 'deb:exportMesh() mesh=', me #---------
|
||||
# idea: me.transform(mx); get verts data; me.transform(mx_inv)= back to the origin state
|
||||
# the .transform-method is fast, but bad, cause invasive:
|
||||
# it manipulates original geometry and by retransformation lefts back rounding-errors
|
||||
@@ -532,7 +539,7 @@ def exportMesh(ob, mx, mx_n, me=None, **common):
|
||||
#print 'deb:exportMesh() me.name=', me.name #---------
|
||||
#print 'deb:exportMesh() me.users=', me.users #---------
|
||||
# check if there are more instances of this mesh (if used by other objects), then write to BLOCK/INSERT
|
||||
if GUI_A['instances_on'].val and me.users>1 and not PROJECTION:
|
||||
if INSTANCES and me.users>1 and not PROJECTION and not (ob.modifiers and APPLY_MODIFIERS):
|
||||
if me.name in BLOCKREGISTRY.keys():
|
||||
insert_name = BLOCKREGISTRY[me.name]
|
||||
# write INSERT to entities
|
||||
@@ -626,7 +633,10 @@ def writeMeshEntities(allpoints, edges, faces, **common):
|
||||
i+=1
|
||||
allpoints = newverts
|
||||
faces = [[map[v]+1 for v in f] for f in faces]
|
||||
dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag=64, **common)
|
||||
flag70 = 64
|
||||
flag75 = 0
|
||||
#dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag=[64,0,0], **common)
|
||||
dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag70=flag70, flag75=flag70, width=0.0, **common)
|
||||
#print '\n deb: dxfPOLYFACE=',dxfPOLYFACE #-------------
|
||||
entities.append(dxfPOLYFACE)
|
||||
elif '3DFACEs'==c:
|
||||
@@ -672,9 +682,9 @@ def curve_drawBlender(vertList, org_point=[0.0,0.0,0.0], closed=0, name="dxfCurv
|
||||
ob = Object.New("Curve",name)
|
||||
cu = Curve.New(name)
|
||||
#print 'deb: vertList=\n', vertList #---------
|
||||
curve = cu.appendNurb(BezTriple.New(vertList[0]))
|
||||
curve = cu.appendNurb(BezTriple.New(vertList[0][0]))
|
||||
for p in vertList[1:]:
|
||||
curve.append(BezTriple.New(p))
|
||||
curve.append(BezTriple.New(p[0]))
|
||||
for point in curve:
|
||||
#point.handleTypes = [VECT, VECT]
|
||||
point.handleTypes = [FREE, FREE]
|
||||
@@ -1002,7 +1012,7 @@ def exportCurve(ob, mx, mw, **common):
|
||||
curve = ob.getData()
|
||||
#print 'deb: curve=', dir(curve) #---------
|
||||
# TODO: should be: if curve.users>1 and not (PERSPECTIVE or (PROJECTION and HIDDEN_MODE):
|
||||
if GUI_A['instances_on'].val and curve.users>1 and not PROJECTION:
|
||||
if INSTANCES and curve.users>1 and not PROJECTION:
|
||||
if curve.name in BLOCKREGISTRY.keys():
|
||||
insert_name = BLOCKREGISTRY[curve.name]
|
||||
# write INSERT to entities
|
||||
@@ -1088,27 +1098,81 @@ def writeCurveEntities(curve, mx,
|
||||
"""help routine for exportCurve()
|
||||
"""
|
||||
entities = []
|
||||
|
||||
width1,width2 = None, None
|
||||
if 1:
|
||||
for cur in curve:
|
||||
#print 'deb: START cur=', cur #--------------
|
||||
#print 'deb: dir(curve):',dir(cur) #---------
|
||||
#print 'deb: curve.type:',cur.type #---------
|
||||
points = []
|
||||
if cur.isNurb():
|
||||
flags = []
|
||||
pflag70, pflag75 = 0,0
|
||||
|
||||
if cur.type==4: # is NURBS
|
||||
#if cur.isNurb():
|
||||
#print 'deb:isNurb --------------' #---------
|
||||
pflag70 = 4
|
||||
orderU = cur.orderU
|
||||
# curve type:
|
||||
# 0: curvNoFitted
|
||||
# 5: curvQuadraticBspline
|
||||
# 6: curvCubicBspline
|
||||
# 8: curvBezier
|
||||
if orderU<=4: pflag75 = 5
|
||||
elif orderU>=5: pflag75 = 6
|
||||
|
||||
vflag70 = 16
|
||||
i = -2
|
||||
for point in cur:
|
||||
#print 'deb:isNurb point=', point #---------
|
||||
i+=1
|
||||
if i==orderU-1: i = 0
|
||||
if i:
|
||||
flags.append([16, [width1,width2]])
|
||||
else:
|
||||
flags.append([8, [width1,width2]])
|
||||
vec = point[0:3]
|
||||
#print 'deb: vec=', vec #---------
|
||||
pkt = Mathutils.Vector(vec)
|
||||
#print 'deb: pkt=', pkt #---------
|
||||
points.append(pkt)
|
||||
else:
|
||||
if not cur.isCyclic():
|
||||
points = points[1:-1]
|
||||
flags = flags[1:-1]
|
||||
elif cur.type==1: # is Bezier
|
||||
#print 'deb:isBezier --------------' #---------
|
||||
pflag75 = 8
|
||||
vflag70 = 1
|
||||
for point in cur:
|
||||
#print 'deb:isBezier point=', point #---------
|
||||
#print 'deb:isBezier point=', point.getTriple() #---------
|
||||
vec = point.getTriple()[1]
|
||||
ptan1,pfit,ptan2 = point.getTriple()
|
||||
#print 'deb: point=', pt #---------
|
||||
ptan1 = Mathutils.Vector(ptan1)
|
||||
pfit = Mathutils.Vector(pfit)
|
||||
ptan2 = Mathutils.Vector(ptan2)
|
||||
#print 'deb: pkt=', pkt #---------
|
||||
points.append(ptan1)
|
||||
flags.append([2, [width1,width2]])
|
||||
points.append(pfit)
|
||||
flags.append([1, [width1,width2]])
|
||||
points.append(ptan2)
|
||||
flags.append([2, [width1,width2]])
|
||||
if not cur.isCyclic():
|
||||
points = points[1:-1]
|
||||
flags = flags[1:-1]
|
||||
elif cur.type==0: # is Polygon
|
||||
#print 'deb:isPolygon --------------' #---------
|
||||
#pflag70 = 4
|
||||
pflag75 = 0
|
||||
for point in cur:
|
||||
#print 'deb:isPoly point=', point #---------
|
||||
vec = point[0:3]
|
||||
#print 'deb: vec=', vec #---------
|
||||
pkt = Mathutils.Vector(vec)
|
||||
#print 'deb: pkt=', pkt #---------
|
||||
points.append(pkt)
|
||||
flags.append([None, [width1,width2]])
|
||||
|
||||
#print 'deb: points', points #--------------
|
||||
if len(points)>1:
|
||||
@@ -1131,7 +1195,12 @@ def writeCurveEntities(curve, mx,
|
||||
if cur.isCyclic(): closed = 1
|
||||
else: closed = 0
|
||||
points = toGlobalOrigin(points)
|
||||
|
||||
points_temp = []
|
||||
for p,f in zip(points,flags):
|
||||
points_temp.append([p,f[0],f[1]])
|
||||
points = points_temp
|
||||
#print 'deb: points', points #--------------
|
||||
|
||||
if DEBUG: curve_drawBlender(points,OCS_origin,closed) #deb: draw to scene
|
||||
|
||||
common['extrusion']= Extrusion
|
||||
@@ -1140,6 +1209,7 @@ def writeCurveEntities(curve, mx,
|
||||
common['thickness']= Thickness
|
||||
#print 'deb: common=', common #------------------
|
||||
|
||||
flag70, flag75 = pflag70+closed, pflag75
|
||||
if 0: #DEBUG
|
||||
p=AXaxis[:3]
|
||||
entities.append(DXF.Line([[0,0,0], p],**common))
|
||||
@@ -1149,14 +1219,14 @@ def writeCurveEntities(curve, mx,
|
||||
p=OCS_origin[:3]
|
||||
entities.append(DXF.Line([[0,0,0], p],**common))
|
||||
#OCS_origin=[0,0,0] #only debug----------------
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
|
||||
entities.append(dxfPLINE)
|
||||
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
|
||||
entities.append(dxfPLINE)
|
||||
if Thickness:
|
||||
common['thickness']= -Thickness
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin,closed,**common)
|
||||
dxfPLINE = DXF.PolyLine(points,OCS_origin, flag70=flag70, flag75=flag70, width=0.0,**common)
|
||||
entities.append(dxfPLINE)
|
||||
|
||||
elif c=="LINEs": # export Curve as multiple LINEs
|
||||
@@ -1481,8 +1551,9 @@ def do_export(export_list, filepath):
|
||||
|
||||
#print 'deb: ViewMatrix=\n', mw #------------------
|
||||
|
||||
if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp')
|
||||
else: tmp_me = None
|
||||
#todo: fixme: seems to be the reason for missing BLOCK-export
|
||||
#if APPLY_MODIFIERS: tmp_me = Mesh.New('tmp')
|
||||
#else: tmp_me = None
|
||||
|
||||
if GUI_A['paper_space_on'].val==1: espace=1
|
||||
else: espace=None
|
||||
@@ -1519,7 +1590,7 @@ def do_export(export_list, filepath):
|
||||
d.layers.append(DXF.Layer(color=tempcolor, name=elayer))
|
||||
|
||||
if (ob.type == 'Mesh') and GUI_B['bmesh'].val:
|
||||
entities, block = exportMesh(ob, mx, mx_n, tmp_me,\
|
||||
entities, block = exportMesh(ob, mx, mx_n, \
|
||||
paperspace=espace, color=ecolor, layer=elayer, lineType=eltype)
|
||||
elif (ob.type == 'Curve') and GUI_B['bcurve'].val:
|
||||
entities, block = exportCurve(ob, mx, mw, \
|
||||
@@ -1561,8 +1632,9 @@ def do_export(export_list, filepath):
|
||||
dxfLINE = DXF.Line(linepoints,paperspace=espace,color=LAYERCOLOR_DEF)
|
||||
entities.append(dxfLINE)
|
||||
else:
|
||||
dxfPLINE = DXF.PolyLine(points,points[0],closed,\
|
||||
paperspace=espace, color=LAYERCOLOR_DEF)
|
||||
fag70, flag75 = closed, 0
|
||||
dxfPOLYFACE = DXF.PolyLine([allpoints, faces], flag70=flag70, flag75=flag70, width=0.0, paperspace=espace, color=LAYERCOLOR_DEF)
|
||||
#dxfPLINE = DXF.PolyLine(points,points[0],[closed,0,0], paperspace=espace, color=LAYERCOLOR_DEF)
|
||||
d.append(dxfPLINE)
|
||||
|
||||
|
||||
@@ -2236,11 +2308,11 @@ def inputOriginVector():
|
||||
def update_globals(): #-----------------------------------------------------------------
|
||||
""" update globals if GUI_A changed
|
||||
"""
|
||||
global ONLYSELECTED,ONLYVISIBLE, DEBUG,\
|
||||
global ONLYSELECTED, ONLYVISIBLE, DEBUG,\
|
||||
PROJECTION, HIDDEN_LINES, CAMERA, \
|
||||
G_SCALE, G_ORIGIN,\
|
||||
PREFIX, LAYERNAME_DEF, LAYERCOLOR_DEF, LAYERLTYPE_DEF,\
|
||||
APPLY_MODIFIERS, INCLUDE_DUPLIS,\
|
||||
INSTANCES, APPLY_MODIFIERS, INCLUDE_DUPLIS,\
|
||||
OUTPUT_DWG
|
||||
#global POLYLINES
|
||||
|
||||
@@ -2272,6 +2344,7 @@ def update_globals(): #--------------------------------------------------------
|
||||
LAYERCOLOR_DEF = GUI_A['layercolor_def'].val
|
||||
LAYERLTYPE_DEF = layerltype_def_list[GUI_A['layerltype_def'].val]
|
||||
|
||||
INSTANCES = GUI_A['instances_on'].val
|
||||
APPLY_MODIFIERS = GUI_A['apply_modifiers_on'].val
|
||||
INCLUDE_DUPLIS = GUI_A['include_duplis_on'].val
|
||||
OUTPUT_DWG = GUI_A['outputDWG_on'].val
|
||||
@@ -2595,7 +2668,7 @@ def draw_UI(): #---------------------------------------------------------------
|
||||
|
||||
y -= 30
|
||||
b0, b0_ = but0c, but_0c + butt_margin +but_1c
|
||||
GUI_A['only_selected_on'] = Draw.Toggle('Export Selection', EVENT_NONE, b0, y, b0_, 20, GUI_A['only_selected_on'].val, "Export only selected geometry on/off")
|
||||
GUI_A['only_selected_on'] = Draw.Toggle('Selected only', EVENT_NONE, b0, y, b0_, 20, GUI_A['only_selected_on'].val, "Export only selected geometry on/off")
|
||||
b0, b0_ = but2c, but_2c + butt_margin + but_3c
|
||||
Draw.BeginAlign()
|
||||
GUI_A['projection_on'] = Draw.Toggle('2d Projection', EVENT_REDRAW, b0, y, b0_, 20, GUI_A['projection_on'].val, "Export a 2d Projection according 3d-View or Camera-View on/off")
|
||||
@@ -3016,10 +3089,10 @@ if __name__=='__main__':
|
||||
if DXF:
|
||||
print '\n\n\n'
|
||||
print 'DXF-Exporter v%s *** start ***' %(__version__) #---------------------
|
||||
print 'with Library %s' %(DXF.__version__) #---------------------
|
||||
print '+DXF-Library %s' %(DXF.__version__) #---------------------
|
||||
if not DXF.copy:
|
||||
print "DXF-Exporter: dxfLibrary.py script requires a full Python install"
|
||||
Draw.PupMenu('Error%t|The dxfLibrary.py script requires a full Python install')
|
||||
print "DXF-Exporter: dxfLibrary.py script requires a full Python installation"
|
||||
Draw.PupMenu('Error%t|The dxfLibrary.py script requires a full Python installation')
|
||||
else:
|
||||
#Window.FileSelector(dxf_export_ui, 'EXPORT DXF', Blender.sys.makename(ext='.dxf'))
|
||||
# recall last used DXF-file and INI-file names
|
||||
|
@@ -7,10 +7,10 @@ Group: 'Import'
|
||||
Tooltip: 'Import for DWG/DXF geometry data.'
|
||||
"""
|
||||
__author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
|
||||
__version__ = '1.12 - 2009.06.16 by migius'
|
||||
__version__ = '1.12 - 2011.05.07 by migius'
|
||||
__url__ = ["http://blenderartists.org/forum/showthread.php?t=84319",
|
||||
"http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"]
|
||||
__email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"]
|
||||
__email__ = ["migius(at)gmx.net","Kitsune_e(at)yahoo.com"]
|
||||
__bpydoc__ = """\
|
||||
This script imports objects from DWG/DXF (2d/3d) into Blender.
|
||||
|
||||
@@ -19,7 +19,7 @@ It supports DWG format too, with help of an external converter.
|
||||
Supported DXF format versions: from (r2.5) r12 up to r2008.
|
||||
Enhanced features are:
|
||||
- configurable object filtering and geometry manipulation,
|
||||
- configurable material pre-processing,
|
||||
- configurable material pre-processing (WIP),
|
||||
- DXF-code analyze and reporting.
|
||||
|
||||
Supported DXF r12 objects:
|
||||
@@ -111,10 +111,23 @@ History:
|
||||
-- support DXF-definitions of autoshade: scene, lights and cameras
|
||||
-- support ortho mode for VIEWs and VPORTs as cameras
|
||||
|
||||
v1.12 - 2011.05.07 by migius
|
||||
h1 fixed for SPLINE: points coordinates are always in WCS
|
||||
h1 code beautifying
|
||||
v1.12 - 2010.04.29 by migius
|
||||
g1 preparation for non-UI-mode: import_dxf.main('dxf_file_name.dxf')
|
||||
v1.12 - 2010.03.04 by migius
|
||||
f1 fix POLYFACE non-standard ordered double-vertices
|
||||
v1.12 - 2009.11.28 by migius
|
||||
e1 fix (unused)-BLOCKs-detection for non-DXFr12-conform SECTION:BLOCKS
|
||||
v1.12 - 2009.07.02 by migius
|
||||
d9 wip-fix global relocation: culprit is blenders 1mio-Limit
|
||||
v1.12 - 2009.06.21 by migius
|
||||
d8 fix normals for TRACE (in opposite to SOLID)
|
||||
v1.12 - 2009.06.16 by migius
|
||||
d7 fix for ignored BLOCKs (e.g. *X) which are members of other BLOCKs
|
||||
v1.12 - 2009.05.27 by migius
|
||||
d6 bugfix negative scaled INSERTs - isLeftHand(Matrix) check
|
||||
d6 bugfix wrong normals for negative scaled INSERTs - isLeftHand(Matrix) check
|
||||
v1.12 - 2009.05.26 by migius
|
||||
d5 changed to the new 2.49 method Vector.cross()
|
||||
d5 bugfix WORLDY(1,1,0) to (0,1,0)
|
||||
@@ -677,8 +690,8 @@ def get_extrusion(data): #-------------------------------------------------
|
||||
return vec
|
||||
|
||||
|
||||
#------------------------------------------
|
||||
def getSceneChild(name):
|
||||
|
||||
def getSceneChild(name): #------------------------------------------
|
||||
dudu = [i for i in SCENE.objects if i.name==name]
|
||||
# dudu = [i for i in SCENE.getChildren() if i.name==name]
|
||||
#print 'deb:getSceneChild %s -result: %s:' %(name,dudu) #-----------------
|
||||
@@ -692,7 +705,9 @@ class Solid: #-----------------------------------------------------------------
|
||||
def __init__(self, obj):
|
||||
"""Expects an entity object of type solid or trace as input.
|
||||
"""
|
||||
self.trace = False
|
||||
if obj.type == 'trace':
|
||||
self.trace = True
|
||||
obj.type = 'solid'
|
||||
if not obj.type == 'solid':
|
||||
raise TypeError, "Wrong type \'%s\' for solid/trace object!" %obj.type
|
||||
@@ -730,7 +745,10 @@ class Solid: #-----------------------------------------------------------------
|
||||
c[0] = getit(data, 12, None)
|
||||
c[1] = getit(data, 22, None)
|
||||
c[2] = getit(data, 32, 0)
|
||||
out = [a,b,c]
|
||||
if self.trace:
|
||||
out = [a,c,b]
|
||||
else:
|
||||
out = [a,b,c]
|
||||
|
||||
d[0] = getit(data, 13, None)
|
||||
if d[0] != None:
|
||||
@@ -1343,7 +1361,7 @@ class Polyline: #--------------------------------------------------------------
|
||||
firstpoint = nurbs_points[0]
|
||||
curve = pline.appendNurb(firstpoint)
|
||||
curve.setType(4) # set curve_type NURBS
|
||||
print 'deb: dir(curve):', dir(curve[-1]) #----------------
|
||||
#print 'deb: dir(curve):', dir(curve[-1]) #----------------
|
||||
for point in nurbs_points[1:]:
|
||||
curve.append(point)
|
||||
#TODO: what is the trick for bevel radius? curve[-1].radius = 1.0
|
||||
@@ -1488,7 +1506,8 @@ class Polyline: #--------------------------------------------------------------
|
||||
pline.setExt1(1.0) # curve-extrusion accepts only (0.0 - 2.0)
|
||||
ob.LocZ = thic + LocZ
|
||||
|
||||
transform(self.extrusion, 0, ob)
|
||||
if self.pltype!='spline':
|
||||
transform(self.extrusion, 0, ob)
|
||||
if thic != 0.0:
|
||||
ob.SizeZ *= abs(thic)
|
||||
|
||||
@@ -1985,7 +2004,7 @@ class Vertex(object): #--------------------------------------------------------
|
||||
v4 = getit(data, 74, None) # polyface:Face.vertex 4.
|
||||
self.face = [abs(v1)-1,abs(v2)-1,abs(v3)-1]
|
||||
if v4 != None:
|
||||
if abs(v4) != abs(v1):
|
||||
if not (abs(v4)-1) in self.face:
|
||||
self.face.append(abs(v4)-1)
|
||||
else: #--parameter for polyline2d
|
||||
self.swidth = getit(data, 40, None) # start width
|
||||
@@ -2044,29 +2063,29 @@ class Spline(Polyline): #------------------------------------------------------
|
||||
"""Class for objects representing dxf SPLINEs.
|
||||
"""
|
||||
"""Expects an entity object of type spline as input.
|
||||
100 - Subclass marker (AcDbSpline)
|
||||
210,220, 230 - Normal vector (omitted if the spline is nonplanar) X,Y,Z values of normal vector
|
||||
70 - Spline flag (bit coded):
|
||||
1 = Closed spline
|
||||
2 = Periodic spline
|
||||
4 = Rational spline
|
||||
8 = Planar
|
||||
16 = Linear (planar bit is also set)
|
||||
71 - Degree of the spline curve
|
||||
72 - Number of knots
|
||||
73 - Number of control points
|
||||
74 - Number of fit points (if any)
|
||||
42 - Knot tolerance (default = 0.0000001)
|
||||
43 - Control-point tolerance (default = 0.0000001)
|
||||
44 - Fit tolerance (default = 0.0000000001)
|
||||
12,22,32 - Start tangent--may be omitted (in WCS). X,Y,Z values of start tangent--may be omitted (in WCS).
|
||||
13,23, 33 - End tangent--may be omitted (in WCS). X,Y,Z values of end tangent--may be omitted (in WCS)
|
||||
40 - Knot value (one entry per knot)
|
||||
41 - Weight (if not 1); with multiple group pairs, are present if all are not 1
|
||||
10,20, 30 - Control points (in WCS) one entry per control point.
|
||||
DXF: X value; APP: 3D point, Y and Z values of control points (in WCS) (one entry per control point)
|
||||
11,21, 31 - Fit points (in WCS) one entry per fit point.
|
||||
X,Y,Z values of fit points (in WCS) (one entry per fit point)
|
||||
100 - Subclass marker (AcDbSpline)
|
||||
210,220, 230 - Normal vector (omitted if the spline is nonplanar) X,Y,Z values of normal vector
|
||||
70 - Spline flag (bit coded):
|
||||
1 = Closed spline
|
||||
2 = Periodic spline
|
||||
4 = Rational spline
|
||||
8 = Planar
|
||||
16 = Linear (planar bit is also set)
|
||||
71 - Degree of the spline curve
|
||||
72 - Number of knots
|
||||
73 - Number of control points
|
||||
74 - Number of fit points (if any)
|
||||
42 - Knot tolerance (default = 0.0000001)
|
||||
43 - Control-point tolerance (default = 0.0000001)
|
||||
44 - Fit tolerance (default = 0.0000000001)
|
||||
12,22,32 - Start tangent--may be omitted (in WCS). X,Y,Z values of start tangent--may be omitted (in WCS).
|
||||
13,23, 33 - End tangent--may be omitted (in WCS). X,Y,Z values of end tangent--may be omitted (in WCS)
|
||||
40 - Knot value (one entry per knot)
|
||||
41 - Weight (if not 1); with multiple group pairs, are present if all are not 1
|
||||
10,20, 30 - Control points (in WCS) one entry per control point.
|
||||
DXF: X value; APP: 3D point, Y and Z values of control points (in WCS) (one entry per control point)
|
||||
11,21, 31 - Fit points (in WCS) one entry per fit point.
|
||||
X,Y,Z values of fit points (in WCS) (one entry per fit point)
|
||||
"""
|
||||
def __init__(self, obj):
|
||||
#print 'deb:Spline.START:----------------' #------------------------
|
||||
@@ -3573,9 +3592,8 @@ class Face: #-----------------------------------------------------------------
|
||||
return ob
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
# type to object maping (sorted-dictionary for f_obiectify ONLY!, format={'key':Class} )
|
||||
type_map = {
|
||||
|
||||
type_map = { # type to object maping (sorted-dictionary for f_obiectify ONLY!, format={'key':Class} )
|
||||
'vport':Vport,
|
||||
'view':View,
|
||||
'layer':Layer,
|
||||
@@ -3597,10 +3615,7 @@ type_map = {
|
||||
'circle':Circle,
|
||||
'ellipse':Ellipse,
|
||||
'arc':Arc
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
def objectify(data): #-----------------------------------------------------------------
|
||||
"""Expects a section type object's data as input.
|
||||
|
||||
@@ -4079,7 +4094,7 @@ class Settings: #--------------------------------------------------------------
|
||||
def progress(self, done, text):
|
||||
"""Wrapper for Blender.Window.DrawProgressBar.
|
||||
"""
|
||||
if self.var['optimization'] <= self.PRO:
|
||||
if self.var['optimization'] <= self.PRO and Blender.mode!='background':
|
||||
progressbar = done * self.obj_number
|
||||
Window.DrawProgressBar(progressbar, text)
|
||||
#print 'deb:drawer done, progressbar: ', done, progressbar #-----------------------
|
||||
@@ -4147,7 +4162,7 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
#print dir(item)
|
||||
layersmap[item.name] = [item.color, item.frozen]
|
||||
#print 'deb:analyzeDXF: layersmap=' , layersmap #-------------
|
||||
layersmap_str = '#list of LAYERs: name, color, frozen_status ---------------------------\n'
|
||||
layersmap_str = '#list of LAYERs: name: color, frozen_status ---------------------------\n'
|
||||
key_list = layersmap.keys()
|
||||
key_list.sort()
|
||||
for key in key_list:
|
||||
@@ -4166,7 +4181,7 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
#print dir(item)
|
||||
viewsmap[item.name] = [item.length]
|
||||
#print 'deb:analyzeDXF: viewsmap=' , viewsmap #-------------
|
||||
viewsmap_str = '#list of VIEWs: name, focus_length ------------------------------------\n'
|
||||
viewsmap_str = '#list of VIEWs: name: focus_length ------------------------------------\n'
|
||||
key_list = viewsmap.keys()
|
||||
key_list.sort()
|
||||
for key in key_list:
|
||||
@@ -4185,7 +4200,7 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
#print dir(item)
|
||||
vportsmap[item.name] = [item.length]
|
||||
#print 'deb:analyzeDXF: vportsmap=' , vportsmap #-------------
|
||||
vportsmap_str = '#list of VPORTs: name, focus_length -----------------------------------\n'
|
||||
vportsmap_str = '#list of VPORTs: name: focus_length -----------------------------------\n'
|
||||
key_list = vportsmap.keys()
|
||||
key_list.sort()
|
||||
for key in key_list:
|
||||
@@ -4206,8 +4221,9 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
if 'blocks' in sections.keys():
|
||||
print "found section:blocks"
|
||||
blocksmap = {}
|
||||
for item in drawing.blocks.data:
|
||||
for item in drawing.blocks.data: #read all BLOCK_definitions
|
||||
#print 'deb:getBlocksmap item=' ,item #--------
|
||||
#print 'deb:getBlocksmap item.name=', item.name #--------
|
||||
#print 'deb:getBlocksmap item.entities=' ,item.entities #--------
|
||||
#print 'deb:getBlocksmap item.entities.data=' ,item.entities.data #--------
|
||||
if type(item) != list and item.type == 'block':
|
||||
@@ -4215,7 +4231,7 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
if item.xref: xref = True
|
||||
childList = []
|
||||
used = False
|
||||
for item2 in item.entities.data:
|
||||
for item2 in item.entities.data: #looking for subBLOCKs
|
||||
if type(item2) != list and item2.type == 'insert':
|
||||
#print 'deb:getBlocksmap dir(item2)=', dir(item2) #----------
|
||||
item2str = [item2.name, item2.layer, item2.color_index, item2.scale, item2.space]
|
||||
@@ -4224,30 +4240,31 @@ def analyzeDXF(dxfFile): #---------------------------------------
|
||||
except KeyError: print 'Cannot map "%s" - "%s" as Block!' %(item.name, item)
|
||||
#print 'deb:analyzeDXF: blocksmap=' , blocksmap #-------------
|
||||
|
||||
for item2 in drawing.entities.data:
|
||||
if type(item2) != list and item2.type == 'insert':
|
||||
if item2.name in blocksmap.keys():
|
||||
if not layersmap or (layersmap and not layersmap[item2.layer][1]): #if insert_layer is not frozen
|
||||
blocksmap[item2.name][0] = True # marked as world used BLOCK
|
||||
|
||||
key_list = blocksmap.keys()
|
||||
key_list.reverse()
|
||||
for key in key_list:
|
||||
if blocksmap[key][0]: #if used
|
||||
for child in blocksmap[key][1]:
|
||||
if not layersmap or (layersmap and not layersmap[child[1]][1]): #if insert_layer is not frozen
|
||||
blocksmap[child[0]][0] = True # marked as used BLOCK
|
||||
def r_block_used(blname,bllayer):
|
||||
#checks recursive if INSERT on frozen-layer
|
||||
if blname in key_list:
|
||||
if (not layersmap) or (layersmap and not layersmap[bllayer][1]): #if insert_layer is not frozen
|
||||
blocksmap[blname][0] = True # marked as world-level used BLOCK
|
||||
for child in blocksmap[blname][1]:
|
||||
sub_blname,sub_bllayer=child[0],child[1]
|
||||
r_block_used(sub_blname,sub_bllayer)
|
||||
|
||||
for item in drawing.entities.data:
|
||||
if type(item) != list and item.type == 'insert':
|
||||
blname,bllayer=item.name,item.layer
|
||||
r_block_used(blname,bllayer)
|
||||
|
||||
|
||||
#print 'deb:analyzeDXF: blocksmap=' , blocksmap #-------------
|
||||
blocksmap_str = '#list of BLOCKs: name:(unused)(xref) -[child_name, layer, color, scale, space]-------\n'
|
||||
key_list = blocksmap.keys()
|
||||
key_list.sort()
|
||||
#key_list.sort()
|
||||
for key in key_list:
|
||||
#for block_name, block_data in blocksmap.iteritems():
|
||||
block_name, block_data = key, blocksmap[key]
|
||||
block_str = '\'%s\': ' %(block_name) #-------------
|
||||
used = '(unused)'
|
||||
if block_data[0]: used = ''
|
||||
# else: used = '(unused)'
|
||||
xref = ''
|
||||
if block_data[2]: xref = '(xref)'
|
||||
blocksmap_str += block_str + used + xref +'\n'
|
||||
@@ -4311,7 +4328,7 @@ def main(dxfFile): #---------------#############################-----------
|
||||
#print 'deb:settings.var:\n', settings.var #-----------------------
|
||||
|
||||
if not settings:
|
||||
#Draw.PupMenu('DXF importer: EXIT!%t')
|
||||
#if UI_MODE: Draw.PupMenu('DXF importer: EXIT!%t')
|
||||
#print '\nDXF Import: terminated by user!'
|
||||
print '\nDXF Import: terminated, cause settings failure!'
|
||||
Window.WaitCursor(False)
|
||||
@@ -4329,21 +4346,16 @@ def main(dxfFile): #---------------#############################-----------
|
||||
Window.WaitCursor(False)
|
||||
elif dxfFile.lower().endswith('.dwg') and sys.exists(dxfFile):
|
||||
if not extCONV_OK:
|
||||
Draw.PupMenu(extCONV_TEXT)
|
||||
if UI_MODE: Draw.PupMenu(extCONV_TEXT)
|
||||
print extCONV_TEXT
|
||||
Window.WaitCursor(False)
|
||||
if editmode: Window.EditMode(1) # and put things back how we fond them
|
||||
return None
|
||||
else:
|
||||
Window.WaitCursor(True) # Let the user know we are thinking
|
||||
#todo: issue: in DConvertCon.exe the output filename is fixed to dwg_name.dxf
|
||||
|
||||
if 0: # works only for Windows
|
||||
dwgTemp = 'temp_01.dwg'
|
||||
dxfTemp = 'temp_01.dxf'
|
||||
os.system('copy %s %s' %(dxfFile,dwgTemp))
|
||||
else:
|
||||
dwgTemp = dxfFile
|
||||
dxfTemp = dxfFile[:-3]+'dxf'
|
||||
dwgTemp = dxfFile
|
||||
dxfTemp = dxfFile[:-3]+'dxf'
|
||||
#print 'temp. converting: %s\n to: %s' %(dxfFile, dxfTemp)
|
||||
#os.system('%s %s -acad11 -dxf' %(extCONV_PATH, dxfFile))
|
||||
os.system('%s %s -dxf' %(extCONV_PATH, dwgTemp))
|
||||
@@ -4511,36 +4523,35 @@ def getBlocksmap(drawing, layersmap, layFrozen_on=False): #--------------------
|
||||
"""Build a dictionary of blockname:block_data pairs
|
||||
"""
|
||||
usedblocks = {}
|
||||
for item in drawing.blocks.data:
|
||||
#print 'deb:getBlocksmap item=%s\n i.entities=%s\n i.data=%s' %(item,item.entities,item.entities.data)
|
||||
if type(item) != list and item.type == 'block':
|
||||
for block in drawing.blocks.data:
|
||||
#print 'deb:getBlocksmap block=%s\n i.entities=%s\n i.data=%s' %(block,block.entities,block.entities.data)
|
||||
if type(block) != list and block.type == 'block':
|
||||
childList = []
|
||||
used = False
|
||||
for item2 in item.entities.data:
|
||||
if type(item2) != list and item2.type == 'insert':
|
||||
#print 'deb:getBlocksmap dir(item2)=', dir(item2) #----------
|
||||
item2str = [item2.name, item2.layer]
|
||||
childList.append(item2str)
|
||||
try: usedblocks[item.name] = [used, childList]
|
||||
except KeyError: print 'Cannot find "%s" Block!' %(item.name)
|
||||
for item in block.entities.data:
|
||||
if type(item) != list and item.type == 'insert':
|
||||
#print 'deb:getBlocksmap dir(item)=', dir(item) #----------
|
||||
itemstr = [item.name, item.layer]
|
||||
childList.append(itemstr)
|
||||
try: usedblocks[block.name] = [used, childList]
|
||||
except KeyError: print 'Cannot find "%s" Block!' %(block.name)
|
||||
#print 'deb:getBlocksmap: usedblocks=' , usedblocks #-------------
|
||||
#print 'deb:getBlocksmap: layersmap=' , layersmap #-------------
|
||||
|
||||
key_list = usedblocks.keys()
|
||||
def r_block_used(blname,bllayer):
|
||||
#checks recursive if INSERT on frozen-layer
|
||||
if blname in key_list:
|
||||
if (not layersmap) or (layersmap and not layersmap[bllayer].frozen or layFrozen_on): #if insert_layer is not frozen
|
||||
usedblocks[blname][0] = True # marked as used BLOCK
|
||||
for child in usedblocks[blname][1]:
|
||||
sub_blname,sub_bllayer=child[0],child[1]
|
||||
r_block_used(sub_blname,sub_bllayer)
|
||||
|
||||
for item in drawing.entities.data:
|
||||
if type(item) != list and item.type == 'insert':
|
||||
if not layersmap or (not layersmap[item.layer].frozen or layFrozen_on): #if insert_layer is not frozen
|
||||
try: usedblocks[item.name][0] = True
|
||||
except KeyError: print 'Cannot find "%s" Block!' %(item.name)
|
||||
|
||||
key_list = usedblocks.keys()
|
||||
key_list.reverse()
|
||||
for key in key_list:
|
||||
if usedblocks[key][0]: #if parent used, then set used also all child blocks
|
||||
for child in usedblocks[key][1]:
|
||||
if not layersmap or (layersmap and not layersmap[child[1]].frozen): #if insert_layer is not frozen
|
||||
try: usedblocks[child[0]][0] = True # marked as used BLOCK
|
||||
except KeyError: print 'Cannot find "%s" Block!' %(child[0])
|
||||
|
||||
r_block_used(item.name,item.layer)
|
||||
|
||||
usedblocks = [i for i in usedblocks.keys() if usedblocks[i][0]]
|
||||
#print 'deb:getBlocksmap: usedblocks=' , usedblocks #-------------
|
||||
obj_number = 0
|
||||
@@ -5585,7 +5596,7 @@ def resetDefaultConfig_3D(): #-----------------------------------------------
|
||||
updateConfig(keywords3d, drawTypes3d)
|
||||
|
||||
|
||||
def inputGlobalScale():
|
||||
def inputGlobalScale():
|
||||
"""Pop-up UI-Block for global scale factor
|
||||
"""
|
||||
global GUI_A
|
||||
@@ -5600,7 +5611,7 @@ def inputGlobalScale():
|
||||
GUI_A['g_scale'].val = float(x_scale.val)
|
||||
|
||||
|
||||
def inputOriginVector():
|
||||
def inputOriginVector():
|
||||
"""Pop-up UI-Block for global translation vector
|
||||
"""
|
||||
global GUI_A
|
||||
@@ -6048,7 +6059,7 @@ def bevent(evt):
|
||||
webbrowser.open('http://wiki.blender.org/index.php?title=Scripts/Manual/Import/DXF-3D')
|
||||
except:
|
||||
Draw.PupMenu('DXF importer: HELP Alert!%t|no connection to manual-page on Blender-Wiki! try:|\
|
||||
http://wiki.blender.org/index.php?title=Scripts/Manual/Import/DXF-3D')
|
||||
http://wiki.blender.org/index.php?title=Scripts/Manual/Import/DXF-3D')
|
||||
Draw.Redraw()
|
||||
elif (evt==EVENT_LOAD_INI):
|
||||
loadConfig()
|
||||
@@ -6090,9 +6101,7 @@ http://wiki.blender.org/index.php?title=Scripts/Manual/Import/DXF-3D')
|
||||
if not extCONV_OK: Draw.PupMenu(extCONV_TEXT)
|
||||
elif Draw.PupMenu('DWG importer will import all DWG-files from:|%s|OK?' % dxfFile) != -1:
|
||||
#elif Draw.PupMenu('DWG importer will import all DWG-files from:|%s|Caution! overwrites existing DXF-files!| OK?' % dxfFile) != -1:
|
||||
UI_MODE = False
|
||||
multi_import(dxfFile)
|
||||
UI_MODE = True
|
||||
Draw.Redraw()
|
||||
|
||||
elif sys.exists(dxfFile) and dxfFile.lower()[-4:] in ('.dxf','.dwg'):
|
||||
@@ -6125,6 +6134,28 @@ http://wiki.blender.org/index.php?title=Scripts/Manual/Import/DXF-3D')
|
||||
Draw.Redraw()
|
||||
|
||||
|
||||
def import_file(dxfFile):
|
||||
"""Imports DXF-file in non-UI-mode
|
||||
|
||||
"""
|
||||
global SCENE
|
||||
global GUI_A, UI_MODE
|
||||
|
||||
if GUI_A['newScene_on'].val:
|
||||
_dxf_file = dxfFile.split('/')[-1].split('\\')[-1]
|
||||
_dxf_file = _dxf_file[:-4] # cut last char:'.dxf'
|
||||
_dxf_file = _dxf_file[:MAX_NAMELENGTH] #? [-MAX_NAMELENGTH:])
|
||||
SCENE = Blender.Scene.New(_dxf_file)
|
||||
SCENE.makeCurrent()
|
||||
#or so? Blender.Scene.makeCurrent(_dxf_file)
|
||||
#sce = bpy.data.scenes.new(_dxf_file)
|
||||
#bpy.data.scenes.active = sce
|
||||
else:
|
||||
SCENE = Blender.Scene.GetCurrent()
|
||||
SCENE.objects.selected = [] # deselect all
|
||||
UI_MODE = False
|
||||
main(dxfFile)
|
||||
UI_MODE = True
|
||||
|
||||
|
||||
def multi_import(DIR):
|
||||
@@ -6145,31 +6176,16 @@ def multi_import(DIR):
|
||||
[sys.join(DIR, f) for f in os.listdir(DIR) if f.lower().endswith(EXT)]
|
||||
if not files:
|
||||
print '...None %s-files found. Abort!' %EXT
|
||||
return
|
||||
else:
|
||||
for i,dxfFile in enumerate(files):
|
||||
print '\n%s-file' %EXT, i+1, 'of', len(files) #,'\nImporting', dxfFile
|
||||
import_file(dxfFile)
|
||||
#Blender.Redraw()
|
||||
|
||||
print 'TOTAL TIME: %.6f' % (sys.time() - batchTIME)
|
||||
print '\a\r', # beep when done
|
||||
Draw.PupMenu('DXF importer: Done!|finished in %.4f sec.' % (sys.time() - batchTIME))
|
||||
|
||||
i = 0
|
||||
for dxfFile in files:
|
||||
i += 1
|
||||
print '\n%s-file' %EXT, i, 'of', len(files) #,'\nImporting', dxfFile
|
||||
if GUI_A['newScene_on'].val:
|
||||
_dxf_file = dxfFile.split('/')[-1].split('\\')[-1]
|
||||
_dxf_file = _dxf_file[:-4] # cut last char:'.dxf'
|
||||
_dxf_file = _dxf_file[:MAX_NAMELENGTH] #? [-MAX_NAMELENGTH:])
|
||||
SCENE = Blender.Scene.New(_dxf_file)
|
||||
SCENE.makeCurrent()
|
||||
#or so? Blender.Scene.makeCurrent(_dxf_file)
|
||||
#sce = bpy.data.scenes.new(_dxf_file)
|
||||
#bpy.data.scenes.active = sce
|
||||
else:
|
||||
SCENE = Blender.Scene.GetCurrent()
|
||||
SCENE.objects.selected = [] # deselect all
|
||||
main(dxfFile)
|
||||
#Blender.Redraw()
|
||||
|
||||
print 'TOTAL TIME: %.6f' % (sys.time() - batchTIME)
|
||||
print '\a\r', # beep when done
|
||||
Draw.PupMenu('DXF importer: Done!|finished in %.4f sec.' % (sys.time() - batchTIME))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
#Draw.PupMenu('DXF importer: Abort%t|This script version works for Blender up 2.49 only!')
|
||||
|
@@ -1774,7 +1774,7 @@ def importMesh_IndexedFaceSet(geom, bpyima, ancestry):
|
||||
color_index = faces_orig_index[f.index] # color index is face index
|
||||
#print color_index, ifs_color_index
|
||||
if ifs_color_index:
|
||||
if color_index <= len(ifs_color_index):
|
||||
if color_index >= len(ifs_color_index):
|
||||
print '\tWarning: per face color index out of range'
|
||||
color_index = 0
|
||||
else:
|
||||
|
@@ -1363,7 +1363,7 @@ static short bevelinside(BevList *bl1,BevList *bl2)
|
||||
prevbevp= bevp+(nr-1);
|
||||
|
||||
while(nr--) {
|
||||
min= prevbevp->vec[0];
|
||||
min= prevbevp->vec[1];
|
||||
max= bevp->vec[1];
|
||||
if(max<min) {
|
||||
min= max;
|
||||
|
@@ -88,7 +88,7 @@ void IDP_ResizeArray(IDProperty *prop, int newlen)
|
||||
/*newlen is bigger*/
|
||||
if (newlen >= prop->len) memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[prop->type]);
|
||||
/*newlen is smaller*/
|
||||
else memcpy(newarr, prop->data.pointer, newlen*prop->len*idp_size_table[prop->type]);
|
||||
else memcpy(newarr, prop->data.pointer, newlen*idp_size_table[prop->type]);
|
||||
|
||||
MEM_freeN(prop->data.pointer);
|
||||
prop->data.pointer = newarr;
|
||||
|
@@ -326,6 +326,7 @@ void BLI_del_slash(char *string);
|
||||
* @return True if @a rect is empty.
|
||||
*/
|
||||
int BLI_rcti_is_empty(struct rcti *rect);
|
||||
int BLI_rctf_is_empty(struct rctf *rect);
|
||||
void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
|
||||
void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
|
||||
void BLI_translate_rctf(struct rctf *rect, float x, float y);
|
||||
|
@@ -48,6 +48,12 @@ int BLI_rcti_is_empty(rcti * rect)
|
||||
(rect->ymax<=rect->ymin));
|
||||
}
|
||||
|
||||
int BLI_rctf_is_empty(rctf * rect)
|
||||
{
|
||||
return ((rect->xmax<=rect->xmin) ||
|
||||
(rect->ymax<=rect->ymin));
|
||||
}
|
||||
|
||||
int BLI_in_rcti(rcti * rect, int x, int y)
|
||||
{
|
||||
|
||||
|
@@ -606,13 +606,15 @@ static void BPY_Err_Handle( char *script_name )
|
||||
*/
|
||||
|
||||
for(;;) {
|
||||
PyObject *py_fn= NULL;
|
||||
v = PyObject_GetAttrString( tb, "tb_next" );
|
||||
|
||||
if( !v || v == Py_None ||
|
||||
strcmp(PyString_AsString(traceback_getFilename(v)), script_name)) {
|
||||
strcmp(PyString_AsString((py_fn= traceback_getFilename(v))), script_name)) {
|
||||
Py_XDECREF(py_fn);
|
||||
break;
|
||||
}
|
||||
|
||||
Py_XDECREF( py_fn );
|
||||
Py_DECREF( tb );
|
||||
tb = v;
|
||||
}
|
||||
|
@@ -392,6 +392,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
"BPy_IDGroup_MapDataToPy() failed" );
|
||||
|
||||
PyDict_SetItemString(dict, loop->name, wrap);
|
||||
Py_DECREF(wrap);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
@@ -56,6 +56,7 @@ extern int cu_ar[];
|
||||
extern int seq_ar[];
|
||||
extern int te_ar[];
|
||||
extern int wo_ar[];
|
||||
extern int part_ar[];
|
||||
|
||||
PyObject *submodule;
|
||||
|
||||
@@ -303,6 +304,11 @@ void generate_curveattrs( PyObject* dict, int blocktype )
|
||||
vals = seq_ar;
|
||||
size = SEQ_TOTIPO;
|
||||
break;
|
||||
case ID_PA:
|
||||
lookup_name = (namefunc)getname_part_ei;
|
||||
vals = part_ar;
|
||||
size = PART_TOTIPO;
|
||||
break;
|
||||
}
|
||||
|
||||
desc = PyDescr_NewGetSet( &Ipo_Type, &BPy_Ipocurve_getseter );
|
||||
@@ -517,6 +523,11 @@ static short lookup_curve_name( char *str, int blocktype, int channel )
|
||||
adrcodes = seq_ar;
|
||||
size = SEQ_TOTIPO;
|
||||
break;
|
||||
case ID_PA:
|
||||
lookup_name = (namefunc)getname_part_ei;
|
||||
adrcodes = part_ar;
|
||||
size = PART_TOTIPO;
|
||||
break;
|
||||
case ID_KE: /* shouldn't happen */
|
||||
default:
|
||||
return -1;
|
||||
@@ -621,6 +632,10 @@ static short lookup_curve_adrcode( int code, int blocktype, int channel )
|
||||
adrcodes = seq_ar;
|
||||
size = SEQ_TOTIPO;
|
||||
break;
|
||||
case ID_PA:
|
||||
adrcodes = part_ar;
|
||||
size = PART_TOTIPO;
|
||||
break;
|
||||
case ID_KE:
|
||||
default:
|
||||
return -1;
|
||||
@@ -699,6 +714,8 @@ static PyObject *M_Ipo_New( PyObject * self_unused, PyObject * args )
|
||||
idcode = ID_CO;
|
||||
else if( !strcmp( code, "Sequence" ) )
|
||||
idcode = ID_SEQ;
|
||||
else if( !strcmp( code, "Particle" ) )
|
||||
idcode = ID_PA;
|
||||
else if( !strcmp( code, "Curve" ) )
|
||||
idcode = ID_CU;
|
||||
else if( !strcmp( code, "Key" ) )
|
||||
@@ -1094,6 +1111,12 @@ static PyObject *Ipo_getCurveNames( BPy_Ipo * self )
|
||||
size = SEQ_TOTIPO;
|
||||
strcpy( name, "SQ_" );
|
||||
break;
|
||||
case ID_PA:
|
||||
lookup_name = (namefunc)getname_part_ei;
|
||||
vals = part_ar;
|
||||
size = PART_TOTIPO;
|
||||
strcpy( name, "PA_" );
|
||||
break;
|
||||
case ID_KE:
|
||||
{
|
||||
Key *key;
|
||||
@@ -1155,7 +1178,7 @@ static void generate_curveconsts( PyObject* module )
|
||||
|
||||
unsigned int i = 0;
|
||||
static short curvelist[] = {
|
||||
ID_OB, ID_MA, ID_CA, ID_LA, ID_TE, ID_WO, ID_PO, ID_CO, ID_CU, ID_SEQ
|
||||
ID_OB, ID_MA, ID_CA, ID_LA, ID_TE, ID_WO, ID_PO, ID_CO, ID_CU, ID_SEQ, ID_PA
|
||||
};
|
||||
|
||||
for( i = 0; i < sizeof(curvelist)/sizeof(short); ++i ) {
|
||||
@@ -1220,6 +1243,12 @@ static void generate_curveconsts( PyObject* module )
|
||||
size = SEQ_TOTIPO;
|
||||
strcpy( name, "SQ_" );
|
||||
break;
|
||||
case ID_PA:
|
||||
lookup_name = (namefunc)getname_part_ei;
|
||||
vals = part_ar;
|
||||
size = PART_TOTIPO;
|
||||
strcpy( name, "PA_" );
|
||||
break;
|
||||
}
|
||||
|
||||
while( size-- ) {
|
||||
@@ -1297,6 +1326,8 @@ static PyObject *Ipo_repr( BPy_Ipo * self )
|
||||
param = "Curve"; break;
|
||||
case ID_SEQ:
|
||||
param = "Sequence"; break;
|
||||
case ID_PA:
|
||||
param = "Particle"; break;
|
||||
case ID_KE:
|
||||
param = "Key"; break;
|
||||
default:
|
||||
|
@@ -362,6 +362,8 @@ char *getIpoCurveName( IpoCurve * icu )
|
||||
return get_key_curvename( icu );
|
||||
case ID_SEQ:
|
||||
return getname_seq_ei( icu->adrcode );
|
||||
case ID_PA:
|
||||
return getname_part_ei( icu->adrcode );
|
||||
case ID_CO:
|
||||
return getname_co_ei( icu->adrcode );
|
||||
}
|
||||
@@ -630,6 +632,9 @@ static PyObject *IpoCurve_getName( C_IpoCurve * self )
|
||||
case ID_SEQ:
|
||||
return PyString_FromString( getname_seq_ei
|
||||
( self->ipocurve->adrcode ) );
|
||||
case ID_PA:
|
||||
return PyString_FromString( getname_part_ei
|
||||
( self->ipocurve->adrcode ) );
|
||||
case ID_CO:
|
||||
return PyString_FromString( getname_co_ei
|
||||
( self->ipocurve->adrcode ) );
|
||||
|
@@ -32,7 +32,9 @@
|
||||
|
||||
#include "BDR_editobject.h" /* enter / leave editmode */
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h" /* for SetBgImage() */
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_library.h" /* for SetBgImage() */
|
||||
#include "BKE_object.h" /* for during_script() and during_scriptlink() */
|
||||
#include "BKE_scene.h" /* scene_find_camera() */
|
||||
#include "BIF_mywindow.h"
|
||||
@@ -52,6 +54,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
#include "mydevice.h"
|
||||
#include "blendef.h" /* OBACT */
|
||||
#include "Image.h" /* for GetBgImage() */
|
||||
#include "windowTheme.h"
|
||||
#include "Mathutils.h"
|
||||
#include "constant.h"
|
||||
@@ -82,6 +85,8 @@ PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_RedrawAll( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_QRedrawAll( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_GetBgImage( PyObject * self );
|
||||
static PyObject *M_Window_SetBgImage( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_GetCursorPos( PyObject * self );
|
||||
static PyObject *M_Window_SetCursorPos( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Window_WaitCursor( PyObject * self, PyObject * args );
|
||||
@@ -165,6 +170,12 @@ static char M_Window_DrawProgressBar_doc[] =
|
||||
'done' is a float value <= 1.0, 'text' contains info about what is\n\
|
||||
currently being done.";
|
||||
|
||||
static char M_Window_GetBgImage_doc[] =
|
||||
"() - Get the current Background Image.";
|
||||
|
||||
static char M_Window_SetBgImage_doc[] =
|
||||
"(Blender Image) - Set Background Image.";
|
||||
|
||||
static char M_Window_GetCursorPos_doc[] =
|
||||
"() - Get the current 3d cursor position as a list of three floats.";
|
||||
|
||||
@@ -332,6 +343,10 @@ struct PyMethodDef M_Window_methods[] = {
|
||||
M_Window_DrawProgressBar_doc},
|
||||
{"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
|
||||
M_Window_DrawProgressBar_doc},
|
||||
{"GetBgImage", ( PyCFunction ) M_Window_GetBgImage, METH_NOARGS,
|
||||
M_Window_GetBgImage_doc},
|
||||
{"SetBgImage", ( PyCFunction ) M_Window_SetBgImage, METH_VARARGS,
|
||||
M_Window_SetBgImage_doc},
|
||||
{"GetCursorPos", ( PyCFunction ) M_Window_GetCursorPos, METH_NOARGS,
|
||||
M_Window_GetCursorPos_doc},
|
||||
{"SetCursorPos", M_Window_SetCursorPos, METH_VARARGS,
|
||||
@@ -670,6 +685,53 @@ static PyObject *M_Window_DrawProgressBar( PyObject * self, PyObject * args )
|
||||
return Py_BuildValue( "i", retval );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Window_GetBgImage */
|
||||
/* Python equivalent: Blender.Window.GetBgImage */
|
||||
/* code borrowed from Texture.py -Texture_getImage( ) */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Window_GetBgImage ( PyObject * self )
|
||||
{
|
||||
if( G.vd && G.vd->bgpic && G.vd->bgpic->ima)
|
||||
return Image_CreatePyObject( G.vd->bgpic->ima );
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Window_SetBgImage */
|
||||
/* Python equivalent: Blender.Window.SetBgImage */
|
||||
/* code borrowed from Texture.py -Texture_setImage( ) */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Window_SetBgImage ( PyObject * self , PyObject * args)
|
||||
{
|
||||
PyObject *value;
|
||||
Image *blimg = NULL;
|
||||
|
||||
PyArg_ParseTuple(args, "O", &value);
|
||||
|
||||
if ( value && value != Py_None && !BPy_Image_Check(value) )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected an Image or None" );
|
||||
|
||||
if( G.vd && G.vd->bgpic->ima ) {
|
||||
G.vd->bgpic->ima->id.us--;
|
||||
G.vd->bgpic->ima = NULL;
|
||||
}
|
||||
|
||||
if ( value == NULL || value == Py_None )
|
||||
Py_RETURN_NONE;
|
||||
|
||||
blimg = Image_FromPyObject( value );
|
||||
|
||||
G.vd->bgpic->ima = blimg;
|
||||
G.vd->flag = V3D_DISPBGPIC|G.vd->flag;
|
||||
BKE_image_signal(blimg, &G.vd->bgpic->iuser, IMA_SIGNAL_RELOAD );
|
||||
id_us_plus( &blimg->id );
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Window_GetCursorPos */
|
||||
/* Python equivalent: Blender.Window.GetCursorPos */
|
||||
|
@@ -224,6 +224,20 @@ def SetPivot (pivot):
|
||||
@param pivot: constant - Window.PivotTypes
|
||||
"""
|
||||
|
||||
def GetBgImage():
|
||||
"""
|
||||
Get Background Image from current 3D-View (or None).
|
||||
@return: Blender Image or None
|
||||
"""
|
||||
|
||||
def SetBgImage(image):
|
||||
"""
|
||||
Set the Image as Background Image in current 3D-View and turn it on.
|
||||
@param image: the new Image.
|
||||
@type image: Blender Image or None.
|
||||
@None removes current Background Image.
|
||||
"""
|
||||
|
||||
def WaitCursor (bool):
|
||||
"""
|
||||
Set cursor to wait or back to normal mode.
|
||||
|
@@ -3365,7 +3365,7 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
|
||||
|
||||
/* preview */
|
||||
if(node->flag & NODE_PREVIEW)
|
||||
if(node->preview && node->preview->rect)
|
||||
if(node->preview && node->preview->rect && !BLI_rctf_is_empty(&node->prvr))
|
||||
node_draw_preview(node->preview, &node->prvr);
|
||||
|
||||
/* buttons */
|
||||
|
@@ -93,12 +93,20 @@ IF(UNIX AND NOT APPLE)
|
||||
MAIN_DEPENDENCY blender
|
||||
COMMAND rm -Rf ${TARGETDIR}/.blender
|
||||
COMMAND mkdir ${TARGETDIR}/.blender/
|
||||
COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
|
||||
COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
|
||||
COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
|
||||
COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/
|
||||
COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;"
|
||||
)
|
||||
|
||||
IF(WITH_INTERNATIONAL)
|
||||
ADD_CUSTOM_COMMAND(TARGET blender
|
||||
POST_BUILD
|
||||
MAIN_DEPENDENCY blender
|
||||
COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/
|
||||
COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/
|
||||
COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/
|
||||
)
|
||||
ENDIF(WITH_INTERNATIONAL)
|
||||
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
|
||||
IF(APPLE)
|
||||
|
@@ -32,6 +32,8 @@
|
||||
//#define USE_DL_EXPORT
|
||||
#include "Python.h"
|
||||
|
||||
#include <stddef.h> /* for python offsetof macros */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <osreldate.h>
|
||||
#if __FreeBSD_version > 500039
|
||||
|
@@ -592,7 +592,7 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape)
|
||||
|
||||
for(int i= 0; i < obarr.size(); i++) {
|
||||
ob= obarr[i];
|
||||
if (ob->getCollisionShape() == newShape); {
|
||||
if (ob->getCollisionShape() == newShape) {
|
||||
proxy = obarr[i]->getBroadphaseHandle();
|
||||
|
||||
if(proxy)
|
||||
|
@@ -29,6 +29,8 @@
|
||||
#include "DummyPhysicsEnvironment.h"
|
||||
#include "PHY_IMotionState.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
@@ -15,11 +15,11 @@ The Blender Game Engine Python API Reference
|
||||
- L{GameKeys} keyboard input and event conversion.
|
||||
- L{Rasterizer} display and rendering.
|
||||
- L{GameTypes} contains all the python types spesific to the GameEngine.
|
||||
- L{PhysicsConstraints} constraints and physical dynamics
|
||||
|
||||
Undocumented modules:
|
||||
---------------------
|
||||
Undocumented module:
|
||||
--------------------
|
||||
- VideoTexture
|
||||
- PhysicsConstraints
|
||||
|
||||
Additional Modules:
|
||||
-------------------
|
||||
|
294
source/gameengine/PyDoc/PhysicsConstraints.py
Normal file
294
source/gameengine/PyDoc/PhysicsConstraints.py
Normal file
@@ -0,0 +1,294 @@
|
||||
# $Id$
|
||||
"""
|
||||
Documentation for the PhysicsConstraints module.
|
||||
================================================
|
||||
|
||||
Example::
|
||||
|
||||
|
||||
# Adding a point constraint #
|
||||
###############################
|
||||
|
||||
|
||||
# import BGE internal module
|
||||
import PhysicsConstraints
|
||||
|
||||
# get object list
|
||||
obj_list = GameLogic.getCurrentScene().objects
|
||||
|
||||
# get object named Obj_1
|
||||
root = obj_list["root"]
|
||||
obj = obj_list["obj"]
|
||||
|
||||
# get object physics ID
|
||||
phido = obj.getPhysicsId()
|
||||
|
||||
# get root physics ID
|
||||
phidr = root.getPhysicsId()
|
||||
|
||||
# want to use point constraint type
|
||||
constraint_type = 1
|
||||
|
||||
# Use bottom right front corner of object for point constraint position
|
||||
point_pos_x = 1.0
|
||||
point_pos_y = -1.0
|
||||
point_pos_z = -1.0
|
||||
|
||||
# create a point constraint
|
||||
const = PhysicsConstraints.createConstraint( phido, phidr, constraint_type, point_pos_x, point_pos_y, point_pos_z)
|
||||
|
||||
# stores the new constraint ID to be used later
|
||||
obj["constraint_ID"] = const.getConstraintId()
|
||||
|
||||
|
||||
Example::
|
||||
|
||||
|
||||
# Removing a point constraint #
|
||||
#################################
|
||||
|
||||
|
||||
# import BGE internal module
|
||||
import PhysicsConstraints
|
||||
|
||||
# get object list
|
||||
obj_list = GameLogic.getCurrentScene().objects
|
||||
|
||||
# get object 1
|
||||
obj = obj_list["obj"]
|
||||
|
||||
# get constraint ID that was saved as an obj property
|
||||
# when the constraint was created
|
||||
constraint_ID = obj["constraint_ID"]
|
||||
|
||||
# remove constraint
|
||||
PhysicsConstraints.removeConstraint(constraint_ID)
|
||||
|
||||
"""
|
||||
|
||||
def createConstraint(obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z):
|
||||
"""
|
||||
Create a point constraint between two objects, an edge constraint between two objects, or a vehicle constraint on an object.
|
||||
|
||||
You only have to input the needed parammeters depending on the type of constraint you are trying to create.
|
||||
|
||||
|
||||
B{Point Constraint} ::
|
||||
|
||||
While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
|
||||
If you are creating a point constraint be sure to assing the integer "1" as the constraintType value.
|
||||
|
||||
Parameters to use:
|
||||
obj_PhysicsID, root_PhysicsID, constraintType, pointPos_x, pointPos_y, pointPos_z
|
||||
|
||||
B{Edge Constraint} ::
|
||||
|
||||
While creating an edge constraint, the "edgePos" values define where you want the center of the edge constraint to be.
|
||||
Also, the "edgeAngle" values define in which direction you want the edge constraint to point (As a 3 dimensions vector).
|
||||
If you want to create an edge constraint be sure to assing the integer "2" as the constraintType value.
|
||||
|
||||
Parameters to use:
|
||||
obj_PhysicsID, root_PhysicsID, constraintType, edgePos_x, edgePos_y, edgePos_z, edgeAngle_x, edgeAngle_y, edgeAngle_z}
|
||||
|
||||
B{Vehicle Constraint} ::
|
||||
|
||||
While creating a point constraint, the "pointPos" values define where you want the pivot point to be located.
|
||||
If you want to create an edge constraint be sure to assing the integer "0" as the constraintType value.
|
||||
|
||||
Parameters to use :
|
||||
obj_PhysicsID, root_PhysicsID, constraintType
|
||||
|
||||
@type obj_PhysicsID: integer
|
||||
@param obj_PhysicsID: The physic ID of the first object to constraint.
|
||||
|
||||
@type root_PhysicsID: integer
|
||||
@param root_PhysicsID: The physic ID of the second object to constraint.
|
||||
|
||||
@type constraintType: integer
|
||||
@param constraintType: The type of constraint.
|
||||
|
||||
@type pointPos_x: float
|
||||
@param pointPos_x: The X position of the point constraint.
|
||||
|
||||
@type pointPos_y: float
|
||||
@param pointPos_y: The Y position of the point constraint.
|
||||
|
||||
@type pointPos_z: float
|
||||
@param pointPos_z: The Z position of the point constraint.
|
||||
|
||||
@type edgePos_x: float
|
||||
@param edgePos_x: The X value of the center of the edge constraint.
|
||||
|
||||
@type edgePos_y: float
|
||||
@param edgePos_y: The Y value of the center of the edge constraint.
|
||||
|
||||
@type edgePos_z: float
|
||||
@param edgePos_z: The Z value of the center of the edge constraint.
|
||||
|
||||
@type edgeAngle_x: float
|
||||
@param edgeAngle_x: The X value of the edge's orientation vector.
|
||||
|
||||
@type edgeAngle_y: float
|
||||
@param edgeAngle_y: The Y value of the edge's orientation vector.
|
||||
|
||||
@type edgeAngle_z: float
|
||||
@param edgeAngle_z: The Z value of the edge's orientation vector.
|
||||
|
||||
@rtype: integer
|
||||
@return: The created constraint ID
|
||||
"""
|
||||
|
||||
|
||||
def getAppliedImpulse(constraint_ID):
|
||||
"""
|
||||
Returns the applied impulse.
|
||||
|
||||
@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
|
||||
@type constraint_ID: integer
|
||||
@rtype: float
|
||||
@return: Measure the stress on a constraint.
|
||||
"""
|
||||
|
||||
|
||||
def getVehicleConstraint(constraint_ID):
|
||||
"""
|
||||
Returns the vehicle constraint ID.
|
||||
|
||||
@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
|
||||
@type constraint_ID: integer
|
||||
@rtype: integer
|
||||
"""
|
||||
def removeConstraint(constraint_ID):
|
||||
"""
|
||||
|
||||
Removes the constraint between 2 game objects (point and edge constraints).
|
||||
|
||||
It does not remove vehicle constraints.
|
||||
|
||||
@param constraint_ID: The constraint ID that was saved on the creation of the constraint.
|
||||
@type constraint_ID: integer
|
||||
"""
|
||||
def setDeactivationLinearTreshold(linearTreshold):
|
||||
"""
|
||||
|
||||
Sets the linear velocity that an object must be below before the deactivation timer can start.
|
||||
|
||||
This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
|
||||
|
||||
@param linearTreshold: The linear velocity.
|
||||
@type linearTreshold: float
|
||||
"""
|
||||
def setDeactivationAngularTreshold(angularTreshold):
|
||||
"""
|
||||
|
||||
Sets the angular velocity that an object must be below before the deactivation timer can start.
|
||||
|
||||
This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
|
||||
|
||||
@param angularTreshold: The angular velocity.
|
||||
@type angularTreshold: float
|
||||
"""
|
||||
def setDeactivationTime(time):
|
||||
"""
|
||||
|
||||
Time (in seconds) after objects with velocity less then thresholds (see below) are deactivated.
|
||||
|
||||
This affects every object in the scene, except for game objects that have 'No sleeping' turned on.
|
||||
|
||||
This function is directly related with the 2 above functions.
|
||||
|
||||
|
||||
@param time: The time in seconds.
|
||||
@type time: float
|
||||
"""
|
||||
def setGravity(gx, gy, gz):
|
||||
"""
|
||||
Sets the gravity for the actual scene only.
|
||||
|
||||
All other scenes remain unaffected.
|
||||
|
||||
This affects every object in the scene that has physics enabled.
|
||||
|
||||
@param gx: The force of gravity on world x axis.
|
||||
@type gx: float
|
||||
@param gy: The force of gravity on world y axis.
|
||||
@type gy: float
|
||||
@param gz: The force of gravity on world z axis.
|
||||
@type gz: float
|
||||
"""
|
||||
def setLinearAirDamping(damping):
|
||||
"""
|
||||
|
||||
Sets the linear air resistance for all objects in the scene.
|
||||
|
||||
@param damping: The linear air resistance.
|
||||
@type damping: float
|
||||
"""
|
||||
def setNumIterations(numIter):
|
||||
"""
|
||||
Sets the number of times an iterative constraint solver is repeated.
|
||||
|
||||
Increasing the number of iterations improves the constraint solver at the cost of performances & the speed of the game engine.
|
||||
|
||||
@param numIter: The number of timesubsteps. (Input 0 to suspend simulation numSubStep)
|
||||
@type numIter: integer
|
||||
"""
|
||||
def setNumTimeSubSteps(numSubStep):
|
||||
"""
|
||||
Set the quality of the entire physics simulation including collision detection and constraint solver.
|
||||
|
||||
Increase the number of time substeps to improves the quality of the entire physics simulation at the cost of the performance & the speed of the game engine.
|
||||
|
||||
@param numSubStep: The number of timesubsteps. (Input 0 to suspend simulation numSubStep)
|
||||
@type numSubStep: integer
|
||||
"""
|
||||
#def setDebugMode():
|
||||
# """
|
||||
#
|
||||
#
|
||||
#
|
||||
# @param numIter:
|
||||
# @type numIter:
|
||||
# """
|
||||
#def setCcdMode():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setContactBreakingTreshold():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setSolverDamping():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setSolverTau():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setSolverType():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setSorConstant():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
||||
#def setUseEpa():
|
||||
# """
|
||||
# Does something
|
||||
#
|
||||
# @rtype:
|
||||
# """
|
Reference in New Issue
Block a user