PLaSM Goes OO!

After several weeks of hard work we are proud to announce that the internals of PLaSM (NCLab’s CAD library) were rewritten to support object-oriented (OO) programming. As a result, many things got simpler. For example, to change the color of an object “obj” to “STEEL”, you can now type

COLOR(obj, STEEL)

as opposed to the previous format

obj = COLOR(obj, STEEL)

Similar simplifications take place also for the MOVE (M), ROTATE (R), ROTATERAD (RRAD) and SCALE (S) commands. There is a new command ROTATEREL (RR) that rotates objects with respect to their own center.
Working with groups of objects became much easier since they are now just Python lists. As a consequence, they can be easily decomposed into the original objects. There is a new command WELD that creates a firm bond than cannot be reversed.
New, elegant commands TOP and BOTTOM were introduced to put objects on top each other or below each other, without worrying about their size. There are also analogous commands LEFT, RIGHT, FRONT and REAR.

We implemented a new command EXTRUDE (E) that extrudes a 2D object to 3D given an extrusion height and angle.
Based on many requests, we added more predefined colors such as LIGHTRED / DARKRED, LIGHTGREEN / DARKGREEN, LIGHTBLUE / DARKBLUE etc.
The changes are not backward compatible but the good news is that your codes are easy to fix. Good source of information is the List of Commands document that is available in the Help section of the PLaSM module. All demo scripts were already transformed to support the new syntax. If you like to use the object-oriented syntax for your designs, here is the list of methods that are available for every PLaSM object. Their meaning should be self-explanatory:

setcolor(self, color = WHITE)
getcolor(self)
move(self, t1, t2, t3 = 0)
rotate(self, angle_deg, axis = 3)
rotaterel(self, angle_deg, axis = 3)
rotaterad(self, angle_rad, axis = 3)
scale(self, a, b, c = 1.0)
minx(self)
miny(self)
minz(self)
maxx(self)
maxy(self)
maxz(self)
sizex(self)
sizey(self)
sizez(self)

For illustration, the following code creates a red unit cube “a”, replicates it, changes the color of the second cube to blue, moves the new cube “b” by vector (1, 1, 1), and creates and displays a compound object that comprises both cubes:

a = CUBE(1)
a.setcolor(RED)
b = COPY(a)
b.setcolor(BLUE)
b.move(1, 1, 1)
c = UNION(a, b)
SHOW(c)

That’s it. Do not hesitate to send us an email if you have any questions!