cellpack.autopack.upy package

Subpackages

Submodules

cellpack.autopack.upy.colors module

Copyright (C) <2010> Autin L. TSRI

This file git_upy/colors.py is part of upy.

upy 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 3 of the License, or (at your option) any later version.

upy 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 upy. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.

cellpack.autopack.upy.colors.RedWhiteBlueRamp(size=256)[source]
cellpack.autopack.upy.colors.ThreeColorRamp(col1=(0.0, 0.0, 1.0), col2=(1.0, 1.0, 1.0), col3=(1.0, 0.0, 0.0), size=256, alpha=False)[source]
cellpack.autopack.upy.colors.TwoColorRamp(col1=(1.0, 0.0, 0.0), col2=(1.0, 1.0, 1.0), size=256, alpha=False)[source]
cellpack.autopack.upy.colors.create_divergent_color_map_with_scaled_values(min_value, max_value, color_list)[source]

Use case: you want a divergent scale centered at 0, but with drastically different negative scale and positive scale. Ie, min number is -20, and max is 2000. @param min_value: float value that is the min of the data @param max_value: float value max of the data @param color_list: array of color strings, either “red” or “rgb(222, 0, 0)” returns: a mapping from 0 to 1 with the appropriate step size for negative and positive values in the form [[0.0, ‘rgb(222, 0, 0)’], …]

cellpack.autopack.upy.colors.getRamp(colors, size=256)[source]
cellpack.autopack.upy.colors.hexToRgb(c)[source]
cellpack.autopack.upy.colors.map_colors(values, colorMap, mini=None, maxi=None)[source]

Get colors corresponding to values in a colormap

cellpack.autopack.upy.hostHelper module

Copyright (C) <2010> Autin L. TSRI This file git_upy/hostHelper.py is part of upy.

upy 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 3 of the License, or (at your option) any later version.

upy 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 upy. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.

class cellpack.autopack.upy.hostHelper.Helper[source]

Bases: object

The Helper abstract Object

This is the main class from which all helper derived. The Helper give access to the basic function need for create and edit object in the host.

Most of the function define at this loevel are overwrite by the class child. matrix and transformation came from http://www.lfd.uci.edu/~gohlke/code/transformations.py.html

>>> import upy
>>> hClass = upy.getHelperClass()
>>> helper = helper.hClass()

See examples in upy/examples

AddObject(object, parent=None, centerRoot=True, rePos=None)[source]

Insert/add an object to the current document under the specified parent, and at the specified location. This function is an alias for addObjectToScene to permit to some script to work either in dejavu and the host.

  • overwrited by children class for each host

@type object: hostObject @param object: the object to insert @type parent: hostObject @param parent: the parent of the object to insert under @type centerRoot: boolean @param centerRoot: if the object have to be recentered according the top-level @type rePos: list @param rePos: the location of the object in the scene

ApplyMatrix(coords, mat)[source]

Apply the 4x4 transformation matrix to the given list of 3d points.

@type coords: array @param coords: the list of point to transform. @type mat: 4x4array @param mat: the matrix to apply to the 3d points

@rtype: array @return: the transformed list of 3d points

BONES = None
CAM_OPTIONS = {'ortho': 'ortho', 'persp': 'persp'}
Circle(name, rad=1.0, **kw)[source]

Create a hostobject of type 2d circle.

  • overwrited by children class for each host

@type name: string @param name: name of the circle @type rad: float @param rad: the radius of the cylinder (default = 1.) @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject @return: the created circle

Cylinder(name, radius=1.0, length=1.0, res=16, pos=[0.0, 0.0, 0.0], **kw)[source]

Create a hostobject of type cylinder.

  • overwrited by children class for each host

@type name: string @param name: name of the cylinder @type radius: float @param radius: the radius of the cylinder @type length: float @param length: the length of the cylinder @type res: float @param res: the resolution/quality of the cylinder @type pos: array @param pos: the position of the cylinder @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject,hostMesh @return: the created cylinder object and mesh

CylinderHeadTails(cylinder, **kw)[source]
Decompose4x4(matrix)[source]

Takes a matrix in shape (16,) in OpenGL form (sequential values go down columns) and decomposes it into its rotation (shape (16,)), translation (shape (3,)), and scale (shape (3,))

@type matrix: 4x4array @param matrix: the matrix to decompose

@rtype: list of array @return: the decomposition of the matrix ie : rotation,translation,scale

Dodecahedron(name, radius)[source]

Create the mesh data and the mesh object of a Dodecahedron of a given radius

@type name: string @param name: name for the spline to update @type radius: float @param radius: radius of the embeding sphere

@rtype: Object, Mesh @return: Dodecahedron Object and Mesh

FixNormals(v, f, vn, fn=None)[source]
Hexahedron(name, radius)[source]

Create the mesh data and the mesh object of a Hexahedron of a given radius

@type name: string @param name: name for the spline to update @type radius: float @param radius: radius of the embeding sphere

@rtype: Object, Mesh @return: Hexahedron Object and Mesh

IK = None
Icosahedron(name, radius)[source]

Create the mesh data and the mesh object of a Icosahedron of a given radius

@type name: string @param name: name for the spline to update @type radius: float @param radius: radius of the embeding sphere

@rtype: Object, Mesh @return: Icosahedron Object and Mesh

IndexedPolgonsToTriPoints(geom, transform=True, **kw)[source]

Convert DejaVu IndexPolygon vertices data in a python list.

  • overwrited by children class for each host

@type geom: DejaVu IndexedPolygon @param geom: the object to triangulate @type transform: Boolean @param transform: apply the object transformation to the vertices @type kw: dictionary @param kw: dictionary of arg options

@rtype : list @return : the vertices data as list

JoinsObjects(listeObjects)[source]

Merge the given liste of object in one unique geometry.

  • overwrited by children class for each host

@type listeObjects: list @param listeObjects: list of object to joins

LIGHT_OPTIONS = {'Area': 'AREA', 'Spot': 'SPOT', 'Sun': 'SUN'}
MidPoint(p1, p2)[source]
ObjectsSelection(listeObjects, typeSel='new')[source]

Modify the current object selection. Redundant with setCurrentSelection.

This function make the distinction between adding (typeSel=”add”) object to the selection and creating a new selection (typeSel=”new”)

  • overwrited by children class for each host

@type listeObjects: list @param listeObjects: list of object to joins @type typeSel: string @param listeObjects: type of modification: new,add,…

Octahedron(name, radius)[source]

Create the mesh data and the mesh object of a Octahedron of a given radius

@type name: string @param name: name for the spline to update @type radius: float @param radius: radius of the embeding sphere

@rtype: Object, Mesh @return: Octahedron Object and Mesh

Platonic(name, Type, radius, **kw)[source]

Generate one of the 5 platonic solid. The name of each figure is derived from its number of faces: respectively “tetra” 4, “hexa” 6, “ocata” 8, “dodeca” 12, and 20. @type name: string @param name: name of the platonic @type Type: string or int @param Type: type of the platonic, can be tetra” 4, “hexa” 6, “ocata” 8, “dodeca” 12, and “ico” 20. @type radius: float @param radius: radius of the embeding sphere @type kw: dictionary @param kw: additional arguement such as meterial,parent

@rtype: hostObject @return: the created platonic

PointCloudObject(name, **kw)[source]

This function create a special polygon which have only point. See createsNmesh or particul if the hostdoes no support only point mesh

  • overwrited by children class for each host

@type name: string @param name: name of the pointCloud @type kw: dictionary @param kw: dictionary of arg options, ie :

‘vertices’ array of coordinates ; ‘faces’ int array of faces ; ‘parent’ hostAp parent object

@rtype: hostApp obj @return: the polygon object and data

Sphere(name, radius=1.0, res=0, pos=[0.0, 0.0, 0.0], **kw)[source]

Create a hostobject of type sphere.

  • overwrited by children class for each host

@type name: string @param name: name of the sphere @type radius: float @param radius: the radius of the sphere @type res: float @param res: the resolution/quality of the sphere @type pos: array @param pos: the position of the cylinder @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject,hostMesh @return: the created sphere object and mesh

Tetrahedron(name, radius)[source]

Create the mesh data and the mesh object of a Tetrahedron of a given radius

