|
|
[二次开发] edit sphere parameter(use UF_MODL_edit
(这条文章已经被阅读了 3043 次) 时间:2009/09/21/08:12
来源:even2004
#include <stdio.h> #include <string.h> #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> #include <uf_object_types.h> #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))) /*ARGSUSED*/ 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); /* NOTE: UF_print_syslog is new in V18 */ 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); } #define WRITE(X) UF_UI_open_listing_window(); UF_UI_write_listing_window(X) /*ARGSUSED*/ static tag_t select_a_feature(char *prompt) { int cnt, resp;: tag_t first, *feats; $ UF_CALL(UF_UI_select_feature(prompt, NULL, &cnt, &feats, &resp)); if (cnt)' {1 O. first = feats[0];) UF_free(feats); return (first); } else return (NULL_TAG); } /*ARGSUSED*/ static logical prompt_for_a_number(char *prompt, char *item, double *number) {. int irc, resp; char menu[1][16]; double da[1]; strncpy(&menu[0][0], item, 16); menu[0][15] = '
|
此文章相关评论:(论坛方式查看) |
作者: even2004 标题:Re:[二次开发] edit sphere parameter(use UF_MODL_edit 时间: 2009/09/21/08:15 da[0] = *number; resp = uc1609(prompt, menu, 1, da, &irc); if (resp == 3 || resp == 4) {/ *number = da[0];+ return TRUE; } else return FALSE; } /*ARGSUSED*/ static void do_it(void) { tag_t' sphere_feat = NULL_TAG, exp_tag = NULL_TAG; char *diameter = NULL, *lhs_str = NULL, *rhs_str = NULL, new_exp_str[UF_MAX_EXP_LENGTH+1] = { "" }; double number = 0.0; if(( (sphere_feat = select_a_feature("Select a Sphere:")) != NULL_TAG ) && prompt_for_a_number( "Enter New Sphere Diameter:","size", &number )) { UF_CALL( UF_MODL_ask_sphere_parms ( sphere_feat, 0, &diameter )); UF_CALL( UF_MODL_dissect_exp_string(diameter, &lhs_str, &rhs_str, &exp_tag )); sprintf( new_exp_str, "%s=%f", lhs_str, number );1 UF_CALL( UF_MODL_edit_exp( new_exp_str ));7 UF_MODL_update(); if( diameter != NULL ) UF_free( diameter ); if( lhs_str != NULL ) UF_free( lhs_str );( if( rhs_str != NULL ) UF_free( rhs_str );2 } } /*ARGSUSED*/ void ufusr(char *param, int *retcode, int paramLen) { if (UF_CALL(UF_initialize())) return;: do_it(); UF_terminate(); } int ufusr_ask_unload(void) { return (UF_UNLOAD_IMMEDIATELY); }
|
|
|