/*----------------------------------------------------------------*\
Global definitions
\*----------------------------------------------------------------*/
#define FILENAME "assembly.lst"
typedef struct user_appdata
{
FILE *fp;
int level;
} UserAppdata1;
/*================================================================*\
Function to write out the members of the current assembly, and
display the result in an information window.
\*================================================================*/
int UserAsmCompVisit ()
{
ProMdl asm_mdl;
char name[PRO_NAME_SIZE];
char type[PRO_TYPE_SIZE];
wchar_t wname[PRO_NAME_SIZE];
ProMdldata mdldata;
ProError err;
UserAppdata1 appdata;
FILE *fp;
ProMdlCurrentGet (&asm_mdl);
/*----------------------------------------------------------*\
Open the text file.
\*----------------------------------------------------------*/
strcpy_s (name,FILENAME);
fopen_s (&fp ,name,"w");
ProMdlDataGet (asm_mdl, &mdldata);
ProWstringToString (name, mdldata.name);
ProWstringToString (type, mdldata.type);
fprintf (fp, "%s %s\n",name,type);
appdata.fp = fp;
appdata.level = 1;
/*-----------------------------------------------------*\
List the assembly members.
\*----------------------------------------------------*/
ProSolidFeatVisit ((ProSolid)asm_mdl, user_action, UserAsmCompFilter, &appdata);
/*---------------------------------------------------*\
Close the file and display it.
\*--------------------------------------------------*/
fclose (fp);
ProStringToWstring (wname, FILENAME);
ProInfoWindowDisplay (wname, NULL, NULL);
return (PRO_TK_NO_ERROR);
return 1;
}
/*================================================================*\
FUNCTION: UserAsmCompFilter()
PURPOSE: A filter used by ProSolidFeatVisit() to visit
features that are assembly components
\*================================================================*/
ProError UserAsmCompFilter (
ProFeature *feature,
ProAppData app_data)
{
ProError status;
ProFeattype ftype;
/*------------------------------------------------*\
Get the feature type------------------------*/
status = ProFeatureTypeGet (feature, &ftype);
/*-----------------------------------------------*\
If the feature is an assembly component,
return NO ERROR,
else
return CONTINUE
\*--------------------------------------------------------*/
if (ftype == PRO_FEAT_COMPONENT)
return (PRO_TK_NO_ERROR);
return (PRO_TK_CONTINUE);
}
/*-----------------------------------------------------------------*\
Write the information to a file.
\*-----------------------------------------------------------------*/
ProError user_action (
ProFeature *feature,
ProError status,
ProAppData appdata)
{
FILE *fp;
int l, level;
ProError err;
ProMdl mdl;
char name[PRO_NAME_SIZE];
char type[PRO_TYPE_SIZE];
wchar_t wname[PRO_NAME_SIZE];
UserAppdata1 *appd, appd1;
ProMdldata mdldata;
appd = (UserAppdata1 *)appdata;
fp = appd->fp;
level = appd->level;
ProAsmcompMdlGet (feature , &mdl);
ProMdlDataGet (mdl, &mdldata);
ProWstringToString (name,mdldata.name);
ProWstringToString (type,mdldata.type);
for (l = 0; l < level; l++)
fprintf(fp," ");
fprintf (fp,"%s %s\n",name,type);
if (strncmp (type,"ASM",3) == 0)
{
appd1.fp = appd->fp;
appd1.level = appd->level+1;
ProSolidFeatVisit ((ProSolid)mdl, user_action, UserAsmCompFilter, &appd1);
}
if (feature != NULL)
return(PRO_TK_NO_ERROR);
return (PRO_TK_CONTINUE);
}