Interactive object

An interactive object is a display unit in zencad.

This section lists the types of interactive objects and specifies the methods of the corresponding base class.


Geometric interactive objects.

The interactive object engine is used to display geometric shapes processed by zencad.

Example 1 (Creating an interactive form object):

model = zencad.box(10)
scn = zencad.scene()

intobj = zencad.interactive_object(model)
scn.add(intobj)

zencad.show(scn)

Example 2 (Create an interactive form object using the disp display function):

model = zencad.box(10)

intobj = zencad.disp(model)
intobj.set_color(zencad.color.yellow)

Graphical interactive objects.

In addition to interactive objects of geometric shapes, there are interactive objects that can be used to transfer additional information on the working stage:


Arrow:

Show an arrow corresponding to the vector vec, leading from the point pnt, the size of the arrow head is determined by the arrlen parameter, the line width by the width parameter. If scene is not None, the object is immediately added to scene.

arrow(pnt, vec, clr=zencad.color.white, arrlen=5, width=1, scene=zencad.default_scene)

Line:

Show the line, between the points apnt and bpnt, line width with the width parameter. If scene is not None, the object is immediately added to scene.

line(apnt, bpnt, clr=zencad.color.white, width=1, scene=zencad.default_scene)

Methods of the interactive_object class:

Repositioning

relocate(trans)

Relocates the object to the trans position relative to its original location.

Hiding

hide(en=True/False)

Hide or re-display the object. The hidden object is not removed from memory.

Color setting

set_color(color)

# Examples:
# RGB:
intobj.set_color((0.2,0.3,0.6))
intobj.set_color(zencad.color(0.2,0.3,0.6))

# RGBA:
intobj.set_color((0.2,0.3,0.6,0.5))
intobj.set_color(zencad.color(0.2,0.3,0.6,0.5))

Change the color of the interactive object. The color parameter represents either a tuple or a zencad.color object.