PLM之家PLMHome

[二次开发源码] NX二次开发源码分享:报告装配加载状态,设置装配加载

2019-9-15 08:32:35 156 0

[复制链接]
admin 发表于 2019-9-15 08:32:35 |阅读模式

admin 楼主

2019-9-15 08:32:35

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有帐号?注册

x
; @2 q1 O9 s, e$ X$ l4 q$ E- M' p) K
NX二次开发源码分享:报告装配加载状态,设置装配加载
" A1 D5 l: X! e2 U$ l4 `( y& ^. ?9 `7 V% }  ^- I3 _( n. G' D3 {
获取Load Options 并进行处理!
" p- q, R$ i! N: ^7 R& j" _* Q, `: U( v/ v' B( m' h" Z
[C] 纯文本查看 复制代码
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_assem.h>

#include <stdarg.h>

static void ECHO(char *format, ...)
{
    char msg[UF_UI_MAX_STRING_LEN+1];
    va_list args;
    va_start(args, format);
    vsprintf(msg, format, args);
    va_end(args);
    UF_UI_open_listing_window();
    UF_UI_write_listing_window(msg);
    UF_print_syslog(msg, FALSE);
}

#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];

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

    return(irc);
}

static void report_assem_search_directories(void)
{
    char
        **dir_list;
    int
        ii,
        num_dir = 0;
    logical
        *subs;

    UF_CALL(UF_ASSEM_ask_search_directories(&num_dir, &dir_list, &subs));
    for (ii = 0; ii < num_dir; ii++)
    {
        ECHO("%s", dir_list[ii]);
        if (subs[ii]) ECHO("...");
        ECHO("\n");
    }
    UF_free_string_array(num_dir, dir_list);
    UF_free(subs);
}

static void report_assem_options(void)
{
    UF_ASSEM_options_t
        assem_opts;

    UF_CALL(UF_ASSEM_ask_assem_options(&assem_opts));

    ECHO("Part Versions\n");
    switch (assem_opts.load_options)
    {
        case UF_ASSEM_load_from_directory:
            ECHO(" Load = From Folder\n");
            break;
        case UF_ASSEM_load_from_search_dirs:
            ECHO(" Load = From Search Folders\n");
            break;
        case UF_ASSEM_load_as_saved:
            ECHO(" Load = As Saved\n");
            break;
        default:
            ECHO(" assem_opts.load_options = unknown value (%d)",
                assem_opts.load_options);
            break;
    }

    switch (assem_opts.load_latest)
    {
        case UF_ASSEM_load_exact_version:
            ECHO(" Load Latest = Off\n");
            break;
        case UF_ASSEM_load_latest_version:
            ECHO(" Load Latest = On\n");
            break;
        default:
            ECHO(" assem_opts.load_latest = unknown value (%d)",
                assem_opts.load_latest);
            break;
    }

    if (assem_opts.load_options == UF_ASSEM_load_from_search_dirs)
        report_assem_search_directories();

    ECHO("Scope\n");
    switch(assem_opts.load_components)
    {
        case UF_ASSEM_dont_load_components:
            ECHO(" Load = Structure Only\n");
            break;
        case UF_ASSEM_do_load_components:
            ECHO(" Load = All Components\n");
            break;
        case UF_ASSEM_use_last_component_set:
            ECHO(" Load = As Saved\n");
            break;
        case UF_ASSEM_use_last_filter:
            ECHO(" Load = Re-evaluate Last Component Group\n");
            break;
        case UF_ASSEM_specify_filter:
            ECHO(" Load = Specify Component Group\n");
            break;
        default:
            ECHO(" assem_opts.load_components = unknown value (%d)",
                assem_opts.load_components);
            break;
    }

    switch(assem_opts.load_fully)
    {
        case UF_ASSEM_load_components_partially:
            ECHO(" Use Partial Loading = On\n");
            break;
        case UF_ASSEM_load_components_fully:
            ECHO(" Use Partial Loading = Off\n");
            break;
        default:
            ECHO(" assem_opts.load_fully = unknown value (%d)",
                assem_opts.load_fully);
            break;
    }

    switch (assem_opts.load_wave_data)
    {
        case UF_ASSEM_load_wave_data:
            ECHO(" Load Interpart Data = On\n");
            break;
        case UF_ASSEM_default_load_behaviour:
            ECHO(" Load Interpart Data = Off\n");
            break;
        default:
            ECHO(" assem_opts.load_wave_data = unknown value (%d)",
                assem_opts.load_wave_data);
            break;
    }

    switch (assem_opts.load_wave_parents)
    {
        case UF_ASSEM_none:
            ECHO(" Load Parents = None\n");
            break;
        case UF_ASSEM_immediate:
            ECHO(" Load Parents = Immediate Level Only\n");
            break;
        case UF_ASSEM_all:
            ECHO(" Load Parents = All Levels\n");
            break;
        default:
            ECHO(" assem_opts.load_wave_parents = unknown value (%d)",
                assem_opts.load_wave_parents);
            break;
    }

    ECHO("Load Behavior\n");
    switch (assem_opts.load_substitution)
    {
        case UF_ASSEM_do_allow_substitution:
            ECHO(" Allow Replacement = On\n");
            break;
        case UF_ASSEM_dont_allow_substitution:
            ECHO(" Allow Replacement = Off\n");
            break;
        default:
            ECHO(" assem_opts.load_substitution = unknown value (%d)",
                assem_opts.load_substitution);
            break;
    }

    switch (assem_opts.auto_regen_pfm_option)
    {
        case UF_ASSEM_auto_generate_pfm:
            ECHO(" Generate Missing Part Family Members = On\n");
            break;
        case UF_ASSEM_dont_auto_generate_pfm:
            ECHO(" Generate Missing Part Family Members = Off\n");
            break;
        default:
            ECHO(" assem_opts.auto_regen_pfm_option = unknown value (%d)",
                assem_opts.auto_regen_pfm_option);
            break;
    }

    switch (assem_opts.failure_action)
    {
        case UF_ASSEM_do_abort_on_failure:
            ECHO(" Cancel Load on Failure = On\n");
            break;
        case UF_ASSEM_dont_abort_on_failure:
            ECHO(" Cancel Load on Failure = Off\n");
            break;
        default:
            ECHO(" assem_opts.failure_action = unknown value (%d)",
                assem_opts.failure_action);
            break;
    }

    ECHO("Reference Sets\n");
    switch (assem_opts.apply_to_all_levels)
    {
        case UF_ASSEM_do_apply_to_all_levels:
            ECHO(" Apply to All Assembly Levels = On\n");
            break;
        case UF_ASSEM_dont_apply_to_all_levels:
            ECHO(" Apply to All Assembly Levels = Off\n");
            break;
        default:
            ECHO(" assem_opts.apply_to_all_levels = unknown value (%d)",
                assem_opts.apply_to_all_levels);
            break;
    }

    ECHO("Preferences-> Assembly (misc)\n");
    switch(assem_opts.emphasize)
    {
        case UF_ASSEM_do_not_emphasize_wp:
            ECHO(" Work Part-> Emphasize = Off\n");
            break;
        case UF_ASSEM_emphasize_wp:
            ECHO(" Work Part-> Emphasize = On\n");
            break;
        default:
            ECHO(" assem_opts.emphasize = unknown value (%d)",
                assem_opts.emphasize);
            break;
    }

    switch(assem_opts.maintain_work_part)
    {
        case UF_ASSEM_do_maintain_work_part:
            ECHO(" Work Part-> Maintain = On\n");
            break;
        case UF_ASSEM_dont_maintain_work_part:
            ECHO(" Work Part-> Maintain = Off\n");
            break;
        default:
            ECHO("assem_opts.maintain_work_part = unknown value (%d)",
                assem_opts.maintain_work_part);
            break;
    }
    switch(assem_opts.update)
    {
        case UF_ASSEM_no_update_report:
            ECHO(" Display Update Report = Off\n");
            break;
        case UF_ASSEM_update_report:
            ECHO(" Do Not Display Update Report = On\n");
            break;
        default:
            ECHO(" assem_opts.update = unknown value (%d)",
                assem_opts.update);
            break;
    }
}

static void load_specified_load_options_def_file(void)
{
    int
        resp;
    char
        filter[MAX_FSPEC_SIZE+1] = { "*.def" },
        fspec[MAX_FSPEC_SIZE+1] = { "" };

    if (!UF_CALL(UF_UI_create_filebox("Enter load options file to restore",
        "Restore Load Options File", filter, "", fspec, &resp)) &&
        (resp == UF_UI_OK))
        UF_CALL(UF_ASSEM_restore_load_options(fspec));
}

static void do_it(void)
{
    ECHO("Current load options:\n");
    report_assem_options();

    load_specified_load_options_def_file();

    ECHO("\nNewly restored load options:\n");
    report_assem_options();
}

/*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);
}

7 N" ^* R4 O7 n( v2 q
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

用户组 : 管理员
邮   箱 :xduniverse@qq.com
手   机 :VIP用户可查看[申请]
Q   Q : 点击这里给我发消息
性别 : 就不告诉你
主页 :http://www.plmhome.com
个人介绍 :原西门子NX高级教务员,10多年NX培训,开发咨询,Teamcenter培训实施等

主题2257

帖子3492

积分66379

  • 一个简单的登录和注册

    一个简单的登录和注册HTML CSS开发页面 登录代

  • Tecnomatix 二次开发

    Tecnomatix 二次开发入门教程 3 第一个hello plm

  • PLM之家NX插件V8.0.0.

    PLM之家NX插件 ============================

  • Tecnomatix 二次开发

    Tecnomatix 二次开发入门教程 6 实现打开PLM之家

  • 官方文档,NX12 使用

    官方文档,NX12 使用 Python进行二次开发相关配

  • 关闭

    站长推荐上一条 /1 下一条

  • 发布新帖
  • 在线客服1
  • 在线客服2
  • 微信
  • 客户端
  • 返回顶部