@type name: string @param name: name for the spline to update @type radius: float @param radius: radius of the embeding sphere

@rtype: Object, Mesh @return: Tetrahedron Object and Mesh

Text(name='', string='', parent=None, size=5.0, pos=None, font=None, lookAt=False, **kw)[source]

Create a hostobject of type Text.

  • overwrited by children class for each host

@type name: string @param name: name of the circle @type string: string @param string: text to display @type parent: Hostobject @param parent: parent of the text @type size: Float @param size: height of the text @type pos: Vector @param pos: position of the text @type font: ? @param font: the font to use @type lookAt: boolean @param lookAt: either the text is constraint to look at the camera/view @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject @return: the created text object

ToMat(mat)[source]

Return a python (4,4) matrice array from a host matrice

  • overwrited by children class for each host

@type mat: host matrice array @param mat: host matrice array @rtype: matrice @return: the converted matrice array

ToVec(v, pos=False)[source]

Return a python xyz array from a host xyz array/vector

  • overwrited by children class for each host

@type v: host vector array @param v: host vector array @rtype: array @return: the converted vector array

addBone(i, armData, headCoord, tailCoord, roll=10, hR=0.5, tR=0.5, dDist=0.4, boneParent=None, name=None, editMode=True, **kw)[source]

Add one bone to an armature. Optional function for creation of the armature

  • overwrited by children class for each host

@type i: int @param i: indice for the new bone @type armData: armature host data @param armData: the armature @type headCoord: array xyz @param headCoord: coordinate of the head of the bone @type tailCoord: array xyz @param tailCoord: coordinate of the tail of the bone @type boneParent: bone @param boneParent: the parent for the created bone @type kw: dictionary @param kw: dictionary of arg options

@rtype: bone @return: the created bone

addCameraToScene(name, Type, focal, center, scene, **kw)[source]

Add a camera object to the scene

  • overwrited by children class for each host

>>> sc = helper.getCurrentScene()
>>> center=[0.,-12.,40.]
>>> cam = helper.addCameraToScene("cam1","persp",30.,center,sc)

@type name: string @param name: name of the camera @type Type: cameraType @param Type: perspective, orthogonale etc… @type focal: float @param focal: the focal of the camera @type center: list @param center: the position of the camera @type scene: host scene @param scene: the scene #we add a **kw for futur arguments

addConstraint(obj, type='spring', target=None, **kw)[source]

Add a constraint to the given object

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

addLampToScene(name, Type='Area', rgb=[1.0, 1.0, 1.0], dist=25.0, energy=1.0, soft=1.0, shadow=False, center=[0.0, 0.0, 0.0], scene=None, **kw)[source]

Add a light to the scene

  • overwrited by children class for each host

>>> sc = helper.getCurrentScene()
>>> center=[0.,-12.,40.]
>>> color = [1.,1.,1.]
>>> light = helper.addLampToScene("light1","Sun",color,20.,1.0,1.0,True,center,sc)

@type name: string @param name: name of the instance @type Type: light hostType/int etc.. @param Type: the light type : spot,sun,omni,etc.. @type rgb: list of int 0-255 @param rgb: color of the light in rgb @type dist: float @param dist: light distance of attenuation @type energy: float @param energy: intensity of the light @type soft: bool @param soft: soft light @type shadow: boolean @param shadow: does the light produce shadow @type scene: host scene @param scene: the scene #we add a **kw for futur arguments

addMaterial(name, color, **kw)[source]

Add a material in the current document

  • overwrited by children class for each host

@type name: string @param name: the material name @type color: array @param color: the material color (r,g,b)

@rtype: hostMaterial @return: the new material

addMaterialFromDic(dic)[source]

Add material to the current scene given a dictionary {“name”:[r,b,g]}

>>> matDic={"mat1":[0,0,0],"mat2":[1,1,1]}
>>> helper.addMaterialFromDic(matDic)

@type dic: Dictionary @param dic: the name:color dictionary for creating materials

addMeshEdge(obj, edge_vertices_indices, **kw)[source]

Set the edge for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to add the edge @type edge_vertices_indices: array<int> @param edge_vertices_indices: list of edge vertices indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

addMeshEdges(obj, edges_vertices_indices, **kw)[source]

Add the edges selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to add the edges @type edge_vertices_indices: list<array<int>> @param edge_vertices_indices: list of edges vertices indices @type kw: dictionary @param kw: dictionary of arg options

addMeshFace(obj, face_vertices_indices, **kw)[source]

Add the face for the given face

  • overwrited by children class for each host

@type obj: hostObject @param obj: the object from which we want to add the face @type vertices_indices: array<int> @param vertices_indices: list of vertices indices @type kw: dictionary @param kw: dictionary of arg options

addMeshFaces(obj, faces_vertices_indices, **kw)[source]

Add the faces for the given mesh data

  • overwrited by children class for each host

@type obj: hostObject @param obj: the object from which we want to add the faces @type faces_vertices_indices: list<array<int>> @param faces_vertices_indices: list of faces vertices indices @type kw: dictionary @param kw: dictionary of arg options

addMeshVertice(poly, vertice_coordinate, **kw)[source]

Add the vertice for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to add the vertice @type vertice_coordinate: list<float>[3] @param vertice_coordinate: x y z coordinate for the new vertice @type kw: dictionary @param kw: dictionary of arg options

addMeshVertices(poly, vertices_coordinates, vertices_indices=None, **kw)[source]

Add the vertices for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to add the vertices @type vertices_coordinates: list<float>[3] @param vertices_coordinates: x y z coordinates for all vertice or vertices_indices @type kw: dictionary @param kw: dictionary of arg options

addObjectToScene(doc, object, parent=None, centerRoot=True, rePos=None)[source]

Insert/add an object to the current document under the specified parent, and at the specified location. This function is used by all the basic object creation function.

  • overwrited by children class for each host

@type doc: hostScene @param doc: the scene where to insert the object @type object: hostObject @param object: the object to insert @type parent: hostObject @param parent: the parent of the object to insert under @type centerRoot: boolean @param centerRoot: if the object have to be recentered according the top-level @type rePos: list @param rePos: the location of the object in the scene

advance_randpoint_onsphere(radius, marge=3.141592653589793, vector=None)[source]
angle_between_vectors(v0, v1, directed=True, axis=0)[source]

Return the angle between vectors.

If directed is False, the input vectors are interpreted as undirected axes, i.e. the maximum angle is pi/2.

>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3])
>>> numpy.allclose(a, math.pi)
True
>>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3], directed=False)
>>> numpy.allclose(a, 0)
True
>>> v0 = [[2, 0, 0, 2], [0, 2, 0, 2], [0, 0, 2, 2]]
>>> v1 = [[3], [0], [0]]
>>> a = angle_between_vectors(v0, v1)
>>> numpy.allclose(a, [0., 1.5708, 1.5708, 0.95532])
True
>>> v0 = [[2, 0, 0], [2, 0, 0], [0, 2, 0], [2, 0, 0]]
>>> v1 = [[0, 3, 0], [0, 0, 3], [0, 0, 3], [3, 3, 3]]
>>> a = angle_between_vectors(v0, v1, axis=1)
>>> numpy.allclose(a, [1.5708, 1.5708, 1.5708, 0.95532])
True
animationStart(doc=None, forward=True, duration=None, **kw)[source]

Play frame for a specifiy duration

@type doc: document/scene @param doc: the desired scene @type duration: float @param duration: how long shoud we play @type forward: bool @param forward: toggle the direction of the animation @type kw: dictionary @param kw: dictionary of arg options

animationStop(doc=None, **kw)[source]

Stop the animation

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

armature(name, coords, **kw)[source]

Create an armature along the given coordinates

  • overwrited by children class for each host

@type name: string @param name: name of the armature object @type coords: list of array xyz @param coords: coordinate foreach bone @type kw: dictionary @param kw: dictionary of arg options

@rtype: host Object,list of bone @return: the created armature and the created bones

assignMaterial(object, matname, texture=True, **kw)[source]

Assign the provided material to the object

  • overwrited by children class for each host

@type object: hostApp object @param object: the object @type matname: string @param matname: the material name @type texture: Boolean @param texture: is the material use a textue @type kw: dictionary @param kw: additional keywords options

