**DMM Varkon ^{®} Tutorial**

A Beginner's Guide to the Varkon Parametric Modeling and CAD Application Development System

By David M. MacMillan

One of my goals in using Varkon is to create three dimensional
models framed in two-dimensional drawings -
both engineering drawings and illustrative drawings.
My first attempts to do this followed the path outlined in the
second major section of this chapter,
Section 9.2. "Method 2: By Using Projected Views."
However, in using this method I encountered difficulties with
different projections interfering with each other.
This method also relies on the persistence of views in the viewing
window (if the `rep_view()` procedure is used to repaint any
one view, all other views disappear).

To avoid these difficulties, I then experimented with the method described in the first section of this chapter, Section 9.1. "Method 1: By Positioning the Model". This method involves the use of only one projection, a "straight on" XY plane projection. In this projection, the model is instantiated multiple times in different orientations. This method requires more elaborate preparation of the model (more parameters to the model). In this method, the model is created in a local coordinate system. This coordinate system is positioned relative to the XY grid of the drawing; the model rotates itself in 3D to achieve the desired orientation. The model also does its own hidden line removal, as this must be done in 3D.

Although this method is more complex, I have found it to be a very robust method for creating multi-view drawings of 3D models.

It is of course quite likely that neither of these methods is the "right" way to do this; these are just the methods I discovered through experiment.

Because a Varkon active module does not preserve comments, and because comments are important to understanding the operation of this demo, the active module used is just a tiny one which calls the main driver for the demo:

