PDA

View Full Version : How to dynamically show/hide the imported 3D shape assigned to a VisualTool


Cliff King
09-18-2007, 04:09 PM
First of all, you need to understand that the VisualTool manages the "hideshape" switch internally. In other words, it calls the switch_hideshape() command in its internal OnPreDraw event to switch the display of its 3D shape on/off based on the current "Minimum Magnification" and "Maximum Distance" values chosen by the modeler for the VisualTool. Therefore it doesn't do any good to execute switch_hideshape() as a modeler because the object is continually switching it back to how it wants it.

Here are a few alternative ways to dynamically hide a VisualTool's "Imported Shape" using code.

1. USE A DIFFERENT OBJECT:
The easiest thing to do is use an object besides the VisualTool, then the switch_hideshape() command will be effective in hiding the 3D shape of the object. Using a BasicFR object is suggested because it has very little overhead, doesn't have any shape factors (i.e. offsets), and has a good default size of 1 X 1 X 1.

2. SET MAXIMUM DISTANCE TO ZERO:
setvarnum(object, "viewdistance", 0);

3. RENAMING THE 3D FILE REFERENCE:
setnodestr(shape(object), " _ ");
buildall();

4. SET THE SHAPE INDEX TO ZERO:
setnodenum(shapeindex(object), 0);
setnodename(shape(object)," _ ");

Four options are listed for educational purposes, but it is suggested that you use option 1 or 2.