assignNewMaterial(matname, color, type, object)[source]
box(name, center=[0.0, 0.0, 0.0], size=[1.0, 1.0, 1.0], cornerPoints=None, visible=1, **kw)[source]

Create a hostobject of type cube.

  • overwrited by children class for each host

@type name: string @param name: name of the box @type center: array @param center: the center of the box @type size: array @param size: the size in x y z direction @type cornerPoints: array list @param cornerPoints: the upper-left and bottom right corner point coordinates @type visible: booelan @param visible: visibility of the cube after creation (deprecated) @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject,hostMesh @return: the created box object and mesh

changeColor(obj, colors, perVertex=False, proxyObject=True, doc=None, pb=False, facesSelection=None, faceMaterial=False)[source]

Apply the given set of color to the given object, if the object is a mesh this function handle the color per vertex.

  • overwrited by children class for each host

@type obj: string or hostObject @param obj: the object to be colored @type colors: list @param colors: the list of colors to apply [[r,g,b],[r,g,b],…] @type perVertex: Boolean @param perVertex: is it color per Vertex @type proxyObject: Boolean @param proxyObject: special keyword for Cinema4D which doesnt support vertex color @type doc: Scene @param doc: the current working documents @type pb: Boolean @param pb: use the progress bar @type facesSelection: liste @param facesSelection: only assign color to the given face selecion @type faceMaterial: Boolean @param faceMaterial: assign color per Face

changeMaterialProperty(material, **kw)[source]

Change a material properties.

  • overwrited by children class for each host

@type material: string/Material @param material: the material to modify @type kw: dictionary @param kw: propertie to modify with new value

  • color

  • specular

changeObjColorMat(obj, color)[source]

Change the diffuse color of the object material.

  • overwrited by children class for each host

@type obj: string or hostObject @param obj: the object forwhich we want to change e material color @type color: list @param color: the new color to apply [r,g,b]

checkIsMesh(name)[source]

Verify that name correspond to a valid mesh.

  • overwrited by children class for each host

@type name: string @param name: the name of the deired mesh

@rtype: hostMesh @return: the mesh

checkName(name)[source]

Check the provide name to avoid invalid caracter for the host. ie maya didnt support object name starting with number, and automatically rename the object. In order to retrieve the object use this functon. If a invalid caracter is found, the caracter is removed. This function can be change in the features, as it currently only look for number.

>>> name = "1sphere"
>>> sphere_obj,sphere_mesh = helper.Sphere(name)
>>> print (sphere_obj,sphere_mesh)#in maya
(u'sphere', u'makeNurbSphere1')
>>> corrected_name  = helper.checkName(name)
>>> print (corrected_name)
sphere
>>> sphere = helper.getObject(name)
>>> print (sphere)
sphere

@type name: string @param name: name of the molecule. @rtype: string @return: corrected name of the molecule.

colorMaterial(mat, col)[source]

Color a given material using the given color (r,g,b).

  • overwrited by children class for each host

@type mat: hostMaterial @param mat: the material to change @type col: array @param col: the color (r,g,b)

colorObject(obj, color, **options)[source]

Apply the given color to the given object,

  • overwrited by children class for each host

@type obj: string or hostObject @param obj: the object to be colored @type color: list @param color: the color to apply [r,g,b] @type options: Dictionary @param options: additional keyword options :

useMaterial : crete a materal with the given color and assign it to the object useObjectColors : change the color propertie of the object (Viewport)

combineDaeMeshData(data, transform=True)[source]
concatObjectMatrix(object, matrice, hostmatrice=None)[source]

Apply a matrix to an hostObject

  • overwrited by children class for each host

@type object: hostObject @param object: the object who receive the transformation @type hostmatrice: list/Matrix @param hostmatrice: transformation matrix in host format @type matrice: list/Matrix @param matrice: transformation matrix in epmv/numpy format

constraintLookAt(object)[source]

Cosntraint an hostobject to look at the camera.

  • overwrited by children class for each host

@type object: Hostobject @param object: object to constraint

convertColor(col, toint=True)[source]

This function will convert a color array [r,g,b] from range 1-255 to range 0.-1 (vice/versa)

@type col: array @param col: the color [r,g,b] @type toint: boolean @param toint: way of the convertion, if true convert to 1-255, if false convert to range 0-1

@rtype: array @return: the converted color [0-1.,0-1.,0-1.] or [1-255,1-255,1-255]

createColorsMat()[source]

Create a Material for all defined colors in upy.colors

@rtype: list @return: the list of the new colors material

createMaterial(name, color, type='Phong', **kw)[source]
createSpring(name, targetA=None, tragetB=None, rlength=0.0, stifness=1.0, damping=1.0, parent=None, **kw)[source]

Create a sprin between two physics objects

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

createsNmesh(name, vertices, vnormals, faces, smooth=False, material=None, proxyCol=False, color=[[1, 0, 0]], **kw)[source]

Function that generate a Polygon object from the given vertices, face and normal. material or color can be passed and apply to the created polygon. Return the object and the mesh.

  • overwrited by children class for each host

@type name: string @param name: name of the pointCloud @type vertices: list @param vertices: the list of vertices @type vnormals: list @param vnormals: the list of vertices normal @type faces: list @param faces: the list of normal @type smooth: string @param smooth: smooth the mesh or not @type material: hostMaterial @param material: the material to apply to the mesh object @type proxyCol: Boolean @param proxyCol: special option for C4D DEPRECATED @type color: list @param color: color to apply to the mesh object @type kw: dictionary @param kw: dictionary of arg options, ie :

‘parent’ hostAp parent object

@rtype: hostObj/hostMesh @return: the polygon object and data

deleteChildrens(obj)[source]

Delete recursively all the children of the given object.

@type obj: hostObject @param obj: the object for which we want to delete the childs

deleteMeshEdges(poly, edges=None, select=False, **kw)[source]

Delete the give edges indices

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to delete the edges @type faces: array<int> @param faces: list of edges indices or None for all @type select: Boolean @param select: delete selected faces @type kw: dictionary @param kw: dictionary of arg options

deleteMeshFaces(poly, faces=None, select=False, **kw)[source]

Delete the give faces indices

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to delete the faces @type faces: array<int> @param faces: list of faces indices or None for all @type select: Boolean @param select: delete selected faces @type kw: dictionary @param kw: dictionary of arg options

deleteMeshVertices(poly, vertices=None, select=False, **kw)[source]

Delete the give vertices indices

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to delete the vertices @type faces: array<int> @param faces: list of vertices indices or None for all @type select: Boolean @param select: delete selected faces @type kw: dictionary @param kw: dictionary of arg options

dihedral(v1, v2, v3, v4)[source]

Returns a float value for the dihedral angle between the four vectors. They define the bond for which the torsion is calculated (~) as: V1 - V2 ~ V3 - V4 The vectors vec1 .. vec4 can be array objects, lists or tuples of length three containing floats. For Scientific.geometry.Vector objects the behavior is different on Windows and Linux. Therefore, the latter is not a featured input type even though it may work.

If the dihedral angle cant be calculated (because vectors are collinear), the function raises a DihedralGeometryError

dodecahedron(radius)[source]

Create the mesh data of a dodecahedron of a given radius

@type radius: float @param radius: radius of the embeding sphere

@rtype: array @return: vertex,face, face normal of the dodecahedron

drawGradientLine(imdraw, col1, col2, col3, xys)[source]

Draw and color a gradient using either PIL rectangle or point drawing methods

drawPtCol(imdraw, color, uv, debug=0)[source]

Draw on the given Texture image accordinge en UV coordinates and colors uv is the 3 vertex coordinate in UV

dupliVert = False
eulerToMatrix(euler)[source]

Code from ‘http://www.euclideanspace.com/maths/geometry/rotations/conversions/’.

This conversion uses NASA standard aeroplane conventions as described on page: ‘http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm

Coordinate System: right hand

Positive angle: right hand

Order of euler angles: heading first, then attitude, then bank

matrix row column ordering:

[m00 m01 m02]

[m10 m11 m12]

[m20 m21 m22]

>>> euler = [0.8,3.14,2.0]#radians
>>> emat = helper.eulerToMatrix(euler)
>>> print emat
[[-0.69670582573323303, 0.65275180908484898, -0.29751650059422086, 0.0],
 [0.0015926529164868282, 0.41614630875957009, 0.90929627358879683, 0.0],
 [0.71735518109654839, 0.6330381706044601, -0.29097116474265428, 0.0],
 [0.0, 0.0, 0.0, 1.0]]

@type euler: 3d array @param euler: the euler angle to convert in matrice

@rtype: 4x4array @return: the matrix computed from the euler angle

fillTriangleColor(array, col1, col2, col3, xys)[source]

Draw and color a Triangle according a color per corner.

Interpolate the color as OpenGL will do with per vertex

findClosestPoint(point, object, transform=True)[source]

Find the closest vertices to the given 3d points in Python implementation

@type point: 3 points @param point: the point to look up @type object: hostObj/hostMesh/String @param object: the object to scan for closest vertices @type transform: Boolean @param transform: take in account the object transformation or not

@rtype :list @return : the minimal distance found and the closest vertices in the given polygon

fit_view3D()[source]

Function that should recenter the viewport to the object in the scene.

  • overwrited by children class for each host

frameAdvanced(doc=None, duration=None, display=False, cb=None, **kw)[source]

Play frame for a specifiy duration with/without display and with/without a callbac

@type doc: document/scene @param doc: the desired scene @type duration: float @param duration: how long shoud we play @type display: bool @param display: toggle the update of the viewport @type cb: function @param cb: the callback function to execute at every frame @type kw: dictionary @param kw: dictionary of arg options

getA(pt1, pt2)[source]
getAllMaterials()[source]

Get all the maerials of the current scene.

  • overwrited by children class for each host

@rtype: list @return: the list of all materials available

getAngleAxis(vec1, vec2)[source]

Return angle (radians) and axis of rotation between two given vectors.

getBoxSize(name, **kw)[source]

Return the current size in x, y and z of the given Box if applcable

  • overwrited by children class for each host

@type name: hostObject @param name: the Box name

@rtype: 3d vector/list @return: the size in x y and z

getCenter(coords)[source]

Get the center from a 3d array of coordinate x,y,z.

@type coords: liste/array @param coords: the coordinates

@rtype: list/array @return: the center of mass of the coordinates

getCornerPointCube(obj)[source]

Return the corner Point of the Given Cube/Box

@type obj: string @param obj: name of the box

@rtype: array 2x3 @return: the upper-left and bottom right corner point coordinates

classmethod getCurrentScene()[source]

Return the current/active working document or scene.

  • overwrited by children class for each host

>>> sc = helper.getCurrentScene()
>>> print (sc)
None #in maya there is no scene concept
<bpy_strct, Scene("Scene")  #blender 2.6
[Scene "Scene"]             #blender 2.49b
<c4d.documents.BaseDocument object at 0x246c01a0>  #Cinema4D

@rtype: scene @return: the active scene

classmethod getCurrentSceneName()[source]

Return the current/active working document or scene name.

  • overwrited by children class for each host

>>> scname = helper.getCurrentSceneName()
>>> print (scname)
None        #maya
Scene       #blender 2.6
Scene       #blender 2.49b
Untitled    #Cinema4D

@rtype: strng @return: the active scene name

getCurrentSelection()[source]

Return the current/active selected object in the document or scene.

  • overwrited by children class for each host

>>> liste_objects = helper.getCurrentSelection()
>>> print (liste_objects)
[<c4d.BaseObject object at 0x1e4fd3a0>, <c4d.BaseObject object at 0x1e4fd3d0>] #cinema4D

@rtype: liste @return: the list of selected object

getFace(hostface, r=True, **kw)[source]

Convert the face edge in python format

  • overwrited by children class for each host

@type hostface: hostFace @param hostface: the face to convert to python @type kw: dictionary @param kw: dictionary of arg options.

  • r=True : Cinema4D reverse face order

@rtype: list @return: the face in python format [i,j,k]

getFaceEdges(poly, faceindice, selected=False, **kw)[source]

Get the edges of the given face object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the edges of the face @type faceindice: int @param faceindice: the face indice @type selected: Boolean @param selected: return only the selected edges or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list @return: all or selected edges of the given face

getFaceNormalsArea(vertices, faces)[source]

compute the face normal of the compartment mesh

getFaces(object, selected=False, **kw)[source]

Get the faces of the given polygon object data

  • overwrited by children class for each host

@type object: hostObject @param object: the object from which we want the faces @type selected: Boolean @param selected: return only the selected faces or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list @return: all or selected faces of the given object

getFacesfromV(vindice, faces)[source]
getImage(img, draw, sizex, sizey)[source]
getLayers(scn)[source]

Return a list of active layers of a scene or an object

getMasterInstance(instance, **kw)[source]

Return the object use for the instanciation

getMaterial(name)[source]

Get the maerial of the given name.

  • overwrited by children class for each host

@type name: string @param name: the name of the desired material

@rtype: hostMaterial @return: the new material

getMaterialProperty(material, **kw)[source]

Get a material properties.

  • overwrited by children class for each host

@type material: string/Material @param material: the material to modify @type kw: dictionary @param kw: propertie to modify with new value

  • color

  • specular

getMesh(name)[source]

Get the mesh of given name

  • overwrited by children class for each host

@type name: string @param name: the name of the deired mesh

@rtype: hostMesh @return: the mesh

getMeshEdge(hostedge, **kw)[source]

Convert the host edge in python format

  • overwrited by children class for each host

@type hostedge: hostEdge @param hostedge: the edge to conver to python @type kw: dictionary @param kw: dictionary of arg options

@rtype: list @return: the edge in python format

getMeshEdges(poly, selected=False, **kw)[source]

Get the edges of the given polygon object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the edges @type selected: Boolean @param selected: return only the selected edges or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list @return: all or selected edges of the given object

getMeshFaces(poly, selected=False, **kw)[source]

Get the faces of the given polygon object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the faces @type selected: Boolean @param selected: return only the selected faces or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list @return: all or selected faces of the given object

getMeshNormales(poly, selected=False, **kw)[source]

Get the normals of the given polygon object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the normals @type selected: Boolean @param selected: return only the selected normals or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list of array xyz @return: coordinate for all or for selected normals of the given object

getMeshVertice(poly, vertex_indice, **kw)[source]

Get the vertices of the given polygon object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the vertices @type vertex_indice: int @param vertex_indice: return only the give vertice coordinates @type kw: dictionary @param kw: dictionary of arg options

@rtype: list of float xyz @return: coordinate for one vertice of the given object

getMeshVertices(poly, selected=False, **kw)[source]

Get the vertices of the given polygon object data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want the vertices @type selected: Boolean @param selected: return only the selected vertices or not @type kw: dictionary @param kw: dictionary of arg options

@rtype: list of array xyz @return: coordinate for all or for selected vertices of the given object

getName(object)[source]

Return the name of an host object. Redundant with getObjecName

  • overwrited by children class for each host

>>> obj = helper.Sphere("mySphere")
>>> name = helper.getObjectName(obj)
>>> print (name)
mySphere

@type object: hostObject @param object: an host object @rtype: string @return: the name of the host object

getObject(name)[source]

Retrieve an object from his name.

  • overwrited by children class for each host

>>> oname = "mysphere"
>>> object= helper.getObject(oname)
>>> print oname,object#the result depnds on the host
mysphere <c4d.BaseObject object at 0x1e4fc4b0> # Cinema4D
mysphere    # Maya

@type name: string @param name: request name of an host object

@rtype: hostObject @return: the object with the requested name or None

getObjectName(o)[source]

Return the name of an host object.

  • overwrited by children class for each host

>>> obj = helper.Sphere("mySphere")
>>> name = helper.getObjectName(obj)
>>> print (name)
mySphere

@type o: hostObject @param o: an host object @rtype: string @return: the name of the host object

getOrder(distu, uv)[source]
getParticles(name, **kw)[source]

Return a particle system along the given name

  • overwrited by children class for each host

@type name: string @param name: name of the particle system @type kw: dictionary @param kw: dictionary of arg options

@rtype: host Object particle data @return: the created particle

getParticulesPosition(PS=None, **kw)[source]

Get the particle position of a particle system

  • overwrited by children class for each host

