📄 project_va.c
字号:
/*****************************************************************************
**
** Project_VA.c
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/
/* Include files */
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_mb.h>
#include <uf_part.h>
#include <uf_assem.h>
#include <stdio.h>
#include <stdlib.h>
#include "Project_VA.h"
#include "Project_Model.h"
#include "Project_VA_dialog.h"
#include "Project_Matrix.h"
logical Project_VA_Determine_Assembly_Condition()
{
tag_t display_part_tag;
tag_t root_tag;
int part_num;
tag_t *child_part_occs;
UF_initialize();
display_part_tag=UF_PART_ask_display_part();
if(display_part_tag==NULL_TAG)
{
uc1601("没有显示部件,请加载相关装配模型",1);
return FALSE;
}
root_tag=UF_ASSEM_ask_root_part_occ(display_part_tag);
part_num=UF_ASSEM_ask_part_occ_children(root_tag,&child_part_occs);
UF_free(child_part_occs);
if(part_num==0)
{
uc1601("不在装配环境中,请加载相关装配模型",1);
return FALSE;
}
return TRUE;
}
/*****************************************************************************
** Activation Methods
*****************************************************************************/
VA_assembly *p_gbl_asm=NULL; //全局变量
/* Unigraphics Startup
** This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
static UF_MB_cb_status_t Project_VA_Model_Refresh_Menu( UF_MB_widget_t,UF_MB_data_t,UF_MB_activated_button_p_t );
static UF_MB_cb_status_t Project_VA_Model_Main_Menu( UF_MB_widget_t,UF_MB_data_t,UF_MB_activated_button_p_t);
static UF_MB_action_t actionTable[]=
{
{"REFRESH_MODEL",Project_VA_Model_Refresh_Menu,NULL},
{"ASSEMBLY_PLANNING",Project_VA_Model_Main_Menu,NULL},
{NULL,NULL,NULL}
};
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
UF_MB_add_actions(actionTable);
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
/*****************************************************************************
** 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 int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
/* PrintErrorMessage
**
** Prints error messages to standard error and the Unigraphics status
** line. */
static void PrintErrorMessage( int errorCode )
{
if ( 0 != errorCode )
{
/* Retrieve the associated error message */
char message[133];
UF_get_fail_message( errorCode, message );
/* Print out the message */
UF_UI_set_status( message );
fprintf( stderr, "%s\n", message );
}
}
static UF_MB_cb_status_t Project_VA_Model_Refresh_Menu(
UF_MB_widget_t widget,
UF_MB_data_t client_data,
UF_MB_activated_button_p_t call_button
)
{
logical assembly_cond;
char *messages={ "更新装配模型将丢失之前规划的信息"};
UF_UI_message_buttons_t buttons;
int result,err;
tag_t display_part_tag,root_tag;
if ( UF_initialize() != 0) return ( UF_UI_CB_CONTINUE_DIALOG );
assembly_cond=Project_VA_Determine_Assembly_Condition();
if(assembly_cond==FALSE) return UF_MB_CB_CONTINUE;
display_part_tag=UF_PART_ask_display_part();
root_tag=UF_ASSEM_ask_root_part_occ(display_part_tag);
if(p_gbl_asm!=NULL)
{
buttons.button1=TRUE;buttons.button2=FALSE;buttons.button3=TRUE;
buttons.label1="更新";buttons.label3="不更新";
buttons.response1=1;buttons.response3=-1;
UF_UI_message_dialog("提示",UF_UI_MESSAGE_INFORMATION,&messages,1,TRUE,
&buttons,&result);
if(result==1)//更新
{
err=Project_VA_Model_Refresh(p_gbl_asm, root_tag);
if(err==UG_NO_ERROR)
uc1601("装配模型更新成功!",1);
}
}
else
{
err=Project_VA_Model_Refresh(p_gbl_asm, root_tag);
if(err==UG_NO_ERROR)
uc1601("装配模型更新成功!",1);
}
return UF_MB_CB_CONTINUE;
}
static UF_MB_cb_status_t Project_VA_Model_Main_Menu( UF_MB_widget_t widget
,UF_MB_data_t client_data
,UF_MB_activated_button_p_t call_button)
{
extern VA_assembly *p_gbl_asm;
VA_movement *p_new_move,*p_cur_move;
VA_Move_Select m_move_sel;
VA_component *p_comp;
int i,n_comp,resp,err;
int menu_sel,sel_move_no,failures[1];
tag_t supress_instances[1];
if(p_gbl_asm==NULL)
{
uc1601("请先初始化装配模型",1);
return UF_MB_CB_CONTINUE;
}
p_comp=p_gbl_asm->head_comp->children;
n_comp=0;
while(p_comp!=NULL)
{
n_comp++;
p_comp=p_comp->next;
}
do
{
m_move_sel.sel_move_no=0;
if(p_gbl_asm->moves->move_num==n_comp)
m_move_sel.sel_move_no=-1;
LaunchAssemblyPlanningDialog(&resp,&m_move_sel);
menu_sel=m_move_sel.action;
sel_move_no=m_move_sel.sel_move_no;
if(resp==UF_UI_OK||resp==UF_UI_CANCEL)
menu_sel=resp;
if(menu_sel==UG_APPEND_MOVE)//添加移动
{
UF_DISP_refresh();
p_cur_move=p_gbl_asm->moves->head;
while(p_cur_move!=NULL)
{
supress_instances[0]=p_cur_move->comp->instance_tag;
UF_ASSEM_suppress_instances(1,supress_instances,failures);
p_cur_move=p_cur_move->next;
}
p_new_move=(VA_movement*)malloc(sizeof(VA_movement));
err=Project_VA_Model_Append_Move(p_new_move);
if(err!=UG_NO_ERROR)
{
free(p_new_move);
continue;
}
if(p_gbl_asm->moves->head==NULL&&p_gbl_asm->moves->tail==NULL)
{
p_gbl_asm->moves->head=p_new_move;
p_gbl_asm->moves->tail=p_new_move;
p_new_move->prev=NULL;
p_new_move->next=NULL;
}
else
{
p_new_move->next=NULL;
p_new_move->prev=p_gbl_asm->moves->tail;
p_gbl_asm->moves->tail->next=p_new_move;
p_gbl_asm->moves->tail=p_new_move;
}
p_gbl_asm->moves->move_num++;
p_cur_move=p_new_move;
}
else if(menu_sel==UG_DISPLAY_MOVE)//显示移动
{
p_cur_move=p_gbl_asm->moves->head;
for(i=0;i<sel_move_no;i++)
p_cur_move=p_cur_move->next;
Project_VA_Component_Resume(p_cur_move->comp);
Project_VA_Display_Move(p_cur_move);
}
else if(menu_sel==UG_DELETE_MOVE)
{
//删除移动
}
else if(menu_sel==UG_DISPLAY_ANIMATION)
{
//显示动画
p_cur_move=p_gbl_asm->moves->head;
for(i=0;i<sel_move_no;i++)
p_cur_move=p_cur_move->next;
Project_VA_Component_Resume(p_cur_move->comp);
Project_VA_Animation_Move(p_cur_move);
}
else if(menu_sel==UG_INTERF_CHECK)
{
//干涉检查
}
else if(menu_sel==UF_UI_OK||menu_sel==UF_UI_CANCEL)
{
//恢复被抑止的部件到初始位置,退出
break;
}
}while(1);
return UF_MB_CB_CONTINUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -