pyg.pyb.pyb module

class pyg.pyb.pyb.pyb[source]

Bases: object

An object to save commands for blender 3d plotting and render

The pyb class is your blender scene, and I’ve coded in a limited set of commands for some simplified bldnder plotting. Right now, it automatically saves to “brender_01.blend/.png” in the current directory, if you can’t find the files.

boolean(left, right, operation)[source]
cone(c=(0.0, 0.0, 0.0), r1=None, r2=None, h=None, name=’cone’, color=None, direction=’z’, alpha=1.0, emis=False)[source]

cone makes a truncated cone with height h and radii r1 and r2.

cone creates a truncated cone with the center of the cone at point c, a tuple of three dimensions. Then, the base has radius r1, the tip has radius r2, and the base and tip are separated by h.

Todo

Make sure rotation works here

Parameters:
  • c (tuple) – the centerpoint of the cone
  • r1 (float) – radius of the base
  • r2 (float) – radius of the tip
  • h (float) – distance between r1 and r2
  • direction (string) – axis which coincides with the rotational axis of the cone, either 'x', 'y', or 'z'. The direction can be changed by reversing r1 and r2, so '+z' won’t work.
cutaway(c=(0.0, 0.0, 0.0), l=(0.0, 0.0, 0.0), exclude=’asdlfjkals;djkfasdlfj’)[source]
draft(i=True)[source]
emis(name=’Source’, color=’#555555’, alpha=1.0, volume=False)[source]
flat(name=’Flat’, color=’#555555’, alpha=1.0)[source]
gq(A=0.0, B=0.0, C=0.0, D=0.0, E=0.0, F=0.0, G=0.0, H=0.0, J=0.0, K=0.0, name=’gq’, color=None, alpha=1.0, emis=False)[source]

gq adds a generalized quadratic surface using the mesh.

gq adds a generalized quadratic surface using the mesh operators. The surface itself is defined by the function

\[\begin{split}Ax^{2}+By^{2}+Cz^{2}+Dxy+Eyz\\+Fzx+Gx+Hy+Jz+K=0\end{split}\]

and takes inputs of \(A\), \(B\), \(C\), \(D\), \(E\), \(F\), \(G\), \(H\), \(J\), and \(K\).

Note that this object is not necessarily closed, so it may need to be added to or subtracted from other surfaces or it will look unrealistic.

Parameters:
  • A (float) – the coefficient \(A\)
  • B (float) – the coefficient \(B\)
  • C (float) – the coefficient \(C\)
  • D (float) – the coefficient \(D\)
  • E (float) – the coefficient \(E\)
  • F (float) – the coefficient \(F\)
  • G (float) – the coefficient \(G\)
  • H (float) – the coefficient \(H\)
  • J (float) – the coefficient \(J\)
  • K (float) – the coefficient \(K\)
image(name=’Image’, fname=None, alpha=1.0, volume=False)[source]
intersect(left, right)[source]
look_at(target=None)[source]
open(blend=None)[source]
plane(x1=None, x2=None, y1=None, y2=None, z1=None, z2=None, c=None, l=None, name=’rpp’, color=None, alpha=1.0, verts=None)[source]
point(location=(0.0, 0.0, 0.0), strength=1.0, name=’Point’, color=’#555555’, alpha=1.0)[source]
rcc(c=None, r=None, h=None, name=’rcc’, color=None, direction=’z’, alpha=1.0, emis=False)[source]

makes a cylinder with center point c, radius r, and height h

Todo

Make sure rotation works here

render(camera_location=(500, 500, 300), c=(0.0, 0.0, 0.0), l=(250.0, 250.0, 250.0), render=True, fit=True, samples=20, res=[1920, 1080], draft=False, **kwargs)[source]
rpp(x1=None, x2=None, y1=None, y2=None, z1=None, z2=None, c=None, l=None, name=’rpp’, color=None, alpha=1.0, verts=None)[source]
run(filename=None, **kwargs)[source]

Opens a blender instance and runs the generated model rendering

scene_setup()[source]

deletes the default cube and sets up a scene to be used to render

pyb.scene_setup is a convenience class that creates a new scene and deletes the default cube, leaving you with a clean slate to render on. It is called automatically during initialization, so there’s no real reason that the user should ever call this.

Returns:None
set_matl(obj=None, matl=None)[source]
show()[source]

Opens the image if it has been rendered

sph(c=None, r=None, name=’sph’, color=None, alpha=1.0, emis=False)[source]
split_scene(filename)[source]
subtract(left, right)[source]
sun(strength=1.0)[source]

creates a blender sun lamp

pyb.sun creates a blender sun lamp and places it. Location is non-sensical in this context, as blender places its sun lamps infinitely far away. Strength, however, should be set, and set much lower than the strength for a point lamp.

Parameters:strength (float) – the strength of the sun lamp
Returns:pyb object with sun lamp added
trans(name=’Trans’, color=’#555555’)[source]
union(left, right)[source]