@type PS: Particle object @param PS: the particle system @type kw: dictionary @param kw: dictionary of arg options

@rtype: list of array xyz @return: coordinate foreach particle

getPosUntilRoot(object)[source]

Go through the hierarchy of the object until reaching the top level, increment the position to get the transformation due to parents. DEPRECATED

@type object: hostObject @param object: the object

@rtype: list @return: the cumulative translation along the parenting hierarchy

getProperty(obj, key)[source]

Return the property “key” of the object obj

  • overwrited by children class for each host

@type obj: host Obj @param obj: the object that contains the property @type key: string @param key: name of the property

@rtype : int, float, str, dict, list @return : the property value

getPropertyObject(obj, key=['radius'])[source]

Return the property “key” of the object obj

  • overwrited by children class for each host

@type obj: host Obj @param obj: the object that contains the property @type key: string @param key: name of the property

@rtype : int, float, str, dict, list @return : the property value

getScale(name, absolue=True, **kw)[source]

Return the current scale of the given object in absolute or local world

  • overwrited by children class for each host

@type name: hostObject @param name: the object name @type absolue: Boolean @param absolue: absolute or local transformation

@rtype: 3d vector/list @return: the scale

getSize(name, **kw)[source]

Return the current size in x, y and z of the given object if applcable

  • overwrited by children class for each host

@type name: hostObject @param name: the object name

@rtype: 3d vector/list @return: the size in x y and z

getTranslation(name, absolue=True, **kw)[source]

Return the current position (translation) of the given object in absolute or local world

  • overwrited by children class for each host

@type name: hostObject @param name: the object name @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

@rtype: 3d vector/list @return: the position

getTubeProperties(coord1, coord2)[source]

From two point return the length, and the orientation from one to another. This function is used to build a cylinder from two points (see oneCylinder function)

>>> coord1 = [1.0,0.0,0.0]
>>> coord2 = [2.0,0.0,0.0]
>>> distance,rsz,rz,coord = helper.getTubeProperties(coord1,coord2)
>>> helper.setTransformation(obj,trans=coord,scale=[1., 1., distance],
                       rot=[0.,rz,rsz])

@type coord1: vector @param coord1: first point @type coord2: vector @param coord2: second point

@rtype: tupple @return: length, orientation (rotation XY,Z), and intermediate point OR

length and matrix of transformation (see getTubePropertiesMatrix that use numpy)

getTubePropertiesMatrix(coord1, coord2)[source]

From two point return the length, and the orientation from one to another. This function is used to build a cylinder from two points (see oneCylinder function)

>>> coord1 = [1.0,0.0,0.0]
>>> coord2 = [2.0,0.0,0.0]
>>> distance,matrix = helper.getTubePropertiesMatrix(coord1,coord2)
>>> helper.setObjectMatrix(obj,matrix)

@type coord1: vector @param coord1: first point @type coord2: vector @param coord2: second point

@rtype: tupple @return: length, 4*4 matrix of rotation

getUV(object, faceIndex, vertexIndex, perVertice=True)[source]

Return the UV coordinate of the given object according faceIndex and vertexIndex

  • overwrited by children class for each host

@type object: string/hostObject @param object: the object from which we want the UV @type faceIndex: list @param faceIndex: the liste of face index for which we want the UV @type vertexIndex: list @param vertexIndex: the liste of vertex index for which we want the UV @type perVertice: Boolean @param perVertice: UV coordinate access per verticer or per face

@rtype: list @return: the list of UV coordinates for the given object according faceIndex and vertexIndex

getUVs()[source]

Reset the Progress Bar, using value

  • overwrited by children class for each host

getVisibility(obj, editor=True, render=False, active=False)[source]

return the editor/renedring/active visibility state of the given object

  • overwrited by children class for each host

@type obj: hostObject @param obj: the object @type editor: boolean @param editor: request editor visibility @type render: boolean @param render: request rendering visibility @type active: boolean @param active: request active states ie C4D

@rtype: bool/array of bool @return: the current visibility state of the object

get_noise(point, ntype, nbasis, dimension=1.0, lacunarity=2.0, offset=1.0, octaves=6, gain=1.0, **kw)[source]
hexahedron(radius)[source]

Create the mesh data of a hexahedron of a given radius

@type radius: float @param radius: radius of the embeding sphere

@rtype: array @return: vertex,face, face normal of the hexahedron

icosahedron(radius)[source]

Create the mesh data of a icosahedron of a given radius

@type radius: float @param radius: radius of the embeding sphere

@rtype: array @return: vertex,face, face normal of the icosahedron

instancesToCollada(parent_object, collada_xml=None, instance_node=True, **kw)[source]
isSphere(obj)[source]
makeTexture(object, filename=None, img=None, colors=None, sizex=0, sizey=0, s=20, draw=True, faces=None, invert=False)[source]

Experiment for baking faces colors using a PIL image

matrixToFacesMesh(name, matrices, vector=[0.0, 1.0, 0.0], transpose=True, **kw)[source]

convert liste of matrix (rotation/position) to quad mesh in order to use cloner / dupliFace

matrixToVNMesh(name, matrices, vector=[0.0, 1.0, 0.0], transpose=True, **kw)[source]

convert liste of matrix (rotation/position) to point mesh in order to use cloner / dupliVert

measure_distance(c0, c1, vec=False)[source]

measure distance between 2 point specify by x,y,z c0,c1 should be Numeric.array

>>> a = [1.0,3.0,5.0]
>>> b = [5.0,1.0,2.0]
>>> distance = helper.measure_distance(a,b)
>>> distance, vector_a_to_b = helper.measure_distance(a,b)

@type c0: vector @param c0: the first 3d vector @type c1: vector @param c1: the second 3d vector @type vec: Boolean @param vec: if the function return the vector c1-c0 @rtype: float ? vector @return: the distance, and optionly the distance vetor

metaballs(name, listePt, listeR, **kw)[source]

Create a metaballs along the given coordinates

  • overwrited by children class for each host

@type name: string @param name: name of the metaballs object @type listePt: list of array xyz @param listePt: coordinate foreach bone @type listeR: list of float @param listeR: radius foreach ball @type kw: dictionary @param kw: dictionary of arg options

@rtype: host Object,list of bone/metaball data @return: the created metaballs,the created ball

newEmpty(name, location=None, parentCenter=None, **kw)[source]

Create a new Null/Empty Object

  • overwrited by children class for each host

>>> empty = helper.newEmpty("null1",location=[10.0,0.0,0.0])
>>> empty_child = helper.newEmpty("null2",location=[15.0,0.0,0.0],parent = empty)

@type name: string @param name: name of the empty @type location: list @param location: position of the null object @type parentCenter: list @param parentCenter: position of the parent object DEPRECATED

@type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

-“parent”

@rtype: hostObject @return: the null object

newInstance(name, object, location=None, hostmatrice=None, matrice=None, **kw)[source]

Create a new Instance from another Object

  • overwrited by children class for each host

>>> sph = helper.Sphere("sph1")
>>> instance_sph = helper.newInstance("isph1",sph,location = [10.0,0.0,0.0])

@type name: string @param name: name of the instance @type object: hostObject @param object: the object to inherit from @type location: list/Vector @param location: position of the null object @type hostmatrice: list/Matrix @param hostmatrice: transformation matrix in host format @type matrice: list/Matrix @param matrice: transformation matrix in epmv/numpy format @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

-“parent” -“material”

@rtype: hostObject @return: the instance object

norm(a, b, c)[source]

return the norm of the vector [a,b,c]

>>> result = helper.norm(a,b,c) #a,b,c being double

@type a: float @param a: first value of the vector @type b: float @param b: second value of the vector @type c: float @param c: third value of the vector

@rtype: float @return: the norm of the vector

normal_array(vertices, faces)[source]
normalize(A)[source]

return the normalized vector A [x,y,z]

>>> a = [1.0,3.0,5.0]
>>> a_normalized = helper.normalize(a)

@type A: vector @param A: the 3d vector @rtype: vector @return: the normalized 3d vecor

normalize_v3(arr)[source]

Normalize a numpy array of 3 component vectors shape=(n,3)

octahedron(radius)[source]

Create the mesh data of a octahedron of a given radius

@type radius: float @param radius: radius of the embeding sphere

