iCAx开思网

标题: 我学UG二次开发,但不知道下列函数出自哪个头文件 [打印本页]

作者: spartutu    时间: 2004-10-12 10:16
标题: 我学UG二次开发,但不知道下列函数出自哪个头文件
UF_MODL_ask_list_item(),
UF_MODL_ask_exp_tag_string(),
UF_MODL_dissect_exp_string(),
UF_MODL_create_block1()
书上没有头文件,不知道这些函数出自那些头文件?
作者: suye007    时间: 2004-10-12 10:20
uf_modl.h
作者: spartutu    时间: 2004-10-12 10:41
我加了头文件,但还是有问题。
原文件中的部分程序如下:
tag_t new_exp;
UF_MODL_create_exp_tag("w=10", [$new_exp)]
  
/*get the parameters and export*/
char *string;
char *lhs_str;
char *rhs_str;
  
但编译时char *string行出现错误说: F:\UG\List\List.c(45) : error C2143: syntax error : missing ';' before 'type'
这是为什么
作者: 深夜摔键盘    时间: 2004-10-12 10:50
这个错误,是C语法上的。
把使用这几个字串的 代码一并贴出来看看
作者: huashanyjj    时间: 2004-10-12 13:04
ug定义的数据类型的头文件要包括,
比如:
uf_defs.h
  
还有如果用到的话:
uf_object_types.h
也要包括,
还有其他的头文件。
最好做一个头文件一下都包含进去
作者: 深夜摔键盘    时间: 2004-10-12 15:42
呵呵,我明白了。
楼主兄弟是在看清华的书,这本书很好。不光教你如何写UG程序,还让你锻炼调程序的能力,给你一段含有若干错误的代码,你得去找bug,而不是搬着书来抄。
还有,把你用向导生成的.c文件改成.cpp,然后在编译连接
作者: guxiongfei    时间: 2004-10-12 16:48
不错,找错误,很锻炼人:)
作者: spartutu    时间: 2004-10-12 22:02
是的,我在学清华的书,加了几个头文件还是没有,代码如下,帮我分析分析,有38个错误和41个警告
/*****************************************************************************
**
**  List.c
**
**  Description:
**     Contains Unigraphics entry points for the application.
**
*****************************************************************************/
  
/*  Include files */
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_defs.h>
  
#include <uf_object_types.h>
  
#include <uf_modl.h>
  
#include "List.h"
  
/*****************************************************************************
**  Activation Methods
*****************************************************************************/
  
