MBS reference manual
The MBS language is an integrated part of the VARKON system. Its main purpose is to act as a generic product modeling language but it is also used for other things (see below).
Introduction
All real products have some kind of structure. They usually consist of several different parts and it is therefore important to model the parts individually. MBS uses the concept of a MODULE to generically define each type of part that is used in a product. Here's an example...MODULE plate_with_hole(
FLOAT width:=100 >"Horisontal size ?";
FLOAT height:=50 >"Vertical size ?";
FLOAT hole_diameter:=30 >"Size of hole ?";
STRING material*10:="Steel" >"What material ?");BEGINMODULE
lin_ang(#1,vec(0,0), 0, width);
lin_offs(#2,#1,-height);
lin_free(#3,on(#1),on(#2));
lin_free(#4,on(#1,1),on(#2,1));
arc_1pos(#5,vec(width/2,height/2),hole_diameter/2);ENDMODULE
This module defines a rectangular plate with a hole in the center. It has a name (plate_with_hole), it has 4 parameters with default values and prompt strings (width, height, hole_diameter, material) and it has a body with statements that defines its geometrical appearence generically.
In order to use this module to create an actual instance of a plate_with_hole we must first compile the text based MBS file into a binary MBO equivalent and then call the module from within the VARKON system. This can be done interactively or by another module. In any case we have to provide actual values for all parameters or at least accept the defaults. VARKON then evaluates (executes) the module using actual parameters and stores the result in the GM database. Each time we call the module VARKON will evaluate it again and store a new instance in the GM database. The result in GM from evaluating a module is called a part. Each part holds its name, its actual parameter values and the entities created by the statements in the body.
Suppose now that we want to model a product consisting of many plates next to each other with a small distance between them. Lets make them all 10 by 10 with a hole of 2 and with copper as material.
MODULE many_plates(
INT n:=10 >"How many ?";
FLOAT d:=1 >"At what distance ?");INT i;
BEGINMODULE
for i:=1 to n do
csys_1p(#1,"Z-plane",vec(0,0,i*d));
part(#2,hole_with_plate(10,10,2,"Copper"),refc(1,i));
endfor;ENDMODULE
The result of evaluating this module is a part named many_plates consisting of a number of other parts named plate_with_hole all stored in the GM database. A part may consist of any number of other parts as well as basic geometric entities like lines or arcs. Parts may also consist of parts that consist of parts and so on down to a depth of maximum 10 levels.
VARKON Homepage | Index |