@rtype: array @return: vertex,face, face normal of the octahedron

oneMetaBall(metab, rad, coord, **kw)[source]

Add one ball to a metaball object. Optional function for creation of the metaball

  • overwrited by children class for each host

@type metab: metaball host data @param metab: the metaball @type rad: float @param rad: radius for the new ball @type coord: array xyz @param coord: coordinate of the ball @type kw: dictionary @param kw: dictionary of arg options

@rtype: ball/None @return: the ball or None

particle(name, coords, group_name=None, radius=None, color=None, hostmatrice=None, **kw)[source]

Create a particle system along the given coordinates

  • overwrited by children class for each host

@type name: string @param name: name of the particle system @type coords: list of array xyz @param coords: coordinate foreach particle @type radius: list of float @param radius: radius foreach particle @type kw: dictionary @param kw: dictionary of arg options

@rtype: host Object,list of bone/metaball data @return: the created metaballs,the created ball

pathDeform(*args, **kw)[source]

Should create a modifierfor the given object using the given path/curve/spline TO DO.

  • overwrited by children class for each host

@type args: list @param args: list of arguments options @type kw: dictionary @param kw: dictionary of arguments options

plane(name, center=[0.0, 0.0, 0.0], size=[1.0, 1.0], cornerPoints=None, visible=1, **kw)[source]

Create a hostobject of type cube.

  • overwrited by children class for each host

@type name: string @param name: name of the plane @type center: array @param center: the center of the plane @type size: array @param size: the size in x y z direction @type cornerPoints: array list @param cornerPoints: the upper-left and bottom right corner point coordinates @type visible: booelan @param visible: visibility of the plane after creation (deprecated) @type kw: dictionary @param kw: list of additional arguments : “material”, subdivision”, axis”

@rtype: hostObject,hostMesh @return: the created plane object and data

progressBar(progress, label)[source]

Update the progress bar status by progress value and label string

  • overwrited by children class for each host

@type progress: Int/Float @param progress: the new progress @type label: string @param label: the new message to put in the progress status

randpoint_onsphere(radius, biased=None)[source]

Generate a random point on the outside of a sphere.

>>> r = 2.0
>>> bias = 2.0
>>> point = helper.randpoint_onsphere(r)
>>> point2 = helper.randpoint_onsphere(r,bias)

@type radius: float @param radius: the radius of the sphere @type biased: float @param biased: optional float vale to use instead of the random function

@rtype: vector @return: a random 3d point on the sphere of the given radius

-points (x,y,z) so that (x-a)^2 +(y-b)^2 + (z-c)^2 = R^2

-To generate a random point on the sphere, it is necessary only to generate two random numbers, z between -R and R, phi between 0 and 2 pi, each with a uniform distribution.

To find the latitude (theta) of this point, note that z=R*sin(theta), so theta=sin-1(z/R); its longitude is (surprise!) phi.

In rectilinear coordinates, tetha = asin-1(z/R) x=R*cos(theta)*cos(phi), y=R*cos(theta)*sin(phi), z=R*sin(theta)= (surprise!) z.

-hemispher theta (0 <= theta < 360) and phi (0 <= phi <= pi/2) x = cos(sqrt(phi)) cos(theta) y = cos(sqrt(phi)) sin(theta) z = sin(sqrt(phi)) A whole sphere is obtained by simply randomising the sign of z.

-Azimuth axis is X axis. The elevation angle is measured as the angle between the Z-axis pointing upwards and the radius vector. From elementary spherical geometry: X coordinate=r*cos(pi/2-el)*cos(az) Y coordinate=r*cos(pi/2-el)*sin(az) Z Coordinate=r*sin(pi/2-el)

raycast(obj, point, direction, length, **kw)[source]
reParent(objs, parent)[source]

Change the object parent using the specified parent objects

  • overwrited by children class for each host

@type objs: hostObject @param objs: the object or liste of objects to be reparented @type parent: hostObject @param parent: the new parent object

read(filename, **kw)[source]
readMeshFromFile(filename)[source]

Given the DejaVu filename return the mesh data (vertices, faces, normal).

Parse two files : filename.indpolvert and filename.indpolface

@type filename: string @param filename: the destinaon filename.

@rtype :list @return : the liste of vertices,faces and normals

recalc_normals(obj, **kw)[source]

Recalcul normals mesh outside/inside

  • overwrited by children class for each host

@type poly: hostObj @param poly: the object to change the normal @type kw: dictionary @param kw: dictionary of arg options

reporthook(count, blockSize, totalSize)[source]
rerieveAxis(axis)[source]

Return the axis from the given array (X,Y or Z +/-).

@type axis: list @param axis: the aray [x,y,z]

@rtype: string @return: the axis of the array

resetProgressBar(value=None)[source]

Reset the Progress Bar, using value

  • overwrited by children class for each host

resetTransformation(object, **kw)[source]

ReSet the transformation of a given Object to identity

  • can be overwriten by children class for each host

@type object: string or Object @param object: the object who receive the identity transformation

restoreEditMode(editmode=1)[source]

Restor any edit mode (if any)

retrieveColorMat(color)[source]

Retrieve a material in the current document from his color (r,g,b), if his color is defined in upy.colors

@type color: array @param color: the material color (r,g,b)

@rtype: hostMaterial @return: the material of color color

rotVectToVect(vect1, vect2, i=None)[source]

returns a 4x4 transformation that will align vect1 with vect2 vect1 and vect2 can be any vector (non-normalized)

rotateObj(object, rotation, absolue=True, **kw)[source]

Global Rotation : Rotate the object This method take a 3d array [rotation_X,rotatio_Y,rotation_Z]

  • overwrited by children class for each host

@type object: hostObject @param object: the object @type rotation: liste/array - matrice @param rotation: the new object rotation @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

rotatePoint(pt, m, ax)[source]

Rotate the point pt [x,y,z] around axe ax[0],ax[1],ax[2] by ax[3] radians, and translate by m [x,y,z].

>>> point = [1.0,2.0,0.0]
>>> trans = [5.0,0.0,0.0]
>>> axes = [1.0,0.0,0.0,math.pi]
>>> point = helper.rotatePoint(point,trans,axes)
>>> print point
[6.0, -2.0, 2.4492935982947064e-16] #[6.0, -2.0, 0.0]

@type pt: 3d vector @param pt: the 3d point to be rotated @type m: 3d vector @param m: translation to apply after rotation @type ax: 4d vector @param ax: axe of rotation ax[0],ax[1],ax[2] and angle ax[3] radians

@rtype: 3d vector @return: the transformed point

rotate_about_axis(B, theta, axis=2)[source]

from http://480.sagenb.org/home/pub/20/

Create the rotation matrix for a angle theta around the given axis, and apply it to the given point (B).

Rotation about

x-axis corresponds to axis==0,

y-axis corresponds to axis==1,

z-axis corresponds to axis==2,

classmethod rotation_matrix(angle, direction, point=None, trans=None)[source]

Return matrix to rotate about axis defined by point and direction.

>>> R = rotation_matrix(math.pi/2.0, [0, 0, 1], [1, 0, 0])
>>> numpy.allclose(numpy.dot(R, [0, 0, 0, 1]), [ 1., -1.,  0.,  1.])
True
>>> angle = (random.random() - 0.5) * (2*math.pi)
>>> direc = numpy.random.random(3) - 0.5
>>> point = numpy.random.random(3) - 0.5
>>> R0 = rotation_matrix(angle, direc, point)
>>> R1 = rotation_matrix(angle-2*math.pi, direc, point)
>>> is_same_transform(R0, R1)
True
>>> R0 = rotation_matrix(angle, direc, point)
>>> R1 = rotation_matrix(-angle, -direc, point)
>>> is_same_transform(R0, R1)
True
>>> I = numpy.identity(4, numpy.float64)
>>> numpy.allclose(I, rotation_matrix(math.pi*2, direc))
True
>>> numpy.allclose(2., numpy.trace(rotation_matrix(math.pi/2,
...                                                direc, point)))
True
classmethod saveDejaVuMesh(filename, verts=[], faces=[])[source]
classmethod saveObjMesh(filepath, vertices=[], faces=[], vnorms=[])[source]
scalar(v1, v2)[source]

