iCAx开思工具箱

标题: 【求助】装配中的"MateV18.h" [打印本页]

作者: cg0606    时间: 2004-8-11 12:22
标题: 【求助】装配中的"MateV18.h"
请问有谁知道“MateV18.h"这个头文件是做什么用的,为什么我在UG version18中找不到?
这个头文件在清华书中(第137页,第5行)创建配合关系的一段程序中用到。
  
另外清华中中创建配合关系的这段程序中(从第137页到第140页),为什么没有用到"UF_ASSEM_init_mc([$ftf)"和"ftf.part_occurrence = to_part_occ]"这两行?
多谢多谢
作者: tari    时间: 2004-8-11 14:30
你用的是UG 18?
你把这个头文件不要试试
UF_ASSEM_init_mc(&ftf)函数好像是nx才出现的
作者: cg0606    时间: 2004-8-11 14:42
多谢回帖,
我用的是UG 18.
昨天晚上我发了一个帖子问关于“UF_ASSEM_mating_condition"的问题,也是您回的吧,多谢。我跟了一个帖子就是问您关于这个”UF_ASSEM_init_mc"的问题,在UG18下,不用这个API也可以吗?
我的程序编译链接都正常,但配合关系就是无法创建,UF_ASSEM_solve_mc返回值正常,但下一句UF_ASSEM_apply_mc_data的返回值就不为0了,怎么也想不通。
清华那本书中给的装配例子我也试了,也是同样的问题,请问您用过那个例子吗?
作者: tari    时间: 2004-8-11 14:47
你用UF_get_fail_message()这个函数跟踪一下,看看系统提示的错误是什么,要不你把整个代码发上来大家看看
作者: cg0606    时间: 2004-8-11 14:51
我完全照抄清华那本书上的例子,代码如下:
  
//  Include files
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <iostream.h>
#include <uf_modl.h>
#include <uf_assem.h>
#include <uf_part.h>
#include <uf_object_types.h>
  
#include "mc.h"
  
//----------------------------------------------------------------------------
//  Activation Methods
//----------------------------------------------------------------------------
  
//  Unigraphics Startup
//      This entry point activates the application at Unigraphics startup
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
    /* Initialize the API environment */
    int errorCode = UF_initialize();
  
    if ( 0 == errorCode )
    {
        /* TODO: Add your application code here */
    char message[133];
    message[0] = '\0';
    strcpy(message, "lease select the first plane");
    UF_UI_selection_options_t opts;
    UF_UI_mask_t mask;
    int response;
    tag_t view;
    double cursor[3];
    int unhighlight = 0;
  
    opts.other_options = 0;
    opts.reserved = NULL;
    opts.num_mask_triples = 1;
    opts.mask_triples = [$mask]
    opts.mask_triples->object_type = UF_face_type;
    opts.mask_triples->object_subtype = UF_bounded_plane_subtype;
    opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE;
    opts.scope = UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;
  
    int type;
    double point[3];
    double dir[3];
    double box[6];
    double radius;
    double rad_data;
    int norm_dir;
    tag_t first_plan;
    do
    {
      int irc = UF_UI_select_single(message, &opts, &response, &first_plan,  
                      cursor, [$view)]
      UF_MODL_ask_face_data(first_plan, &type, point, dir, box, &radius, &rad_data,
                  [$norm_dir)]
    }while(!(type== 22 [$& response == 5))]
  
    int ret;
    tag_t from_part_occ;
    ret = UF_ASSEM_ask_parent_component(first_plan, [$from_part_occ)]
    logical is_occ = UF_ASSEM_is_occurrence(from_part_occ);
    tag_t from_part_ins = UF_ASSEM_ask_inst_of_part_occ(from_part_occ);
  
    char part_name[132+1];
    char refset_name[30+1];
    char instance_name[30+1];
    double origin[3];
    double csys_matrix[9];
    double transform[4][4];
    ret = UF_ASSEM_ask_component_data(from_part_occ, part_name, refset_name,
                      instance_name, origin, csys_matrix,  
                      transform);
    uc1601(instance_name, 1);
  
    message[0] = '\0';
    strcpy(message, "lease select the second plane");
    tag_t second_plan;
    do
    {
      int irc = UF_UI_select_single(message, &opts, &response, &second_plan,  
                      cursor, [$view)]
      UF_MODL_ask_face_data(first_plan, &type, point, dir, box, &radius, &rad_data,
                  [$norm_dir)]
    }while(!(type== 22 [$& response == 5))]
  
    tag_t to_part_occ;
    ret = UF_ASSEM_ask_parent_component(second_plan, [$to_part_occ)]
    tag_t to_part_ins = UF_ASSEM_ask_inst_of_part_occ(to_part_occ);
  
    ret = UF_ASSEM_ask_component_data(to_part_occ, part_name, refset_name,
                      instance_name, origin, csys_matrix,  
                      transform);
    uc1601(instance_name, 1);
  
    // create mating condition
    UF_ASSEM_mating_condition_t ftf;
//    UF_ASSEM_init_mc([$ftf)]
  
    ftf.mated_object = from_part_ins;
    ftf.part_occurrence = to_part_occ;
    ftf.name = NULL;
    ftf.user_name = FALSE;
    ftf.constraints[0].from_status = UF_ASSEM_ok;
    ftf.constraints[0].to_status = UF_ASSEM_ok;
    ftf.constraints[0].mate_type = UF_ASSEM_v16_mate;
    ftf.constraints[0].from_type = UF_ASSEM_planar_face;
    ftf.constraints[0].to_type = UF_ASSEM_planar_face;
    ftf.constraints[0].from = UF_ASSEM_ask_prototype_of_occ(first_plan);
    ftf.constraints[0].from_part_occ = from_part_occ;
    ftf.constraints[0].to = UF_ASSEM_ask_prototype_of_occ(second_plan);
    ftf.constraints[0].to_part_occ = to_part_occ;
    ftf.constraints[0].offset = NULL_TAG;
    ftf.constraints[0].name = "face to face";
    ftf.constraints[0].user_name = TRUE;
    ftf.num_constraints = 1;
    ftf.suppressed = FALSE;
  
    UF_ASSEM_mc_status_t status;
    UF_ASSEM_mc_structure_state_t struct_status;
    UF_ASSEM_dof_t dof;
  
    ret = UF_ASSEM_solve_mc([$ftf, &status, &dof, transform)]
  
    ret = UF_ASSEM_apply_mc_data([$ftf, &struct_status, &status)]
  
    UF_DISP_refresh();
  
    UF_MODL_update();
  
    UF_DISP_set_highlight(first_plan, 0);
    UF_DISP_set_highlight(second_plan, 0);
  
        /* Terminate the API environment */
        errorCode = 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 "C" int ufusr_ask_unload( void )
{
    return( UF_UNLOAD_UG_TERMINATE );
}
作者: tari    时间: 2004-8-11 14:59
请问你用于装配的是零件还是装配体?instance、occurrence、protype这几个概念自己琢磨一下,也许是这个原因
作者: cg0606    时间: 2004-8-11 15:47
这些概念对我来说确实比较糊涂,我再想想吧,多谢多谢




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3