CAFE

UG/Open API Q&A

UF_ASSEM_substitute_component() 함수 사용 관련....

작성자카라|작성시간10.01.14|조회수163 목록 댓글 3

GTAC 샘플을 그대로 실행해 봐도 에러가 나던데요...

무엇을 잘못 한 걸까요????

//-----------------------------------------------------------------

// GTAC 소스 에러

//  Instance is not an instance of work part

//-----------------------------------------------------------------

 

//-----------------------------------------------------------------

// GTAC 소스를 이용하여 적용 하였더니,

// Object is of an unexpected class

//-----------------------------------------------------------------

 

work part 셋팅을 하고 해도 똑같은 에러가 납니다.

 

일단 아래는 GTAC 샘플 입니다...

 

아직두 운영 하고 계신거 맞지요????

 

부탁 드립니다.

 

/*HEAD SUBSTITUTE_COMPONENT CCC UFUN */
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_object_types.h>
#include <uf_assem.h>
#include <uf_disp.h>
#include <uf_cfi.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);

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

static int mask_for_components(UF_UI_selection_p_t select, void *type)
{
    UF_UI_mask_t
        mask = { UF_component_type, 0, 0 };

    if (!UF_CALL(UF_UI_set_sel_mask(select,
            UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, 1, &mask)))
        return (UF_UI_SEL_SUCCESS);
    else
        return (UF_UI_SEL_FAILURE);
}

static tag_t select_a_component(char *prompt)
{
    int
        resp;
    double
        cp[3];
    tag_t
        object,
        view;

    UF_CALL(UF_UI_select_with_single_dialog(prompt, "",
        UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, mask_for_components, NULL, &resp,
        &object, cp, &view));

    if (resp == UF_UI_OBJECT_SELECTED || resp == UF_UI_OBJECT_SELECTED_BY_NAME)
    {
        UF_CALL(UF_DISP_set_highlight(object, 0));
        return object;
    }
    else return NULL_TAG;

}

static void report_load_status(UF_PART_load_status_t *status)
{
    char
        msg[133];
    int
        ii;

    for (ii=0; ii<status->n_parts; ii++)
    {
        UF_get_fail_message(status->statuses[ii], msg);
        printf("    %s - %s\n", status->file_names[ii], msg);
    }

    if (status->n_parts > 0)
    {
        UF_free(status->statuses);
        UF_free_string_array(status->n_parts, status->file_names);
    }
}

static int prompt_for_an_integer(char *prompt, char *item, int number)
{
    int
        irc,
        resp;
    char
        menu[1][16];
    int
        da[1];

    strcpy(&menu[0][0], item);
    da[0] = number;

    resp = uc1607(prompt, menu, 1, da, &irc);
    if (resp == 3 || resp == 4)
    {
        return da[0];
    }
    else return 0;

}

static logical pick_one_of_two_choices(char *prompt, char *option_one,
    char *option_two, int *choice)
{
    int
        resp;
    char
        options[2][38];

    strncpy(&options[0][0], option_one, 37);
    strncpy(&options[1][0], option_two, 37);
    options[0][37] = '\0';
    options[1][37] = '\0';

    resp = uc1603(prompt, *choice, options, 2);
    if ((resp > 4) && (resp < 19))
    {
        *choice = resp - 4;  /* returns 1 or 2 */
        return TRUE;
    }
    else return FALSE;
}

static void combine_directory_and_wildcard(char *dir, char *fltr, char *spec)
{
    if (!strcmp(dir, ""))
        strcpy(spec, fltr);
    else
    {
        UF_CALL(uc4575(dir, 0, "junk.xxx", spec));
        strcpy(strstr(spec, "junk.xxx"), fltr);
    }
}

static logical prompt_for_part_name(char *prompt, char *fspec)
{
    int
        resp;
    char
        filter[MAX_FSPEC_SIZE+1],
        *p_dir,
        *p_ext;

    UF_CALL(UF_UI_ask_dialog_directory(UF_UI_PART_DIR, &p_dir));
    UF_CALL(UF_UI_ask_dialog_filter(UF_UI_PART_OPEN_FLTR, &p_ext));

    combine_directory_and_wildcard(p_dir, p_ext, filter);

    UF_free(p_dir);
    UF_free(p_ext);

    if (!UF_CALL(UF_UI_create_filebox(prompt, "Part Name", filter, "", fspec,
        &resp)) && (resp != UF_UI_CANCEL)) return TRUE;
    else return FALSE;
}

static logical prompt_for_existing_part_name(char *prompt, char *fspec)
{
    logical
        nxman,
        unused;
    int
        mode = 1,
        resp;

    UF_CALL(UF_is_ugmanager_active(&nxman));

    if (nxman)
    {
        if (pick_one_of_two_choices(prompt, "in Native", "in TcEng",
            &mode))
        {
            if (mode == 1)
                return (prompt_for_part_name(prompt, fspec));
            else
            {
                UF_CALL(UF_UI_set_prompt(prompt));
                if (UF_CALL(UF_UI_ask_open_part_filename(fspec, &unused, &resp))
                    || (resp == UF_UI_CANCEL)) return FALSE;
                return TRUE;
            }
        }
        else return FALSE;
    }
    else
    {
        UF_CALL(UF_UI_set_prompt(prompt));
        if (UF_CALL(UF_UI_ask_open_part_filename(fspec, &unused, &resp))
            || (resp == UF_UI_CANCEL)) return FALSE;
        return TRUE;
    }
}

static void do_it(void)
{
    int
        layer=1;
    tag_t
        comp,
        inst;
    double
        instance_origin[3],
        instance_matrix[9],
        instance_trans[4][4];
    char
        filename[MAX_FSPEC_SIZE+1] = { "" },
        instance_name[UF_CFI_MAX_FILE_NAME_SIZE],
        part_name[MAX_FSPEC_SIZE+1],
        refset_name[MAX_ENTITY_NAME_SIZE+1];
    UF_PART_load_status_t
        load_status;

    while (((comp = select_a_component("Substitute out")) != NULL_TAG) &&
        prompt_for_existing_part_name("Substitute in", filename))
    {
        inst = UF_ASSEM_ask_inst_of_part_occ(comp);
        layer = prompt_for_an_integer( "Enter Layer", "Layer", layer );
        UF_CALL(UF_ASSEM_ask_component_data(inst, part_name, refset_name,
            instance_name, instance_origin, instance_matrix, instance_trans));
        UF_CALL(UF_ASSEM_substitute_component(&inst, filename, instance_name,
            refset_name, layer, &load_status));
        report_load_status(&load_status);
    }
}

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

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자야누스 | 작성시간 10.01.15 잘 됩니다. work part의 child를 선택하지 않는 경우에는 위와 같은 에러가 발생하네요. 즉 work part의 2 level에 있는 component를 선택하는 경우 같은 에러가 발생하네요.
  • 작성자야누스 | 작성시간 10.01.15 그러고..아직 운영중입니다..^^;; 요즘 글이 너무 없죠..많이 채워주세요.
  • 작성자카라 작성자 본인 여부 작성자 | 작성시간 10.01.15 원인을 알려 주셔서 너무 감사합니다. 2 level 의 한계를 극복 했습니다...
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