VARKON Version 1.15 1997-10-16

### Extracting result from GM

Let's design a very simple wheel and see how it works. Our wheel consists of a 50 millimeter fixed size hub, a variable size rim and a variable number of spokes. For the hub and rim we can use the following modules.....

    DRAWING MODULE hub_50();                DRAWING MODULE rim(FLOAT size);

    BEGINMODULE                             BEGINMODULE

      arc_1pos(#1,vec(0,0),25);               arc_1pos(#1,vec(0,0),size/2);

    ENDMODULE                               ENDMODULE

and for a variable size wheel with a variable number of spokes.....

    DRAWING MODULE wheel(FLOAT size; INT nspokes);

    BEGINMODULE

      part(#1,hub_50());
      part(#2,rim(size));

      for i:=1 to nspokes do
        lin_ang(#2,on(#1#1,i/nspokes),on(#2#1,i/nspokes));
      endfor;

    ENDMODULE

Suppose now that VARKON evaluates wheel for size=600 and nspokes=30. The result stored in the GM database will be a hub_50 (#1), a rim (#2) and 30 lines (#3.1,#3.2,#3.3,.........#3.30). To extract infromation about a specific entity we must know its identity....
get_arc(#1#1,arcfont,daslength,p1,r,v1,v2); ! Returns arc data of hub_50
get_lin(#3.20,linfont,dashlength,p1,p2); ! Returns line data for spoke 20
size:=get_flt(#2,1); ! Returns rim parameter = 600
MBS includes specific get-routines for all types of enteties including parts and their parameters. If you dont know the identity of an entity you can searh using...
identity:=get_next_gm(mode,type,part_name,member_in_group_with_name);
This routine returns the next entity that matches type and/or optional name and/or optional group if traversing the GM-tree in the direction of mode (horisontal/vertical). Type can be any combination of types and names can be given using wildcards. If you want to limit a search to a specific part of GM you can set your own root position using...
set_root_gm(root_id);
A set_root_gm to #2 with a following get_next_gm of any entity would return #2#1 which is the arc representing the rim in our example. A set_root_gm to the top of wheel and a following get_next_gm of any part with name = hub* would return #1 which is the identity of hub_50.

VARKON Homepage | Index