14.7 Removing existing objects

Since the sketch is not geometrically constrained, changing the value of any of the QW-Parameters in QW-Modeller GUI will not result in redrawing sketch with new dimensions. To redraw sketch with new, non-default parameters, it is required to reexecute the macro in the active document. However, in such case, the existing sketch and its revolution must be removed. In function definition section, we define the following function:

 

def remove_existing_objects(qwm_doc):

if hasattr(qwm_doc, "horn"):

qwm_doc.removeObject("horn")

if hasattr(qwm_doc, "Sketch_horn"):

qwm_doc.removeObject("Sketch_horn")

 

As this function removes horn and Sketch horn if the active document contains such attributes, it should be called before draw corrugated horn(). In the main code section we call both function in the following order:

 

remove_existing_objects(qwm_doc)

draw_corrugated_horn(qwm_doc)