ug二次开发C语言实例,【求】UG二次开发的代码(C语言),求高手看看哪出错了...

这篇博客主要讨论了一段用于Unigraphics(UG)二次开发的C语言代码,该代码旨在读取DXF文件并进行处理。在代码执行过程中遇到了编译错误,包括语法错误和未声明的标识符。博主列举了错误提示,并寻求帮助解决这些问题。
摘要由CSDN通过智能技术生成

已结贴√

问题点数:10 回复次数:2

ca56232b3bbedf9a539d07f37fffb99a.gif

3144d8b7615c79d9f638db40d5689d26.gif

a218af6549b45ee526caf607ebff1358.gif

0f8df0e29816ae721419de940fb833d1.gif

【求】UG二次开发的代码(C语言),求高手看看哪出错了

/*****************************************************************************

**

** NX8_Open1.c

**

** Description:

**     Contains Unigraphics entry points for the application.

**

*****************************************************************************/

/* Include files */

#include

#include

#include

#include "stdio.h"

#include "math.h"

#include "string.h"

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

FILE*fp;

int i,gcode;

char fname[14],gvalue[65];

float xs[100],ys[100],zs[100],xe[100],ye[100],ze[100];

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

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

}

int scanline()

{

printf("Enter DXF file name:");

scanf("%s",fname);

strcat(fname,".dxf");

fp=fopen(fname,"r");

do

{

fscanf(fp,"%d",&gcode);

fscanf(fp,"%s",gvalue);

}

while(gcode!=2||strcmp(gvalue,"ENTITIES")!=0);

do

{

fscanf(fp,"%d",&gcode);

fscanf(fp,"%s",gvalue);

if(gcode==0&&strcmp(gvalue,"LINE")==0)outline();

}

while(gcode!=0||strcmp(gvalue,"ENDSEC")!=0);

fclose(fp);

return 0;

}

int outline()

{

do{fscanf(fp,"%d",&gcode);

if(gcode==10)

{i=i+1;

fscanf(fp,"%f",&xs[i]);

}

else

fscanf(fp,"%s",gvalue);

}while(gcode!=10);

fscanf(fp,"%d",&gcode);

fscanf(fp,"%f",&ys[i]);

fscanf(fp,"%d",&gcode);

fscanf(fp,"%f",&zs[i]);

fscanf(fp,"%d",&gcode);

fscanf(fp,"%f",&xe[i]);

fscanf(fp,"%d",&gcode);

fscanf(fp,"%f",&ye[i]);

fscanf(fp,"%d",&gcode);

fscanf(fp,"%f",&ze[i]);

return 0;

}

/*****************************************************************************

**  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 */

if( UF_CALL(UF_initialize()) )

{

/* Failed to initialize */

return;

}

/* TODO: Add your application code here */

void main ()

{

int n;

i=0;

scanline();

printf("Enter data file name:");

scanf("%s",fname);

fp=fopen(fname,"w");

fprintf(fp,"%d\n",i);

for(n=1;n<=i;n++)

{

fprintf(fp,"%f,%f,%f\n",xs[n],ys[n],zs[n]);

fprintf(fp,"%f,%f,%f\n",xe[n],ye[n],ze[n]);

}

fclose(fp);

}

/* Terminate the API environment */

UF_CALL(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 int ufusr_ask_unload( void )

{

return( UF_UNLOAD_UG_TERMINATE );

}

下面是错误显示

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(113): error C2143: 语法错误 : 缺少“;”(在“类型”的前面)

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(122): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(122): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(122): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(124): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(124): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(124): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(125): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(125): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(125): error C2065: “n”: 未声明的标识符

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(131): error C2143: 语法错误 : 缺少“)”(在“字符串”的前面)

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(131): error C2143: 语法错误 : 缺少“)”(在“字符串”的前面)

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(131): error C2143: 语法错误 : 缺少“{”(在“字符串”的前面)

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(131): error C2059: 语法错误:“”

1>e:\2\nx8_open1\nx8_open1\nx8_open1.c(132): error C2059: 语法错误:“}”

1>

1>生成失败。

1>

1>已用时间 00:00:00.44

========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值