QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 1977|回复: 0
打印 上一主题 下一主题

[分享] UG按规则访问曲线上的点还有信息输出练习

[复制链接]

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
跳转到指定楼层
楼主
发表于 2016-1-5 16:46:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
UG按一定的规则访问曲线上的点还有信息输出练习
好久没发过帖子了,不知道自己论文写完以后还会不会搞UG的二次开发,不过自己学习的一些内容还是做一些分享把。以后说不定会去试试solidworks的二次开发。这篇主要介绍UF_MODL_ask_curve_points()
int UF_MODL_ask_curve_points
(

tag_t curve_id,  //曲线ID
double ctol, //弦高误差,如果是0就忽略
double atol, //弧度误差,如果是0就忽略
double stol, //最大步长,如果是0就忽略
int * numpts, //点的数目
double * * pts //点坐标的一维数组,xyz,xyz,xyz

)
另外,对UG中输出信息的方式,先记录两种,以后再慢慢做总结。
第一种:
UF_CALL(UF_UI_open_listing_window());//打开消息输出窗口

sprintf(buffer,"The points are: %f\n",pts);//将消息压入到buffer中,buffer是一个字符串数组,作为输出缓存

UF_CALL(UF_UI_write_listing_window(buffer));  //将buffer中的信息打印到信息框中去

还有用到的就是

sprintf(message, " section curves feature tag is %d\n", section_curves_feature);
   uc1601(message,1); 输出信息

下面的程序是建立一个圆弧,并输出按弦高误差来输出圆弧上的几个点。
#include <uf.h>
#include <uf_modl.h>
#include <uf_curve.h>
#include <uf_csys.h>
#include <uf_obj.h>
#include <stdio.h>
#include <uf_ui.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report( char *file, int line, char *call, int irc)
{
  if (irc)
  {
     char    messg[133];
     printf("%s, line %d:  %s\n", file, line, call);
     (UF_get_fail_message(irc, messg)) ?
       printf("    returned a %d\n", irc) :
       printf("    returned error %d:  %s\n", irc, messg);
  }
  return(irc);
}
static void do_ugopen_api(void)
{
  double ctol = 0.07612046748871;
  double atol = 0.0;
  double stol = 0.76536686473018;
  double *pts;
  char buffer[256];//输出缓存
  int numpts, i;
  tag_t arc, wcs_tag;
  UF_CURVE_arc_t arc_coords;
  UF_CALL(UF_CSYS_ask_wcs(&wcs_tag));
  UF_CALL(UF_CSYS_ask_matrix_of_object(wcs_tag,
                                       &arc_coords.matrix_tag));
  arc_coords.start_angle = 0.0;
  arc_coords.end_angle = PI;
  arc_coords.arc_center[0] = 0.0;
  arc_coords.arc_center[1] = 0.0;
  arc_coords.arc_center[2] = 0.0;
  arc_coords.radius = 1.0;
  UF_CURVE_create_arc(&arc_coords, &arc);
  UF_MODL_ask_curve_points(arc,ctol,atol,stol,
                                 &numpts, &pts);
  for(i = 0; i < 3 * numpts; i++)
  {   UF_CALL(UF_UI_open_listing_window());
   sprintf(buffer,"The points are: %f\n",pts);
    UF_CALL(UF_UI_write_listing_window(buffer));
  }
   UF_free(pts);
}
void ufusr(char *param, int *retcode, int param_len)
{
  if (!UF_CALL(UF_initialize()))
  {
    do_ugopen_api();
    UF_CALL(UF_terminate());
  }
}
int ufusr_ask_unload(void)
{
  return (UF_UNLOAD_IMMEDIATELY);
}


捕获.JPG (136.41 KB, 下载次数: 32)

程序结果

程序结果

有奖推广贴子: 

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-5-30 00:37

返回顶部