TopMod
Python Command Reference

Object Management

load(filename)

Loads a file of either Wavefront OBJ (.obj) or DLFL (.dlfl) into the scene. The file data becomes the current object. The filetype is recognized by the extension. Filename is given as a string (e.g., "myfile.obj"). In the TopMod interface this replaces any current object loaded. In stand-alone, this pushes any current object onto the stack.

Result:
objectid
save(filename)

Saves a file of either Wavefront OBJ (.obj) or DLFL (.dlfl) from the current object. The filetype is recognized by the extension. Filename is given as a string (e.g., "myfile.obj").

Result:
wasSuccess
kill(objectid)

Kills or destroys the object represented by objectid. This is disabled when using the TopMod interface! It serves only when working in python standalone.

Result:
None
switch(objectid)

Switches the current object to the object represented by objectid. This is disabled when using the TopMod interface!. Since the interface currently only allows one object to be open at a time.

Result:
objectid

Core Operations

createVertex((x,y,z))

Creates an isolated vertex with it's point-sphere at a position specified by a 3-tuple. No edge is created. An object can be created this way. This is one of the minimal operators.

Result:
(faceid,vertexid),objectid
removeVertex(vertexid)

Removes/Deletes an isolated vertex and it's point-sphere. This is one of the minimal operators.

Result:
None
insertEdge((faceid,vertexid),(faceid,vertexid))

Inserts an edge connecting two corners. Each corner is represented by a tuple: (faceid,vertexid). When the new edge is created the input vertices become members of the same face. Since integers are immutable in Python, we must return these also.

Result:
edgeid,(faceid,vertexid),(faceid,vertexid),(faceid,vertexid),(faceid,vertexid)
deleteEdge(edgeid)

Deletes the edge represented by edgeid. When the edge is deleted then one face remains. If the deleted edge's sides belonged to two separate faces then the second one is deleted. A list (of size 1) with remaining face's ID is returned. Otherwise, if the deleted edge's sides belonged to the same face, then one new face is created. A list (of size 2) with the 2 face IDs is returned.

Result:
[faceid,...]
collapseEdge(edgeid)

Collapses the edge represented by edgeid.

Result:
vertexid
subdivideEdge([divisions,]edgeid)

Subdivides the edge represented by edgeid. By default it just subdivides it in half, but when given the optional argument divisions it subdivides the edge by that number. Then it returns a list of all the newly created vertices.

Result:
[vertexid,...]

Auxiliary Operations

extrude(type,faceid[,...])

Extrudes a face with the type of extrusions specified by a string. Valid types include:

Result:
faceid
subdivide(scheme[,...])

Subdivides the current object with the specified scheme. Each scheme has a different set of optional arguments. Valid scheme names are:

Result:
None
subdivideFace(faceid[,usequads])

Subdivide a face into n faces (where n is the number of edges of the face). By default the new faces are quadralaterals, but if specified with False, then the new faces will be triangular.

Result:
None
subdivideFaces(faceidList[,usequads])

Subdivide faces in the list into n faces (where n is the number of edges of the face). By default the new faces are quadralaterals, but if specified with False, then the new faces will be triangular. If you want to do all faces you can also Use subdivide("linear-vertex")

Result:
None
dual()

Takes the dual of the current object.

Result:
None
connectEdges((edgeid,faceid),(edgeid,faceid)[,loopCheck])

Connect two half-edges with a face. If loopCheck is True then only connect if the edges are not adjacent to their corresponding faces.

Result:
None
connectCorners((faceid,vertexid),(faceid,vertexid)[,numsegs,maxconn,'dual'])

Connect two faces given a corner from each face. Uses repeated insertEdge operations

Result:
None
connectFaces(faceid,faceid[,numsegs,maxconn])

Connect two faces with multiple segments. Intermediate points are calculated by linear interpolation based on number of segments. Maximum connections should be set to -1 when connecting all is desired

Result:
None
addHandle(interp,(faceid,vertexid),(faceid,vertexid),numsegs
[,weight1,weight2,maxconn,numtwists]
)

Create an interpolated handle. The option interp should be set to either "hermite" or "bezier" depending on the desired interpolation method. Setting the number of segments and playing with the weights and number of twists will yield different results.

Result:
None
rind(facelist,useScaling,percent[,uniform])

Create a rind model - create a crust then punch the specified faces. The percentage is a thickness parameter when useScaling is false, otherwise it is a scaling parameter.

Result:
None
wireframe([thicknes,split])

Creates a solid wireframe from the object.

Result:
None
column(thickness,segments)

Creates a solid column wireframe from the object.

Result:
None

Finding IDs

faces([selected])

Returns a tuple containing the ids of the faces. If selected is True, then only those faces selected are returned (this is the default in the TopMod interface), otherwise all the faces. Since selection is impossible in stand-alone, the default is all the faces.

Result:
(faceid,...)
edges([selected])

Returns a tuple containing the ids of the edges. If selected is True, then only those edges selected are returned (this is the default in the TopMod interface), otherwise all the edges. Since selection is impossible in stand-alone, the default is all the edges.

Result:
(edgeid,...)
verts([selected])

Returns a tuple containing the ids of the vertices. If selected is True, then only those vertices selected are returned (this is the default in the TopMod interface), otherwise all the vertices. Since selection is impossible in stand-alone, the default is all the vertices.

Result:
(vertexid,...)
corners([selected])

Returns a tuple containing 2-tuples with the ids of the faces and the ids of the vertices. If selected is True, then only those corners selected are returned (this is the default in the TopMod interface), otherwise all the corners. Since selection is impossible in stand-alone, the default is all the corners.

Result:
((faceid,vertexid),...)
walk(faceid)

This does a boundary walk around a face. The format looks like this:

DLFLFace faceid (numsides) : vertexid[backface]--(edgeid)-->.... It returns a list of vertices and a list of edges

It continues until it walks through each side of the face.

Result:
vertexlist,edgelist
cornerWalk(faceid)

Performs the boundary walk as specified by the walk above, but instead of grabbing the vertices and edges walked, it returns the corners walked. This means the result will contain the tuples with the input faceid and each vertex.

Result:
[(faceid,vertexid),...]

Object Information

printObject()

Print out object information to standard out. For example, a cube:

Number of vertices : 8
Number of faces : 6
Number of edges : 12
Number of materials : 1
Genus : 0

Result:
None
vertexInfo(vertexid)

Store information about the vertex in a dictionary. The options can be accessed by there keys like this vertexInfo(vertexid)['coords']. Valid keys are:

Result:
{'key': value}
edgeInfo(edgeid)

Store information about the edge in a dictionary. The options can be accessed by there keys like this edgeInfo(edgeid)['midpoint']. Valid keys are:

Result:
{'key': value}
faceInfo(faceid)

Store information about the face in a dictionary. The options can be accessed by there keys like this faceInfo(faceid)['centroid']. Valid keys are:

Result:
{'key': value}
cornerInfo((faceid,vertexid))

Store information about the corner in a dictionary. The options can be accessed by there keys like this cornerInfo((faceid,vertexid))['type']. Valid keys are:

Result:
{'key': value}
centroid(vertexids)

Find the centroid of a given set of vertices.

Result:
centroid

Transformations

translate(x,y,z[,relative])

Translate the current object to <x y z> if relative is False, otherwise translate by x, y & z units. Relative is true by default.

Result:
None
scale((x,y,z))

Scale the current object to <x y z>.

Result:
None
move(vertexids,(x,y,z)[,relative])

Takes a tuple containing every vertexid that is to be moved. Then translates either to <x y z> (absolute) or by x, y, & z (relative). The default is relative.

Result:
None

Return To Top