calculates the scalar product of two vectors v1 and v2 are numpy.array objects. returns a float for a one-dimensional array.

scaleObj(object, absolue=True, **kw)[source]

Global Scale : scale the object by the vector scale

  • overwrited by children class for each host

@type object: hostObject @param object: the object @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

selectEdge(obj, edgeindce, select=True, **kw)[source]

Set the edge selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the edge @type edgeindce: int @param edgeindce: egde indice @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

selectEdges(obj, edges, select=True, **kw)[source]

Set the edges selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the edges @type edges: array<int> @param edges: list of edges indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

selectFace(obj, faceindce, select=True, **kw)[source]

Set the selecion status for the given face

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the face @type faceindce: int @param faceindce: the face indice @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

selectFaces(obj, faces, select=True, **kw)[source]

Set the faces selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the faces @type faces: array<int> @param faces: list of faces indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

selectVertice(poly, vertice_indice, select=True, **kw)[source]

Set the vertice selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the vertice @type vertice_indice: int @param vertice_indice: vertice indice @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

selectVertices(poly, vertices_indices, select=True, **kw)[source]

Set the vertices selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the vertices @type vertices_indices: array<int> @param vertices_indices: list of vertices indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setCurrentSelection(obj)[source]

Return the current/active selected object in the document or scene.

  • overwrited by children class for each host

>>> liste_objects = [helper.getObject("obj1"),helper.getObject("obj2")]
>>> helper.setCurrentSelection(liste_objects)

@type obj: hostObject @param obj: the object to be selected

setFrame(value, **kw)[source]

Set the current frame

@type value: int/float @param value: the desired frame @type kw: dictionary @param kw: dictionary of arg options

setKeyFrame(obj, **kw)[source]

Set a keyframe for the curret object

@type obj: hostObj @param obj: the object @type kw: dictionary @param kw: dictionary of arg options

setLayers(scn, layers)[source]

Set the layers of a scene or an object, expects a list of integers

setMeshEdge(obj, edgeindce, edge_vertices_indices, select=True, **kw)[source]

Set the edge for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to set the edge @type edgeindce: int @param edgeindce: egde indice @type edge_vertices_indices: array<int> @param edge_vertices_indices: list of edge vertices indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setMeshEdges(obj, edges_vertices_indices, edges, select=True, **kw)[source]

Set the edges selecion status for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to select the edges @type edge_vertices_indices: list<array<int>> @param edge_vertices_indices: list of edges vertices indices @type edges: array<int> @param edges: list of edges indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setMeshFace(obj, faceindce, face_vertices_indices, select=True, **kw)[source]

Set the face for the given face

  • overwrited by children class for each host

@type obj: hostObject @param obj: the object from which we want to set the face @type faceindce: int @param faceindce: the face indice @type vertices_indices: array<int> @param vertices_indices: list of vertices indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setMeshFaces(obj, faces_vertices_indices, faces=None, select=True, **kw)[source]

Set the faces for the given mesh data

  • overwrited by children class for each host

@type obj: hostObject @param obj: the object from which we want to set the faces @type faces_vertices_indices: list<array<int>> @param faces_vertices_indices: list of faces vertices indices @type faces: array<int> @param faces: list of faces indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setMeshVertice(poly, vertice_indice, vertice_coordinate, select=True, **kw)[source]

Set the vertice for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to set the vertice @type vertice_indice: int @param vertice_indice: vertice indice @type vertice_coordinate: list<float>[3] @param vertice_coordinate: x y z coordinate for vertice vertice_indice @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setMeshVertices(poly, vertices_coordinates, vertices_indices=None, select=True, **kw)[source]

Set the vertices for the given mesh data

  • overwrited by children class for each host

@type poly: hostObject @param poly: the object from which we want to set the vertices @type vertices_coordinates: list<float>[3] @param vertices_coordinates: x y z coordinates for all vertice or vertices_indices @type vertices_indices: array<int> @param vertices_indices: list of vertices indices @type select: Boolean @param select: select status @type kw: dictionary @param kw: dictionary of arg options

setName(object, name)[source]

Set the name of an host object. Redundant with getObjecName

  • overwrited by children class for each host

>>> obj = helper.Sphere("mySphere")
>>> name = "mySpinningsphere"
>>> helper.setName(obj,name)

@type object: hostObject @param object: an host object @type name: string @param name: the new name

setObjectMatrix(object, matrice, hostmatrice=None, absolue=True, **kw)[source]

Set a matrix to an hostObject

  • overwrited by children class for each host

@type object: hostObject @param object: the object who receive the transformation @type hostmatrice: list/Matrix @param hostmatrice: transformation matrix in host format @type matrice: list/Matrix @param matrice: transformation matrix in epmv/numpy format @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

setParticulesPosition(newPos, PS=None, **kw)[source]

Update he particle position of a particle system along the given new coordinates

  • overwrited by children class for each host

@type newPos: list of array xyz @param newPos: coordinate foreach particle @type PS: Particle object @param PS: the particle system @type kw: dictionary @param kw: dictionary of arg options

setProperty(obj, key, value)[source]

Create a property “key” for the object obj and set his value

  • overwrited by children class for each host

@type obj: host Obj @param obj: the object that contains the property @type key: string @param key: name of the property @type value: int, float, str, dict, list @param value: the value of the property

setPropertyObject(obj, key, value)[source]

Create a property “key” for the object obj and set his value

  • overwrited by children class for each host

@type obj: host Obj @param obj: the object that contains the property @type key: string @param key: name of the property @type value: int, float, str, dict, list @param value: the value of the property

setRigidBody(obj, shape='auto', child=False, dynamicsBody='on', dynamicsLinearDamp=0.0, dynamicsAngularDamp=0.0, massClamp=0.0, rotMassClamp=1.0, **kw)[source]

Set the curren objec as a rigid body

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

setSoftBody(obj, **kw)[source]

Set the curren object as a soft body

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

setTransformation(name, mat=None, rot=None, scale=None, trans=None, order='str', **kw)[source]

Set the transformatio of a given Object

  • can be overwriten by children class for each host

@type name: string @param name: the object who receive the transformation @type mat: list/Matrix @param mat: transformation matrix @type rot: list @param rot: rotation along [X,Y,Z] @type scale: list @param scale: scale along [X,Y,Z] @type trans: list @param trans: translation along [X,Y,Z] @type order: string @param order: order of transformation @type kw: Dictionary @param kw: additional arguemts

setTranslation(name, pos=[0.0, 0.0, 0.0], absolue=True, **kw)[source]

Return the current position (translation) of the given object in absolute or local world

  • overwrited by children class for each host

@type name: hostObject @param name: the object name @type pos: list<float> @param pos: the new position @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

setUV(object, faceIndex, vertexIndex, uv, perVertice=True)[source]

Update/Set the UV coordinate of the given object according faceIndex and vertexIndex

  • overwrited by children class for each host

@type object: string/hostObject @param object: the object from which we want to update the UV @type faceIndex: list @param faceIndex: the liste of face index for which we want to update the UV @type vertexIndex: list @param vertexIndex: the liste of vertex index for which we want to update the UV @type uv: list @param uv: the new uv coordinate [i,j] @type perVertice: Boolean @param perVertice: UV coordinate access per verticer or per face

setUVs()[source]

Reset the Progress Bar, using value

  • overwrited by children class for each host

setViewport(**kw)[source]

set the property of the viewport

  • overwrited by children class for each host

@type kw: dictionary @param kw: the list of parameter and their value to change

spline(name, points, close=0, type=1, scene=None, parent=None, **kw)[source]

This will return a hostApp spline/curve object according the given list of point.

  • overwrited by children class for each host

@type name: string @param name: name for the object @type points: liste/array vector @param points: list of position coordinate of the curve point @type close: bool/int @param close: is the curve is closed @type type: int/string @param type: ususally describe type of curve, ie : bezier, linear, cubic, etc… @type scene: hostApp scene @param scene: the current scene @type parent: hostObject @param parent: the parent for the curve @type kw: dictionary @param kw: additional keywords options

@rtype: hostObject,hostMesh @return: the created spline object and data

testForEscape()[source]

return True if ESC is press

tetrahedron(radius)[source]

