发布企业信息

UG/OPEN 使用默认设置打印图纸的程序源代码

作者:佚名  信息来源:无忧机械电子  2006-11-15

字体大小:  网友评论  进入论坛  

程序代码:/***************************************************************************** Print all drawing sheets of the displayed part (using the default settings) to a known printer / profile。h #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))) static int report_error( char *file, int...
程序代码:
/*****************************************************************************
Print all drawing sheets of the displayed part (using the default settings)
to a known printer / profile. This example assumes that the default Printer
Group has a printer named "Printer One" and it uses the SDI "system" profile



*****************************************************************************/



/* Include files */
#include <stdio.h>
#include <uf.h>
#include <uf_obj.h>
#include <uf_part.h>
#include <uf_plot.h>
#include <uf_ui.h>
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))



static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];



sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);



UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);



if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}



return(irc);
}



extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
UF_PLOT_job_options_t job_options;
UF_PLOT_banner_options_t banner_options;
char *job_name;
int copies;
tag_t display_part;
tag_t drawing_sheet;



/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}



/* If no part is displayed, do nothing. */



display_part = UF_PART_ask_display_part();
if (display_part == NULL_TAG)
{
return;
}

/*
Get the default job options and banner options for use in
the "print" call for each sheet
*/
UF_CALL( UF_PLOT_ask_default_job_options( &job_options) );
UF_CALL( UF_PLOT_ask_default_banner_options( &banner_options ) );



copies = 1;



drawing_sheet = NULL_TAG;
while ((UF_CALL(UF_OBJ_cycle_objs_in_part(display_part,
UF_drawing_type,
&drawing_sheet)) == ERROR_OK) &&
(drawing_sheet != NULL_TAG))
{
/* Supplying a drawing sheet tag causes the default job
name to have the sheet name appended to it
*/
UF_CALL( UF_PLOT_ask_default_job_name( drawing_sheet, &job_name ) );



/* Print the sheet. The "Printer One" printer MUST be
defined in the default Printer group for your system.
The "<System Profile>" profile is the default SDI
profile. You can alter these two parameters to match
your installation.
*/
UF_CALL( UF_PLOT_print( drawing_sheet, &job_options, job_name,
&banner_options, "Printer One",
"<System Profile>", copies ) );
UF_free( job_name );
}



/* Terminate the API environment */
UF_CALL(UF_terminate());
}



/*****************************************************************************
** Utilities
*****************************************************************************/



/* Unload Handler
** This function specifies when to unload your application from Unigraphics.
** If your application registers a callback (from a MenuScript item or a
** User Defined Object for example), this function MUST return
** "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}




分页:
Google


推荐图文

广告

机械热点图文

  • 数控车床加工编程典型实例分析2
  • 内螺纹车削加工——数控车床编程实例42
  • 子程序编程方法-数控车床编程实例36
  • 塑料模具动画演示

机械风云人物

  • 制造未来的巨人

    制造未来的巨人

    --小巨人公司展示“中国第一座智能网络化机床制造工厂” 贺兰山下,黄河岸边,豪放的...

  • 迦南科技集团的科技发展之路——访迦南科技集团董事长方亨志先生

    迦南科技集团的科技发展

    方亨志:迦南科技集团有限公司董事长、政协第八届永嘉县委员会委员、浙江省机械工业协...

Copyright © 2004 51base.com Inc. All rights reserved.

无忧基地 版权所有│粤ICP备06098418号│XHTML | CSS

客服:+86-755-2212 2202 工作时间:周1~5 10点~16点

感谢中国网络提供带宽支持

《网络营销技巧》