The sheets Script

The sheets script stores the drawing sheet decoration styles.

Example Script

In the DecorateSheet() example script below, the typical items to configure are shown with bold text.

Because the program will be calling a text-type label to plot the title box, the name of the symbol and its parameters are somewhat fixed. In the example, the title box label is bound to the 2D symbol via the DG label type ("TITLEBOX") and the text number "22". This association makes the program call the "text22( )" symbol.

#include include/dg.h
#include include/pd.h
#include include/dw.h
#include include/dmutil.h

DecorateSheet(string style, w, h)
{
	if( style == "Cadmatic" )
		return( DecorateCadmaticSheet(w,h) );
	/*
	else if( style == "XXX" )
		return( DecorateXXXSheet(w,h) );
	else return(0); 
	*/
}
DecorateCadmaticSheet(w, h)
{
	dw_group = DW_GETGROUPID( "SHEET" );

	/* get rid of old 2D stuff in the group: SHEET */

	if( dw_group != 0 )
		DW_DELGROUP_ANDMEM( dw_group );

	dg_group = DG_GETGROUPID( "SHEET" );

	if( dg_group != 0 ){
		nr_member = DG_GETOBJSOFGROUP( dg_group );
		for(i=0; i < nr_member; i=i+1; ){
			dg_obj		= DG_GETOBJID();
			DG_DELTEXT( dg_obj );
		}
		DG_DELGROUP( dg_group );
	}

	/* insert new stuff ... */
	DW_LIMITS(0., 0., w, h);
	DW_GRID(1,		/* grid on */
		 1,		/* grid visible */
		 15,	/* color */
		 1,		/* linetype, using solid line */
		 0.,	/* x-coordinate of base point */
		 0.,	/* y-coordinate of base point */
		 2.5,	/* spacing of grid lines in x-direction */
		 2.5,	/* spacing of grid lines in y-direction */
		 0.);	/* pattern length used to draw grid lines */

	/*
	**	Draw a double frame around the drawing sheet.
	*/

	dw_group = DW_NEWGROUP( "ANNOTATE", "SHEET", 0 );
	dg_group = DG_NEWGROUP( "ANNOTATE", "SHEET", 0 );

	DW_OWNER(0);				/*	just drafting stuff */
	DW_DRWATTR(65002, 11, 3);	/*	layer, color, width */
	DW_LTYPE(1, 0.);			/*	line type, pattern length */
	dw_obj = DW_POLY(0., 0.,  0., h,     w,    h,     w,   0., 0., 0.);
	DW_ADDGROUPMEM( dw_group, 1, dw_obj );
	dw_obj = DW_POLY(5., 5.,  5., h-5.,  w-5, h-5.,  w-5, 5., 5., 5.);
	DW_ADDGROUPMEM( dw_group, 1, dw_obj );

	/*
	**	Place title block at the lower right corner.
	*/
	dg_sym          =  0;
	label_type      = "TITLEBOX";
  	label_text      = "";               
	label_txt_no    =  22;					/* uses 2d symbol called text22 */
	digit_mode      = "DW_TXT_PNT_OD_RN";
	x_orig          =  w-185-5;				/* frame = 5 mm, titlebox = 185 mm */
	y_orig          =  5.;					/* frame = 5 mm */ 
	
	DG_DRWATTR(65004, 1, 3);				/*	layer, color, width */
	dg_obj = DG_INSTEXTLABEL( dg_sym, label_type, label_text, label_txt_no,
								 digit_mode, x_orig, y_orig );

	DG_ADDGROUPMEM( dg_group, 1, dg_obj );

	/* 	
	**	Default cut parameters, DG_CUTPRM: Cut at intersections YES, Cut horizontal lines NO, Gap 2.5 mm
	** 	If you want to cut the horizontal lines, second value should be 1
	*/
	DG_CUTPRM(1,0,2.5);

	/*
	** Reveision table location for revision_table.mac
	*/
	
	dg_sym          =  0;	 
	label_type      = "REVISIONTABLE";
  	label_text      = "";               
	label_txt_no    =  0;		/* uses 2d symbol called text0 */
	digit_mode      = "DW_TXT_PNT_OD_RN";
	x_orig          =  w-185-5;		/* frame = 5 mm, titlebox = 185 
				   mm , revisiontable = 100 mm*/
	y_orig          =  h-5.;		/* frame = 5 mm */ 
	
	DG_DRWATTR(65004, 1, 3);	/*	layer, color, width */
	dg_obj = DG_INSTEXTLABEL( dg_sym, label_type, label_text, label_txt_no,
								 digit_mode, x_orig, y_orig );

	DG_ADDGROUPMEM( dg_group, 1, dg_obj );

	return(0);
}