/*====================================================================*\ FILE : UgFamtabUse.c PURPOSE : Demonstrate the Usage of Family Tables Functions HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 04-Dec-97 H-02-02 ljl $$1 setup & fix bug in user_family_diffs() \*====================================================================*/ /*---------------------- Pro/Toolkit Includes ------------------------*/ #include /*---------------------- Pro/Develop Includes ------------------------*/ #include "prodevelop.h" #include "profamtab.h" #include "prodevdim.h" /*---------------------- Application Includes ------------------------*/ #include /*---------------------- Function Prototypes -------------------------*/ ProError user_Family_Diffs(); ProError user_family_diffs (); /*------------------------- Global Data ------------------------------*/ static ProFileName msgfil; ProError user_Family_Diffs() { Prohandle drawing; Select3d *sel; drawing = pro_get_current_object(); ProStringToWstring( msgfil, "msg_ugfamtab.txt" ); /*-----------------------------------------------------------*\ Ask the user to select a drawing view. \*-----------------------------------------------------------*/ promsg_print (msgfil, "USER Select the view"); while (pro_select ("dwg_view", 1, &sel, NULL, NULL)) { /*-----------------------------------------------------------*\ Call the function to display family differences for this view. \*-----------------------------------------------------------*/ user_family_diffs (drawing, sel[0].selected_id, sel[0].selected_ptr); } return ( PRO_TK_NO_ERROR ); } ProError user_family_diffs (drawing, view_id, view) Prohandle drawing; int view_id; Prohandle view; { Prohandle instance, generic; Pro_object_info inst_info; int status, col, col_type, num_col ; wchar_t col_name[PRODEV_NAME_SIZE], inst_value[PRODEV_LINE_SIZE], generic_value[PRODEV_LINE_SIZE]; char str[PRODEV_NAME_SIZE]; int dim_id; Pro_object_info gen_info; int err ; /*-----------------------------------------------------------*\ Get the model in the selected view. \*-----------------------------------------------------------*/ instance = prodrw_get_view_model (drawing, view_id); prodb_get_object_info (instance, &inst_info); /*-----------------------------------------------------------*\ Get the generic model, and complain if there isn't one. \*-----------------------------------------------------------*/ status = protdo_get_generic_object (instance, &generic); prodb_get_object_info (generic, &gen_info); if (status != 0) { promsg_print (msgfil, "USER This view does not contain a family table instance"); return ( status ); } num_col = protdo_num_columns (generic) ; /*-----------------------------------------------------------*\ For each column in the family table... \*-----------------------------------------------------------*/ for (col = 0; col < num_col; col++) { /*-----------------------------------------------------------*\ If the column is not a DIMENSION, skip it. \*-----------------------------------------------------------*/ protdo_get_column_info (generic, col, &col_type, col_name); if (col_type != FT_DIMENSION) continue; /*-----------------------------------------------------------*\ Read the values in this column for the generic and for the instance. If they are the same, or the instance has an asterisk, skip it. \*-----------------------------------------------------------*/ err = protdo_read_field (generic, inst_info.name, col_type, col_name, inst_value); ERROR_CHECK("user_family_diffs()", "protdo_read_field()", err); if (!strcmp (str, "*")) continue; protdo_read_field (generic, NULL, col_type, col_name, generic_value); if (!user_wstrcmp (inst_value, generic_value)) continue; /*-----------------------------------------------------------*\ Translate the column header to a dimension identifier, and display this dimension in the selected view. \*-----------------------------------------------------------*/ if (!sscanf (pro_wstr_to_str (str, col_name), "d%d", &dim_id)) continue; prodim_display_dimension (instance, drawing, dim_id, NULL, 0, view); } return ( PRO_TK_NO_ERROR ); }