GLOBAL DRAWING MODULE thirdangle(); BEGINMODULE part(#1,test3rd()); ENDMODULE

The code for the main driver is as follows.

! test3rd.MBS ! construct a sample third-angle projection with extra isometric view ! This module is placed in the public domain by its author, ! David M. MacMillan global drawing module test3rd( ); ! the size of the model in 3D float xsize; float ysize; float zsize; float nullsize; ! a dummy variable used once the size has been calculated ! drawing coordinates (2D window on screen) of the four views float frontx; float fronty; float topx; float topy; float rightx; float righty; float isox; float isoy; ! the space between views (2D window on screen) constant float viewspace = 2; ! the border of the drawing (2D window on screen) float xmin; float xmax; float ymin; float ymax; ! miscellaneous constants constant float norot = 0; ! do not rotate constant float nooff = 0; ! no offset constant float fullsize = 1.0; constant int hide = 1; ! do hidden line removal constant int nohide = 0; ! do not constant float isoangle = 35.266666; ! angle between the edge of an ! isometrically projected cube and ! the plane of projection (35 deg 16 min) beginmodule ! Clear the Varkon cache so that we always load new object code for ! all modules. clear_pm (); ! Clear the model, to ensure that we draw afresh. clear_gm (); ! Place the front (XY) view at left (X=0) and bottom (Y=0) ! The 3D drawing calculates its size and returns it through the VAR parameters ! xsize, ysize, zsize. frontx := 0; fronty := 0; csys_1p (#1, "front", vec (frontx, fronty), norot, norot, norot: blank=1); part (#2, boxlocal (8, 2, 4, nooff, nooff, nooff, 0, 0, 0, fullsize, nohide, xsize, ysize, zsize), #1); ! place top view at left (X=0); ! for Y, add model height in 3-space (ysize) + ! the inter-view separation (viewspace) + ! the height of the top view as displayed (zsize) ! Note that the top view "hangs down" from its coordinate system, ! which is at its (local) upper left hand corner. ! The model still calculates its size, which should in fact be the same ! as calculated previously. To nail down as many variables as possible, ! though, just ignore these calculated values (store them in the ! variable "nullsize"). topx := 0; topy := ysize + viewspace + zsize; csys_1p (#3, "top", vec (topx, topy), norot, norot, norot: blank=1); part (#4, boxlocal (8, 2, 4, nooff, nooff, nooff, 90, 0, 0, fullsize, nohide, nullsize, nullsize, nullsize), #3); ! place right view at bottom (Y=0); ! for X, add model width in 3-space (xsize) + ! the inter-view separation (viewspace) + ! the width of the right view as displayed (zsize) ! Note that positive direction of the Z axis of the right view is, ! as displayed on the drawing, to the left. rightx := xsize + viewspace + zsize; righty := 0; csys_1p (#5, "right", vec (rightx, righty), norot, norot, norot: blank=1); part (#6, boxlocal (8, 2, 4, nooff, nooff, nooff, 0, -90, 0, fullsize, nohide, nullsize, nullsize, nullsize), #5); ! The isometric view doesn't fit cleanly into the third angle projection ! scheme; it's just being put into some empty space. ! The location calculated here is therefore mostly empirical. ! The size used here is entirely empirical. isox := rightx - (zsize / 2); isoy := topy; csys_1p (#7, "isometric", vec (isox, isoy), norot, norot, norot: blank=1); part (#8, boxlocal (8, 2, 4, nooff, nooff, nooff, isoangle, -45, 0, 0.75, hide, nullsize, nullsize, nullsize), #7); ! Calculate the drawing's overall size. xmin := -viewspace; ymin := -viewspace; xmax := rightx + zsize + viewspace; ymax := topy + viewspace; ! Draw a border around the drawing. lin_free (#10, vec (xmin, ymin), vec (xmax, ymin)); lin_free (#11, vec (xmax, ymin), vec (xmax, ymax)); lin_free (#12, vec (xmax, ymax), vec (xmin, ymax)); lin_free (#13, vec (xmin, ymax), vec (xmin, ymin)); ! In a more elaborate example, other components of the drawing, ! such as the title box, might go here. endmodule ! $Id: vk-3din2d.src,v 1.3 1998/06/17 22:06:02 dmm Exp $ ! $Log: vk-3din2d.src,v $ ! Revision 1.3 1998/06/17 22:06:02 dmm ! *** empty log message *** ! ! Revision 1.2 1998/05/28 03:38:04 dmm ! *** empty log message *** !

The 3D model itself is simply a right parallelopiped with an extra diagonal line drawn across one end of one face to aid in visual orientation.

! boxlocal.MBS ! ! Draw a rectilinear box (right parallelopiped) in a local coordinate system. ! Pass the size, offset, and rotation parameters as float values rather ! than vectors to allow us to be called from 2D drawing modules (which ! don't allow the construction of 3D vectors). ! This module is placed in the public domain by its author, ! David M. MacMillan local geometry module boxlocal( float dx; ! size of box: X, Y, Z float dy; float dz; float xoff; ! offset of "back left bottom" corner of box float yoff; float zoff; float xrot; ! rotation around X, Y, Z float yrot; float zrot; float scale; ! scale of the box; 1.0 is 100% int hide; ! do or do not generate hidden line removal var float xsize; ! computed dimensions of model, to pass back to the caller var float ysize; var float zsize ); float dxs; ! scaled X,Y,Z size float dys; float dzs; ! coordinates of the corners of the box, ! visualized in the 1st quadrant. vector lbb; ! left back bottom; origin vector lbt; ! left back top vector lft; ! left front top vector lfb; ! left front bottom vector rbb; ! right back bottom vector rbt; ! right back top vector rft; ! right front top vector rfb; ! right front bottom beginmodule ! Create a local coordinate system for this model. csys_1p (#1, "local", vec (xoff, yoff, zoff), xrot, yrot, zrot: blank=1); mode_local (#1); ! Scale the box. dxs := dx * scale; dys := dy * scale; dzs := dz * scale; ! Calculate the corners of the box. lbb := vec (0, 0, 0); lbt := vec (0, dys, 0); lft := vec (0, dys, dzs); lfb := vec (0, 0, dzs); rbb := vec (dxs, 0, 0); rbt := vec (dxs, dys, 0); rft := vec (dxs, dys, dzs); rfb := vec (dxs, 0, dzs); ! Draw the box. lin_free (#2, lfb, lbb); ! the edges on the "left" side lin_free (#3, lft, lbt); lin_free (#4, lfb, lft); lin_free (#5, lbb, lbt); lin_free (#6, rfb, rbb); ! the edges on the "right" side lin_free (#7, rft, rbt); lin_free (#8, rfb, rft); lin_free (#9, rbb, rbt); lin_free (#10, lbb, rbb); ! connect the sides lin_free (#11, lfb, rfb); lin_free (#12, lbt, rbt); lin_free (#13, lft, rft); ! Draw a more or less arbitrary diagonal line across the "right" end ! of the "top" face, to aid in visual orientation. lin_free (#14, on(#13,0.75), on(#12,1)); if hide = 1 then ! Dress the box in b_planes for hidden line removal b_plane (#20, lbt, lft, rft, rbt); ! top b_plane (#21, rbt, rft, rfb, rbb); ! right b_plane (#22, lft, lfb, rfb, rft); ! front b_plane (#23, lfb, lbb, rbb, rfb); ! bottom b_plane (#24, lbt, lbb, lfb, lft); ! left b_plane (#25, rbt, rbb, lbb, lbt); ! back ! Create a view, identical in projection with the drawing view, ! and do hidden line removal in this view. cre_view ("xyhidden", vec (0,0,1)); act_view ("xyhidden"); hide_view ("xyhidden", 1); endif; ! Calculate the overall size of the model, and pass these values back ! through three VAR parameters. xsize := xoff + dx; ysize := yoff + dy; zsize := zoff + dz; endmodule ! $Id: vk-3din2d.src,v 1.3 1998/06/17 22:06:02 dmm Exp $ ! $Log: vk-3din2d.src,v $ ! Revision 1.3 1998/06/17 22:06:02 dmm ! *** empty log message *** ! ! Revision 1.2 1998/05/28 03:38:04 dmm ! *** empty log message *** !

The final result is the following third angle projection, autozoomed to fill the window:

With the exception of any material noted as being in the public domain, the text, images, and encoding of this document are copyright © 1998 by David M. MacMillan.

The author has no relationship with Microform AB, and this Tutorial is neither a product of nor endorsed by Microform AB.

"Varkon" is a registered trademark of Microform AB, Sweden.

This document is licensed for private, noncommercial, nonprofit viewing by individuals on the World Wide Web. Any other use or copying, including but not limited to republication in printed or electronic media, modification or the creation of derivative works, and any use for profit, is prohibited.

This writing is distributed in the hope that it will be useful, but "as-is," without any warranty of any kind, expressed or implied; without even the implied warranty of merchantability or fitness for a particular purpose.

In no event will the author(s) or editor(s) of this document be liable to you or to any other party for damages, including any general, special, incidental or consequential damages arising out of your use of or inability to use this document or the information contained in it, even if you have been advised of the possibility of such damages.

In no event will the author(s) or editor(s) of this document be liable to you or to any other party for any injury, death, disfigurement, or other personal damage arising out of your use of or inability to use this document or the information contained in it, even if you have been advised of the possibility of such injury, death, disfigurement, or other personal damage.

All trademarks or registered trademarks used in this document
are the properties of their respective owners and
(with the possible exception of any marks owned by the
author(s) or editor(s) of this document)
are used here for purposes of identification only.
A trademark
catalog page
lists the marks known to be used on these web pages.
Please e-mail
`dmm@lemur.com`
if you believe that the recognition of a trademark has been overlooked.

Version
1.3, 1998/06/17.
Feedback to dmm@lemur.com

`http://www.database.com/~lemur/vk-3din2d.html`

Go to the: