PLM之家PLMHome-国产软件践行者

[交作业] 20160320 lesson 2 2圆柱求和+手工输入中心线+点信息

[复制链接]

2016-3-20 19:27:35 3226 1

gsmfxsmy 发表于 2016-3-20 19:15:41 |阅读模式

gsmfxsmy 楼主

2016-3-20 19:15:41

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
/*****************************************************************************
8 `) f1 h- ~' [0 }: @**
* U) ^9 N2 h; A7 g2 c0 a$ ~7 l* d** creat cly.cpp
, w& g  A. s. N, X* \, v7 y2 _**8 R9 X" c1 A4 D% v
** Description:
  o; l3 A  H% v" ?) z6 r5 N- _**     Contains Unigraphics entry points for the application.8 [- i  M+ {3 K8 |. ?
**
" F' O* j4 _0 `5 ?( ?8 d, J*****************************************************************************/  x2 M5 U) z1 T

1 h3 o3 L( K0 l9 d/ O7 }/* Include files */9 n3 |8 d/ j) B/ v: o: L# w
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
% h8 F! Z2 a! Y, \0 u#   include <strstream>
, O; k/ D; d9 }6 x7 O#   include <iostream>
$ b5 R- L; m% [0 N. e    using std:strstream;! L9 F) B9 e5 l' m- ?/ k
    using std::endl;   
, q! j+ b0 j1 d4 f    using std::ends;
' }" l2 G% B. N: v  n    using std::cerr;
5 a0 y0 [* j9 r! z9 v& N6 A) @#else
9 u. N# {6 P! h2 o. E' S#   include <strstream.h>
* _' x* j3 T& C8 I9 w' t* ?( ^) y#   include <iostream.h>
5 ^2 t2 f; q- ~0 ^" _- Z% ?7 q" U$ C#endif
, B* }; o: U; d# n% \, j/ x#include <uf.h>, y+ U! ?. B" D7 m# l
#include <uf_ui.h>
0 g- l3 r4 t$ U3 f) ?; U& h" l#include <uf_exit.h>  b# B% q2 @9 J- _6 o
#include<uf_part.h>
: Z+ q2 N  O6 _. o9 Y; `#include<uf_modl.h>. T2 F: K0 a, l5 T5 l
#include<uf_curve.h>' R$ q# f! l7 j2 G. f: w
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
, X3 W' `$ f+ ]) S' X0 ^
! l, s. q# [7 P6 z9 \( {) M  z! o& R+ _1 u
static int report_error( char *file, int line, char *call, int irc)
1 k; E& @% J9 Z2 a* y{5 x( `0 K; ~8 ]* W$ s7 s  T4 l
    if (irc)
# E) \; @3 J4 h) @# a+ M9 [2 v. A) T9 i    {% u- O' ?. p3 m! o9 E
        char err[133]," e9 P% @0 R) _5 }: e4 \; j
             msg[133];0 Q9 ]3 A/ l) d( l  l, d

/ l" z$ y: @, \# ]        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",. p' t" Z' ?! I- `
            irc, line, file);
) X. `2 a; Z& I        UF_get_fail_message(irc, err);: |" J! N7 x% M: ]: `
! W, X; I) W6 M  x3 M8 r0 r
        UF_print_syslog(msg, FALSE);
( ^, ?7 ?# u& T  Y3 V: M        UF_print_syslog(err, FALSE);
' h( r- o' e5 o( {- K        UF_print_syslog("\n", FALSE);- |1 Z6 i1 f6 @# k& \( l; p8 m1 K9 J
        UF_print_syslog(call, FALSE);* l: f" E9 T" s8 p
        UF_print_syslog(";\n", FALSE);
5 {. e  G7 P7 g# R9 u
( Q4 ?+ l8 T! W$ Q6 H+ e        if (!UF_UI_open_listing_window())
/ ]. S8 v: V- Q, q1 s        {
0 S/ K4 {! P$ W3 L7 l3 c( c# g            UF_UI_write_listing_window(msg);
* o5 X4 F& P  k1 S: H" z6 c            UF_UI_write_listing_window(err);
. n; K* H" b8 h            UF_UI_write_listing_window("\n");
8 J- J! z; f+ ]8 d, v            UF_UI_write_listing_window(call);# Y! y8 H; K: L/ L
            UF_UI_write_listing_window(";\n");
, O2 c3 s" D# q  k: U& k% {        }
) {4 l; U. ]' h% ^7 r- y    }
$ L7 j! t4 I: o
" G2 }& c7 z. X/ }8 p    return(irc);3 S$ s: k+ p  r4 N  W
}: G" S6 I# U/ D2 ]2 k

  U. w7 h7 I+ U6 B% m2 [& o( G) l( h/ S- y
/*****************************************************************************
& J, {5 G9 ~6 M9 K& t8 W0 f" z" j**  Activation Methods1 I5 r" C' c! c4 J- F
*****************************************************************************/
+ D& l! S+ o" ]/*  Unigraphics Startup
- N5 \+ j! _# G**      This entry point activates the application at Unigraphics startup */8 z, W0 q5 b" h7 Y' o0 ^
extern DllExport void ufsta( char *param, int *returnCode, int rlen )% R( b' s, O) G4 L# b: [. K$ B5 R
{: h) J) B+ D9 D# E& }' I
    /* Initialize the API environment */% `3 @9 ~# g% T, @- W
    if( UF_CALL(UF_initialize()) ) 9 i+ l9 f) p8 {* y' |) o8 v+ d
    {
4 |$ q& r3 h+ j        /* Failed to initialize */
8 G6 \$ [' C- ]4 z% P        return;
" q  z, T# P! g3 ^, o& E3 C- W. H4 k    }
$ B" s( P# R  w8 j+ E+ m" r* x8 `  e. }7 r
    /* TODO: Add your application code here */* e- T& r- Q  f
       
) F5 ?6 O  \% s        //new part
: l; s$ P2 G; u& p
$ h( F' z/ I5 G) E9 o- O6 i: w( e        tag_t parttag=NULL_TAG;' z2 A+ I8 `6 J: b

9 x" _3 m1 z- o& ?        UF_PART_new("c:\\temp\\plmhome.prt",1,&parttag);
) ]+ e" L- ~. w
1 }$ E+ f; P) R, y, q        //creat cyl
; D: m3 f+ U% I4 T) m( a! C6 f1 \) h* u( a
                double origin [ 3 ]={0,0,0};
3 ^. o" c) w% B5 R4 [                char *height={"50"};
2 U# I( Y. A" i                char *diam={"100"};
, y3 [4 v/ O' X0 s% Q/ F1 o7 d                double direction1 [ 3 ] ={1,1,1};3 F5 w) `8 b8 B  _) q* V
                double direction2 [ 3 ] ={-1,-1,-1};                : c+ _* ~* V* }3 L8 a) V% C
                tag_t cylFeatureTag=NULL_TAG;# ]# M( C! f( l4 O% x/ ^

2 H9 F/ n7 r1 P9 B/ t6 a        UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin,height,diam,direction1,&cylFeatureTag));
; n8 X* a$ V. N- ~        UF_CALL(UF_MODL_create_cyl1(UF_POSITIVE,origin,height,diam,direction2,&cylFeatureTag));
3 i8 n% M9 V. X1 \6 \( w        //creat line
+ @, v# c9 E( f1 X8 f/ l+ w+ o: P        UF_CURVE_line_t line_coords;% f8 R& K8 i, w' G  v5 `
        line_coords.start_point[0]=-50.0;8 D0 q3 O# `7 _+ h, {7 B
        line_coords.start_point[1]=-50.0;. ?7 p) E& h4 R3 ]$ P% Z4 S: t
        line_coords.start_point[2]=-50.0;
/ B  p# @8 z1 g        line_coords.end_point[0]=50;
0 \0 G0 F  V( P8 r; T        line_coords.end_point[1]=50;# P& V9 O, U5 O
        line_coords.end_point[2]=50;, x9 q$ R$ Q! p! l
        tag_t linetag=NULL_TAG;
* a- c6 f- }, g4 K# Q/ c9 T3 D, Y8 q
        UF_CALL(UF_CURVE_create_line(&line_coords,&linetag));7 V, \8 ?* N- j+ l$ o
        //creat point
/ j& ^& I4 k& u% P, b        double pointstarTCoords[3]={line_coords.start_point[0],line_coords.start_point[1],line_coords.start_point[2]};
# S& Z% @& f6 X8 N: W        double pointendcoords[3]={line_coords.end_point[0],line_coords.end_point[1],line_coords.end_point[2]};5 b7 Y0 T- f; V# X5 V1 n0 q( |8 q
        tag_t pointtag=NULL_TAG;
8 P7 Y7 j5 b2 ?5 h% h3 Q7 m& p        UF_CALL(UF_CURVE_create_point(pointstartcoords,&pointtag));
% \: o( M- x1 o0 R& d' v                double start[3];3 C: M) ~" R! ~8 L. i4 j6 H; }
                UF_CURVE_ask_point_data(pointtag,start);1 c: [/ R% U) q, ~+ s: Y$ [& G! H2 Q
        UF_CALL(UF_CURVE_create_point(pointendcoords,&pointtag));
8 @6 `' y/ ^1 [! n. f$ h& {) ?& J9 e                double end[3];& o8 s5 Y! Z, N: x5 i- o# h& q, N
                UF_CURVE_ask_point_data(pointtag,end);" l# L- e- v% J1 `$ _
        char msg1[128];( _  I" S, Z& v+ A8 k7 M$ R. m
        char msg2[128];
* N1 b! O/ Q. g' a' i* V        sprintf(msg1,"start:\NX:%f\ty:%f\tz:%f\n",start[0],start[1],start[2]);
% q$ i9 ~+ B0 z! b        uc1601(msg1,1);. ~9 l' w/ O* ^7 ?$ p
        sprintf(msg2,"end:\nx:%f\ty:%f\tz:%f\n",end[0],end[1],end[2]);1 ?* t2 ~8 K) J2 o2 z' X8 T
        uc1601(msg2,1);- S, m' n( L5 w& L: N6 x
        //mapping point from abs to wcs8 `& B8 H% n$ Z* g

! n& [- N6 Z; x( R6 v- t        UF_UI_open_listing_window();
3 x/ r  K3 u( s7 H. O; O+ y4 L        UF_UI_write_listing_window(msg1);
* }: x7 G2 u! w5 D5 W% Z6 ]        UF_UI_write_listing_window(msg2);
8 @+ l  c; W4 o& Q8 }2 x       
' u8 D, Y/ \0 k4 i. u9 S; |        //close9 R/ D; c6 s. g! O
        UF_PART_close_all();. Q/ z  W  U, T. w
6 m  K1 B7 q) ~* x
    /* Terminate the API environment */
# L. d4 h5 X- f+ R; l    UF_CALL(UF_terminate());& b# h$ i. x) S% W0 @
}% l" n6 ~  {0 ]2 r& D8 X, {3 J+ N2 {
* w" a( t! ^3 T9 @9 W0 S/ t+ ^" i
/*****************************************************************************
4 u, _" Q8 _) C+ q# c  R  X**  Utilities
- |3 `, V1 D; p% A*****************************************************************************/* i1 E2 a- y% v+ g0 [! J
8 w, \0 T9 l2 d" |0 i
/* Unload Handler
- ~$ _% y( @2 Q6 h3 `**     This function specifies when to unload your application from Unigraphics.4 a1 x5 _' i" g7 a
**     If your application registers a callback (from a MenuScript item or a2 ^) ?8 u/ p- P
**     User Defined Object for example), this function MUST return1 _/ {) ]9 @! z6 Q$ y' |
**     "UF_UNLOAD_UG_TERMINATE". */+ @9 u! v# u% x2 Z! t9 Y
extern int ufusr_ask_unload( void ): L' L5 a( K+ O) J6 Q
{
: W6 g3 M- w5 x( a    return( UF_UNLOAD_IMMEDIATELY );# _7 S% N" n5 j
}7 `" v6 q0 T9 ]5 X

: G) ?0 v& K% @3 L2 |1 y. Y' F' V  Y! Z  e+ I
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复1

gsmfxsmy 发表于 2016-3-20 19:27:35

gsmfxsmy 沙发

2016-3-20 19:27:35

本帖最后由 gsmfxsmy 于 2016-3-20 19:29 编辑 ' q1 F* c: ?; t9 T) \1 Z5 u) \& M6 G

* R- W0 x& D8 A8 p/ SL:\1
5 p/ p9 f" V7 Z1 G
                               
登录/注册后可看大图
3 `0 q. P9 E8 ?& }# d: \( w
                               
登录/注册后可看大图

2 P7 J$ `9 r( Q! T2 j4 L$ {% {' g8 f                               
登录/注册后可看大图
3.jpg
2.jpg
1.jpg
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了