Chapter 20-Excerpt
Chapter 20-Excerpt
Chapter 20-Excerpt
origin-list profiles)
(defun *error* ()
(cmd-out)
(vla-EndUndoMark *aevl:drawing*))
(vla-StartUndoMark *aevl:drawing*)
(cmd-in)
(if (= (getvar "WORLDUCS") 0)
(vl-cmdf "_UCS" "_W"))
(assoc-surf-data)
(setq i 0)
(repeat n
(setq origin-list (cons (* interval i) origin-list)
i (1+ i)))
(make-profiles
(reverse origin-list)
height
width
(strcat id "_PROFILE")
id)
(make-assoc-surf profiles)
(mod-constraint)
(cmd-out)
(ax-SWt)
(vla-EndUndoMark *aevl:drawing*))
Listing 20.12. Main Function C:ASSOC-SURF.
Figure 20.4.
Associative surface in the
Block Editor.
Then, why is it that its parameters are not available in the drawing? If I open the Block Edi-
tor’s Parameters Manager palette I find that those dimensional constraints appear as Dimensional
Constraint Parameters. But now we have a column titled Show that did not appear before. And
all of this column’s values are set to "No".
If I select one of the restrictions and right-click, a context menu appears (Figure 20.5) display-
ing the options Delete Parameter and Convert Parameter. If we choose this second option the
entry in the Show column changes from No to Yes.
Knowing what to do, we must now find the commands and options that nay be used for ex-
ecuting this conversion in our program. As was shown in Chapter 10, Visual LISP programs
can be executed within the Block Editor. This holds for C:ASSOC-SURF. It is in the Block
Editor where we can find the commands allowing us to create or covert the Dimensional Con-
straints into parameters. The Block Editor’s specific commands include _BCPARAMETER which
is equivalent to _DIMCONSTRAINT. These commands are practically the same. The options it
offers (see Table 20.14) can create in the Block Editor constraint parameters for every situation
where it was possible to create dimensional constraints.
For us the most interesting option is the one that converts dimensional constraints into con-
straint parameters. This option can be included in our C:ASSOC-SURF program supposing
we can detect if it is running within the Block Editor. This way we would have a more universal
program, creating a normal associative surface if we work in Model Space or creating a dy-
namic block by working in the Block Editor.
Figure 20.6. Dialog to create a new empty block with the Block Editor.
The criterion we can use to check if the program is running in the Block Editor is the value of
the BLOCKEDITOR system variable which in that case would be set to 1. We can then add an
auxiliary function that will only operate if in the block editor, automatically converting the
dimensional constraints into block dimensional parameters. This would be done by creating
a selection set of dimensional constraints following the same criteria used in Listing 20.11
that will be traversed applying to each dimensional constraint the _Convert option of the
_BCPARAMETER command.
Including a call to this function in C:ASSOC-SURF we will have a program capable of creat-
ing a normal associative surface in Model Space or a dynamic block if executed within the
Block Editor.
20.8 Summary.
We have considered in this chapter the programming options for Procedure and NURBS sur-
faces. There are no ActiveX methods for creating them and the data associated to most of their
DXF group codes is encrypted, so the only way to create them is the through the command/
vl-cmdf interface.
In the case of Procedural surfaces which are defined from linear cross-sections it is
possible to retain the association between the surface and them. The cross sections can
be assigned geometric and dimensional constraints so that they can be modified by pa-
rameters. Parameter modification can be implemented in a program. This way we can
have surfaces whose shape changes by manually or programmatically modifying these
parameters. A very practical way for using these surfaces is the creation of dynamic
blocks with the aid of the Block Editor.
The most widely used surfaces in industrial design are the NURBS surfaces. This is due
to their great advantages, which include rich interactive design capabilities and accu-
rate representation of closed shapes such as conics and quadrics. In fact, many CAD/
CAM, virtual reality, visualization and animation applications use models built with
NURBS surfaces.
The SPLINE entities explained in Chapter 14 are especially suitable for creating
NURBS surfaces. These surfaces cannot be modified through Visual LISP program-
ming. They can only be modified interactively using their control vertices and gizmos.