Manage labels to tikzpy object (labels object)

Each shape, assembly… is associated with a one or more labels or layers. Using the active property of the label is possible to manage to draw or not the shapes associated with such labels and filter by them. Initially every shape is created with the label default that can be manage as any other label.

Load main tikzpy class as follow and add, edit, desactive and manage labels of the different shapes:

 1### Load tikzpy library
 2import tikzpy
 3import os, sys
 4
 5### Load main object
 6tikZ = tikzpy.load()
 7
 8### Add point at x=0, y=0, z=0
 9p0 = tikZ.pto.pto(0,0,0)
10
11### Add point at x=1, y=1, z=1
12p1 = tikZ.pto.pto(1,1,1)
13
14### Add a line for example
15l1 = tikZ.shp.line(p0, p1)
16l1.addlabel = "patatin"
17
18l2 = tikZ.shp.line(p1, p0)
19l2.addlabel = "patatan"
20
21### Labels
22print tikZ.lbl.list_active_labels(active = True)  ## Return list of active labeels
23
24tikZ.lbl["patatin"].active = False                ## Inactive a label
25
26print tikZ.lbl.list_active_labels(active = False) ## Return list of inactive labeels

and start bulding yor drawing. More examples on how to use the labels object can be found in labels examples.

Labels functions. Class -> tikzpy.lbl

class cls_labels._labels(parent)[source]

Labels class:

Platform

Unix, Windows

Synopsis

Allows to manage shapes labels. Active / hide shapes using labels and filtering shapes using labels. Shapes containing hidden labels will not be shown in the picture.

Variables

labels – return list containing all the lables

list_active_labels(active=True)[source]
Synopsis:
  • Returns a list of labels active / hide

Optional parameters:
  • active = True: True for active labels. False for hidden labels.

Returns:
  • Returns a list of labels active / hide

Note

set_all_active(active=True)[source]
Synopsis:
  • Set all labels as active / hide

Optional parameters:
  • active = True: True for active labels. False for hidden labels.

Returns:
  • None

Note

set_active_labels(value, active=True)[source]
Synopsis:
  • Set specific labels names as active / hide

Args:
  • value: label name or list of labels names

Optional parameters:
  • active = True: True for active labels. False for hidden labels.

Returns:
  • None

Note

dellabel(value)[source]
Synopsis:
  • Delete a label from all the shapes

Args:
  • value: label name or list of labels names

Returns:
  • None

Note

shapes_by_label(value)[source]
Synopsis:
  • Returns a list of shapes ids that contain a label or list of labels

Args:
  • value: label name or list of labels names

Returns:

Note

label_to_shapes(shps, value, delete_label=False)[source]
Synopsis:
  • Add / delete a label or list of labels to a shape or list of shapes

Args:
  • shps: list of shapes or single shape. Given by id or shape object.

  • value: label name or list of labels names

Optional parameters:
  • delete_label = False: True add labels. False delete labels.

Returns:
  • None

Note