/*  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 */
    int errorCode = UF_initialize();
  
    if ( 0 == errorCode )
    {
        /* TODO: Add your application code here */
    //创建参数  create parameters
    tag_t new_exp;
    UF_MODL_create_exp_tag("w=10", [$new_exp)]
  
    /*get the parameters and export*/
    char *string, *lhs_str, *rhs_str;
  
    UF_MODL_ask_exp_tag_string (new_exp, [$string)]
    UF_UI_open_listing_window();
    UF_UI_write_listing_window("the new created parameter is:\n");
    UF_UI_write_listing_window(string);
    UF_UI_write_listing_window("\n");
  
    //delete the parameter
    UF_MODL_dissect_exp_string(string, [$lhs_str, &rhs_str, &new_exp)]
    UF_MODL_delete_exp(lhs_str);
    UF_free(string);
    UF_free(lhs_str);
    UF_free(rhs_str);
  
    //create 2 rectangles
    UF_FEATURE_SIGN sign = UF_NULLSIGN;  //create a new rectangle
    UF_FEATURE_SIGN sign1 = UF_POSITIVE; //create a rectangle that join with the rectangle created before
    double block_orig[3] = {0.0, 0.0, 0.0};
    double block_orig1[3] = {0.0, 0.0, 2.5};
    char *block_len[3] = {"1", "2", "3"};
    char *block_len1[3] = {"1", "1", "1"};
    tag_t blk_obj;
    tag_t blk1_obj;
    UF_MODL_create_block1(sign, block_orig, block_len, [$blk_obj)]
    UF_MODL_create_block1(sign1, block_orig1, block_len1, [$blk1_obj)]
  
    uf_list_t *list;
    // create the list
    UF_MODL_create_list([$list)]
    //put the rectangles into the list
    UF_MODL_put_list_item(list,blk_obj);
    UF_MODL_put_list_item(list,blk1_obj);
    int list_count;
    tag_t list_item;
    UF_MODL_ask_list_count(list, [$list_count)]
    for(int i=0; i<list_count;i++)
    {
      UF_MODL_ask_list_item(list, i, [$list_item)]
      UF_DISP_set_highlight(list_item, 1);
    }
  
    //delete the blk_obj in the list
    UF_MODL_delete_list_item([$list, blk_obj)]
  
    //delete the rectangles in the list
    UF_MODL_delete_feature(list);
    UF_MODL_update();
  
    //delete the list
    UF_MODL_delete_list([$list)]
  
    //delete the blk_obj
    UF_OBJ_delete_object(blk_obj);
  
        /* 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 );
    }
}
作者: 深夜摔键盘    时间: 2004-10-13 01:40
告诉你了呀。
把c文件改成cpp文件
作者: wflying    时间: 2004-10-13 11:35
TO spartutu :
你搞UG开发,必须要有UG Docement,所有的函数都在那里边,有2k多个函数!你的错误是变量定义的位置不对
/* Initialize the API environment */  
    int errorCode = UF_initialize();  
  
    if ( 0 == errorCode )  
    {  
        /* TODO: Add your application code here */  
    //创建参数 create parameters  
    tag_t new_exp;  
    UF_MODL_create_exp_tag("w=10", [$new_exp)]  
  
    /*get the parameters and export*/  
    char *string, *lhs_str, *rhs_str;
改成
/* Initialize the API environment */
tag_t new_exp;
  /*get the parameters and export*/  
   char *string, *lhs_str, *rhs_str;  
  
     int errorCode = UF_initialize();  
  
     if ( 0 == errorCode )  
     {  
         /* TODO: Add your application code here */  
         UF_MODL_create_exp_tag("w=10", [$new_exp)]  
  
    再试试,应该是没有问题了的!
   
作者: spartutu    时间: 2004-10-13 14:27
定义位置变了后,还是有问题,出现了以下错误
f:\ug\list\list.c(66) : error C2275: 'UF_FEATURE_SIGN' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_modl_types.h(546) : see declaration of 'UF_FEATURE_SIGN'
f:\ug\list\list.c(66) : error C2146: syntax error : missing ';' before identifier 'sign'
f:\ug\list\list.c(66) : error C2065: 'sign' : undeclared identifier
f:\ug\list\list.c(67) : error C2275: 'UF_FEATURE_SIGN' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_modl_types.h(546) : see declaration of 'UF_FEATURE_SIGN'
f:\ug\list\list.c(67) : error C2146: syntax error : missing ';' before identifier 'sign1'
f:\ug\list\list.c(67) : error C2065: 'sign1' : undeclared identifier
f:\ug\list\list.c(68) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(69) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(70) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(71) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(72) : error C2275: 'tag_t' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_defs.h(52) : see declaration of 'tag_t'
f:\ug\list\list.c(72) : error C2146: syntax error : missing ';' before identifier 'blk_obj'
f:\ug\list\list.c(72) : error C2065: 'blk_obj' : undeclared identifier
f:\ug\list\list.c(73) : error C2275: 'tag_t' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_defs.h(52) : see declaration of 'tag_t'
f:\ug\list\list.c(73) : error C2146: syntax error : missing ';' before identifier 'blk1_obj'
f:\ug\list\list.c(73) : error C2065: 'blk1_obj' : undeclared identifier
f:\ug\list\list.c(74) : error C2065: 'block_orig' : undeclared identifier
f:\ug\list\list.c(74) : warning C4047: 'function' : 'double *' differs in levels of indirection from 'int '
f:\ug\list\list.c(74) : warning C4024: 'UF_MODL_create_block1' : different types for formal and actual parameter 2
f:\ug\list\list.c(74) : error C2065: 'block_len' : undeclared identifier
f:\ug\list\list.c(74) : warning C4047: 'function' : 'char ** ' differs in levels of indirection from 'int '
f:\ug\list\list.c(74) : warning C4024: 'UF_MODL_create_block1' : different types for formal and actual parameter 3
f:\ug\list\list.c(75) : error C2065: 'block_orig1' : undeclared identifier
f:\ug\list\list.c(75) : warning C4047: 'function' : 'double *' differs in levels of indirection from 'int '
f:\ug\list\list.c(75) : warning C4024: 'UF_MODL_create_block1' : different types for formal and actual parameter 2
f:\ug\list\list.c(75) : error C2065: 'block_len1' : undeclared identifier
f:\ug\list\list.c(75) : warning C4047: 'function' : 'char ** ' differs in levels of indirection from 'int '
f:\ug\list\list.c(75) : warning C4024: 'UF_MODL_create_block1' : different types for formal and actual parameter 3
f:\ug\list\list.c(77) : error C2275: 'uf_list_t' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_defs.h(66) : see declaration of 'uf_list_t'
f:\ug\list\list.c(77) : error C2065: 'list' : undeclared identifier
f:\ug\list\list.c(79) : warning C4047: 'function' : 'struct uf_list_s ** ' differs in levels of indirection from 'int *'
f:\ug\list\list.c(79) : warning C4024: 'UF_MODL_create_list' : different types for formal and actual parameter 1
f:\ug\list\list.c(81) : warning C4047: 'function' : 'struct uf_list_s *' differs in levels of indirection from 'int '
f:\ug\list\list.c(81) : warning C4024: 'UF_MODL_put_list_item' : different types for formal and actual parameter 1
f:\ug\list\list.c(82) : warning C4047: 'function' : 'struct uf_list_s *' differs in levels of indirection from 'int '
f:\ug\list\list.c(82) : warning C4024: 'UF_MODL_put_list_item' : different types for formal and actual parameter 1
f:\ug\list\list.c(83) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(84) : error C2275: 'tag_t' : illegal use of this type as an expression
        c:\program files\eds\unigraphics nx\ugopen\uf_defs.h(52) : see declaration of 'tag_t'
f:\ug\list\list.c(84) : error C2146: syntax error : missing ';' before identifier 'list_item'
f:\ug\list\list.c(84) : error C2065: 'list_item' : undeclared identifier
f:\ug\list\list.c(85) : warning C4047: 'function' : 'struct uf_list_s *' differs in levels of indirection from 'int '
f:\ug\list\list.c(85) : warning C4024: 'UF_MODL_ask_list_count' : different types for formal and actual parameter 1
f:\ug\list\list.c(85) : error C2065: 'list_count' : undeclared identifier
f:\ug\list\list.c(86) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(86) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(86) : error C2143: syntax error : missing ')' before 'type'
f:\ug\list\list.c(86) : error C2143: syntax error : missing ';' before 'type'
f:\ug\list\list.c(86) : error C2065: 'i' : undeclared identifier
f:\ug\list\list.c(86) : warning C4552: '<' : operator has no effect; expected operator with side-effect
f:\ug\list\list.c(86) : error C2059: syntax error : ')'
f:\ug\list\list.c(87) : error C2143: syntax error : missing ';' before '{'
f:\ug\list\list.c(88) : warning C4047: 'function' : 'struct uf_list_s *' differs in levels of indirection from 'int '
f:\ug\list\list.c(88) : warning C4024: 'UF_MODL_ask_list_item' : different types for formal and actual parameter 1
f:\ug\list\list.c(93) : warning C4047: 'function' : 'struct uf_list_s ** ' differs in levels of indirection from 'int *'
f:\ug\list\list.c(93) : warning C4024: 'UF_MODL_delete_list_item' : different types for formal and actual parameter 1
f:\ug\list\list.c(96) : warning C4047: 'function' : 'struct uf_list_s *' differs in levels of indirection from 'int '
f:\ug\list\list.c(96) : warning C4024: 'UF_MODL_delete_feature' : different types for formal and actual parameter 1
f:\ug\list\list.c(100) : warning C4047: 'function' : 'struct uf_list_s ** ' differs in levels of indirection from 'int *'
f:\ug\list\list.c(100) : warning C4024: 'UF_MODL_delete_list' : different types for formal and actual parameter 1
Error executing cl.exe.
  
List.obj - 34 error(s), 25 warning(s)
作者: spartutu    时间: 2004-10-13 14:31
而将c文件改成cpp文件之后,出现了以下问题:Compiling...
List.cpp
Linking...
   Creating library Debug/List.lib and object Debug/List.exp
List.obj : error LNK2001: unresolved external symbol __imp__UF_terminate
List.obj : error LNK2001: unresolved external symbol __imp__UF_OBJ_delete_object
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_delete_list
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_update
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_delete_feature
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_delete_list_item
List.obj : error LNK2001: unresolved external symbol __imp__UF_DISP_set_highlight
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_ask_list_item
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_ask_list_count
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_put_list_item
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_create_list
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_create_block1
List.obj : error LNK2001: unresolved external symbol __imp__UF_free
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_delete_exp
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_dissect_exp_string
List.obj : error LNK2001: unresolved external symbol __imp__UF_UI_write_listing_window
List.obj : error LNK2001: unresolved external symbol __imp__UF_UI_open_listing_window
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_ask_exp_tag_string
List.obj : error LNK2001: unresolved external symbol __imp__UF_MODL_create_exp_tag
List.obj : error LNK2001: unresolved external symbol __imp__UF_initialize
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/List.exe : fatal error LNK1120: 21 unresolved externals
Error executing link.exe.
  
List.exe - 22 error(s), 0 warning(s)
  
不知道为什么?
作者: 深夜摔键盘    时间: 2004-10-13 14:40
没有添加libufun.lib和 libugopenint.lib到你的工程中去。
alt+f7,设置一下link项,。
作者: suye007    时间: 2004-10-13 16:18
https://www.icax.org/viewthread. ... %3D1&page=#pid=还是从这个开始吧......
作者: spartutu    时间: 2004-10-13 21:02
但把两个lib加进去之后还是出现了上述的34个错误和25个警告,不知为什么
作者: 深夜摔键盘    时间: 2004-10-14 09:06

要么看看zzz老大的“手把手教你二次开发”,要么把你的代码贴上来看看。
作者: spartutu    时间: 2004-10-14 15:28
代码和出现的错误都在上面的帖子里,请帮我看看是为什么?'UF_FEATURE_SIGN' : illegal use of this type as an expression  
        是怎么回事?
作者: 深夜摔键盘    时间: 2004-10-14 15:51
你添加了libufun.lib 和libugopenint.lib,并且把.c改成了.cpp之后,那些错误不都是没有了?
你的错误应该不是代码的错误,是VC工程设置的问题。




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3