找回密码
 注册
Simdroid-非首页
查看: 61|回复: 1

[二次开发] a sample for UF_UI_ONT_ask_selected_nodes

[复制链接]
发表于 2010-10-5 13:37:38 | 显示全部楼层 |阅读模式 来自 北京
Function:ask blank offset distance
Description:
Contains Unigraphics entry points for the application.
The ONT needs a previously created Workpiece.
Highlight the Worpiece and execute this program

----------------------------

#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_cam.h>
#include <uf_lib.h>
#include <uf_param.h>
#include <uf_param_indices.h>
#include <uf_part.h>
#include <uf_obj.h>
#include <uf_obj_types.h>
#include <uf_ui_ont.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);
}

#define WRITE(X)   UF_UI_open_listing_window(); UF_UI_write_listing_window(X)

#define WRITE_S(X) (write_string_to_listing_window(#X, X))

void write_string_to_listing_window(char *title, char *string)
{
    char
        msg[MAX_LINE_SIZE+1];

    UF_CALL(UF_UI_open_listing_window());
    sprintf(msg, "%s = %s\n", title, string);
    UF_CALL(UF_UI_write_listing_window(msg));
}

static void do_it(void)
{
    logical
        is_initialized;
    int
        object_count,
        type,
        subtype,
        attributes=2;

        double blank_dist;

    tag_t
        *objects;

    char
        msg[200];


    if (UF_CALL(UF_CAM_is_session_initialized(&is_initialized)) ||
        (is_initialized == FALSE)) return;

    /* Get the highlighted/selected objects from Navigation Tool. */
     UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects ));

    if (object_count == 1)
    {
        UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));

        if ((type == UF_machining_geometry_grp_type) &&
            (subtype == UF_mill_geom_featr_subtype ))
        {

                // get the blank distance
                // Note that the uf_param_indices.h file is wrong - it shows
                //#define UF_PARAM_BLANK_DIST   266  /* UF_PARAM_type_double_length */
                // see PR6076897

                        UF_CALL(UF_PARAM_ask_double_value(objects[0],381,&blank_dist));
                        sprintf(msg,"Blank distance is %f\n",blank_dist);
            WRITE(msg);

        }
        else
        {
            WRITE("type is not UF_machining_geometry_grp_type");
            WRITE(" or subtype is not UF_mill_geom_featr_subtyp");
        }
        UF_free(objects);

    }
    else
    {
        WRITE("objects selected in ONT is not equal to 1");
    }

}


/*ARGSUSED*/
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
    if (UF_CALL(UF_initialize())) return;
    do_it();
    UF_CALL(UF_terminate());
}

extern int ufusr_ask_unload( void )
{
    return( UF_UNLOAD_IMMEDIATELY );
}
发表于 2010-10-5 23:35:52 | 显示全部楼层 来自 辽宁阜新
Simdroid开发平台
好深奥啊。
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-5-21 10:07 , Processed in 0.031503 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表