Create the mesh data of a tetrahedron of a given radius

@type radius: float @param radius: radius of the embeding sphere

@rtype: array @return: vertex,face, face normal of the tetrahedron

toggle(variable, value)[source]
toggleDisplay(object, display)[source]

Toggle on/off the display/visibility/rendermode of an hostObject in the host viewport.

  • overwrited by children class for each host

>>> helper.toggleDisplay("polygone1",True)
>>> obj = helper.getObject("polygone1")
>>> helper.toggleDisplay(obj,False)

@type object: hostObject @param object: the object @type display: boolean @param display: if the object is displayed

toggleEditMode()[source]

Turn off edit mode (if any)

toggleXray(object, xray)[source]

Toggle on/off the Xray visibility of an hostObject in the host viewport. Currently not supported in Maya

  • overwrited by children class for each host

>>> helper.toggleXray("polygone1",True)
>>> obj = helper.getObject("polygone1")
>>> helper.toggleXray(obj,False)

@type object: hostObject @param object: the object @type xray: boolean @param xray: if the object is Xray displayed

translateObj(object, position, use_parent=True, absolue=True, **kw)[source]

Global Translation : Move the object to the vector position

  • overwrited by children class for each host

@type object: hostObject @param object: the object @type position: liste/array @param position: the new object position px,py,pz @type use_parent: boolean @param use_parent: if the parent position is used @type absolue: Boolean @param absolue: absolute or local transformation @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

transposeMatrix(matrice)[source]
triangulate(poly, **kw)[source]

Convert quad to triangle the selected face of the given polygon object.

  • overwrited by children class for each host

@type poly: hostObj @param poly: the object to triangulate @type kw: dictionary @param kw: dictionary of arg options

triangulateFace(f, vertices)[source]
triangulateFaceArray(faces)[source]
classmethod unit_vector(data, axis=None, out=None)[source]

Return ndarray normalized by length, i.e. eucledian norm, along axis.

>>> v0 = numpy.random.random(3)
>>> v1 = unit_vector(v0)
>>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0))
True
>>> v0 = numpy.random.rand(5, 4, 3)
>>> v1 = unit_vector(v0, axis=-1)
>>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=2)), 2)
>>> numpy.allclose(v1, v2)
True
>>> v1 = unit_vector(v0, axis=1)
>>> v2 = v0 / numpy.expand_dims(numpy.sqrt(numpy.sum(v0*v0, axis=1)), 1)
>>> numpy.allclose(v1, v2)
True
>>> v1 = numpy.empty((5, 4, 3), dtype=numpy.float64)
>>> unit_vector(v0, axis=1, out=v1)
>>> numpy.allclose(v1, v2)
True
>>> list(unit_vector([]))
[]
>>> list(unit_vector([1.0]))
[1.0]
update()[source]

Update the host viewport, ui or gl draw This function can’t be call in a thread.

  • overwrited by children class for each host

updateArmature(basename, x, listeName=None, scn=None, root=None, **kw)[source]
updateBox(box, center=[0.0, 0.0, 0.0], size=[1.0, 1.0, 1.0], cornerPoints=None, visible=1, mat=None, **kw)[source]

Update the given box.

  • overwrited by children class for each host

@type box: string @param box: name of the box @type center: array @param center: the new center of the box @type size: array @param size: the new size in x y z direction @type cornerPoints: array list @param cornerPoints: the new upper-left and bottom right corner point coordinates @type visible: booelan @param visible: visibility of the cube after creation (deprecated) @type kw: dictionary @param kw: additional keywords options

updateMasterInstance(instance, objects, add=True, hide=True, **kw)[source]

Update the reference of the passed instance by adding/removing-hiding objects

  • overwrited by children class for each host

>>> sph = helper.Sphere("sph1")
>>> instance_sph = helper.newInstance("isph1",sph,location = [10.0,0.0,0.0])

@type instance: string/hostObj @param instance: name of the instance @type objects: list hostObject/string @param objects: the list of object to remove/add to the instance reference @type add: bool @param add: if True add the objec else remove @type hide: bool @param hide: hide instead of remove @type kw: dictionary @param kw: you can add your own keyword, but it should be interpreted by all host

updateParticles(newPos, PS=None, **kw)[source]

Update the particle system along the given new coordinates. remove or add particle.

  • overwrited by children class for each host

@type newPos: list of array xyz @param newPos: coordinate foreach particle @type PS: Particle object @param PS: the particle system @type kw: dictionary @param kw: dictionary of arg options

updatePathDeform(*args, **kw)[source]

Should update the modifierfor the given object using the given path/curve/spline

TO DO.

  • overwrited by children class for each host

@type args: list @param args: list of arguments options @type kw: dictionary @param kw: dictionary of arguments options

updateSpring(spring, targetA=None, tragetB=None, rlength=0.0, stifness=1.0, damping=1.0, **kw)[source]

Update the spring control

@type doc: document/scene @param doc: the desired scene @type kw: dictionary @param kw: dictionary of arg options

updateTubeObjs(listeObj, listePts, listeInd=None)[source]

This function will update a liste of Tupe according the given liste of new points. One Tube is define by two 3d points.

update_spline(name, coords)[source]

This will update the spline points coordinates

  • overwrited by children class for each host

@type name: string @param name: name for the spline to update @type coords: liste/array vector @param coords: list of new position coordinate to apply to the curve point

vector_norm(data, axis=None, out=None)[source]

Return length, i.e. eucledian norm, of ndarray along axis.

>>> v = numpy.random.random(3)
>>> n = vector_norm(v)
>>> numpy.allclose(n, numpy.linalg.norm(v))
True
>>> v = numpy.random.rand(6, 5, 3)
>>> n = vector_norm(v, axis=-1)
>>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=2)))
True
>>> n = vector_norm(v, axis=1)
>>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=1)))
True
>>> v = numpy.random.rand(5, 4, 3)
>>> n = numpy.empty((5, 3), dtype=numpy.float64)
>>> vector_norm(v, axis=1, out=n)
>>> numpy.allclose(n, numpy.sqrt(numpy.sum(v*v, axis=1)))
True
>>> vector_norm([])
0.0
>>> vector_norm([1.0])
1.0
write(*args, **kw)[source]
classmethod writeDX(filename, gridvalue, gridcenter, gridstep, grisize, commens='')[source]
classmethod writeMeshToFile(filename, verts=None, faces=None, vnorms=[], fnorms=[])[source]

Write the given mesh data (vertices, faces, normal, face normal) in the DejaVu format. Create two files : filename.indpolvert and filename.indpolface

@type filename: string @param filename: the destinaon filename. @type verts: list @param verts: the liste of vertices @type faces: list @param faces: the liste of faces @type vnorms: list @param vnorms: the liste of vertices normal @type fnorms: list @param fnorms: the liste of faces normal

writeToFile(polygon, filename)[source]

Write the given polygon mesh data (vertices, faces, normal, face normal) in the DejaVu format.

Create two files : filename.indpolvert and filename.indpolface.

See writeMeshToFile

@type polygon: hostObj/hostMesh/String @param polygon: the polygon to export in DejaVu format @type filename: string @param filename: the destinaon filename.

cellpack.autopack.upy.hostHelper.dot(v1, v2)[source]
cellpack.autopack.upy.hostHelper.vcross(v1, v2)[source]
cellpack.autopack.upy.hostHelper.vdiff(p1, p2)[source]
cellpack.autopack.upy.hostHelper.vdistance(c0, c1)[source]

get the distance between two points c0 and c1

cellpack.autopack.upy.hostHelper.vlen(v1)[source]
cellpack.autopack.upy.hostHelper.vnorm(v1)[source]

Module contents

cellpack.autopack.upy.getHClass(host)[source]

Return the base class for modelling design according the provide host.

@type host: string @param host: name of the host application

@rtype: Class @return: the specific ui class

cellpack.autopack.upy.getHelperClass(host=None)[source]

Return the base class for modelling design according the provide host. If the host is not provide,retrieveHost() will be called to guess the host.

@type host: string @param host: name of the host application

@rtype: Class @return: the specific ui class

cellpack.autopack.upy.retrieveHost()[source]

Retrieve the 3d host application where the script is running.

@rtype: string @return: the name of the host, ie blender, maya or c4d