PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

gsmfxsmy 楼主

2016-3-20 19:15:41

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

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

x
/*****************************************************************************
8 }. M3 B5 b  N' @8 v**
7 K1 |- O; S! P* t0 E/ x1 h$ g** creat cly.cpp" Z; `) k, r0 g8 [& F* N. H
**; R9 T  l  D' \+ u
** Description:
4 _+ y8 T: R! a+ m: m**     Contains Unigraphics entry points for the application./ R' ?6 a0 R5 o5 A& [9 e1 X9 A
**
! q- Z  b7 }; A, x/ a9 {*****************************************************************************/5 D: x, \" V6 Z6 U# L

" x  F9 k6 p2 m3 V8 ?. O/* Include files *// h* {: ~! G: K
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
  |: P. ]2 N" [#   include <strstream>$ C8 k# m! v8 S4 d: S) x
#   include <iostream>: F" ~5 q6 `# b) o  ?7 m
    using std:strstream;
, e# S  ]6 h+ J& F' _6 V  b* J, F    using std::endl;   
) O* Y7 a" d8 p+ R- L    using std::ends;
) a, h/ i$ X% j2 {7 |    using std::cerr;
6 ]  E( o- Y' S$ }6 _7 M#else+ Q2 N, {: _* n; u5 {& |; p
#   include <strstream.h>
3 J4 [; x0 ], |' I9 Y  l. u; m#   include <iostream.h>4 ?  A* l3 |* L5 u
#endif
  ?2 O! m7 w; X& [. S' T#include <uf.h>  D9 Y9 P3 H* b+ T  g& p
#include <uf_ui.h>" X7 e, w" E9 y
#include <uf_exit.h>) X) y. c; ~" _' [. }( v2 `
#include<uf_part.h>9 B( l; |5 R4 X3 Y7 T& z( F8 e
#include<uf_modl.h>
- }# R  P5 e, e0 t8 ^#include<uf_curve.h>: ^" M. N" X  Y' c0 T3 f$ P
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
( z' z4 N2 h( N% q
# R2 a7 L& S3 l- E
1 p" l. w( ~3 M6 a( A8 i8 cstatic int report_error( char *file, int line, char *call, int irc)$ P( v, d) p$ u; R. i
{
; Y# N4 E. Q- s, \& q0 v$ d, {, J    if (irc)
3 y& z9 X  Y  w& Z- r    {) }. \; ~. c' b# q
        char err[133],& R! h% z' d2 o0 Z& K
             msg[133];  n% e4 G- A/ N, b- r# Q3 j

, l* `" _8 f& [  ^7 J8 S7 }        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
0 m. m, c: h. g* P( \            irc, line, file);" A+ j/ o5 ^7 Q: N5 z
        UF_get_fail_message(irc, err);* m/ A9 L7 m( |$ z/ H0 E4 G
4 u* r  u0 r+ j8 l9 @' M
        UF_print_syslog(msg, FALSE);
( }  e2 ^+ A0 d- T* W: U        UF_print_syslog(err, FALSE);( |% k& Z$ X$ i; c+ V& h1 r
        UF_print_syslog("\n", FALSE);
9 H* K; U) u0 z; O+ y        UF_print_syslog(call, FALSE);
0 N$ i2 g- ~/ j1 Z+ I, G! k  |        UF_print_syslog(";\n", FALSE);2 A8 g+ \! y6 u$ o; j

" D. ~# ?. q0 {- d9 e        if (!UF_UI_open_listing_window())
+ e$ x2 h5 N3 O3 E$ ]4 B# C        {' F! `" L7 D# I* u5 ~
            UF_UI_write_listing_window(msg);
( ?; `: d5 f' o$ {7 D            UF_UI_write_listing_window(err);9 @2 {9 p6 K8 {5 v8 _7 \/ w8 [/ x* v8 O
            UF_UI_write_listing_window("\n");# E: A; o! P1 ]8 q( b- ]: Y" ?
            UF_UI_write_listing_window(call);
" x0 ~8 Z0 ]: a" k5 X4 g" @            UF_UI_write_listing_window(";\n");
7 ]9 H; |( P' E3 u9 y        }$ O5 g5 s: R' q* _
    }
/ N6 F6 M2 [: R8 ?+ p* r. f5 k+ G0 Z  P$ d. @: b) Q, G, F+ Z) W
    return(irc);
1 ]  D" ?5 Y, ]; [2 g8 k, O}; K! y! V( m- d3 P; [9 L
* x6 |# t3 a. M& F8 E$ i1 D
9 C3 l* Q0 {" r9 Y# c" N7 q# P
/*****************************************************************************3 @( W. Q: i' s9 m; t
**  Activation Methods
& p" T2 x% }: r; {+ \7 Q*****************************************************************************/. R* U& C7 Y: e8 B/ `. F
/*  Unigraphics Startup
3 @% F  w& @4 v4 t. E2 V* N**      This entry point activates the application at Unigraphics startup */
' V! b  F6 s: \+ F6 aextern DllExport void ufsta( char *param, int *returnCode, int rlen )
, O2 Z" _) F/ t( p{# G2 f' L) i; W7 E" u8 D( ~
    /* Initialize the API environment */  @! j1 ]2 l! }2 H$ ^0 I
    if( UF_CALL(UF_initialize()) ) 6 ^" T% b( @7 L  t7 f% R, N- g( M8 L
    {
( R; `, z& X$ b; p% b# f        /* Failed to initialize */" [8 f1 F: N! ?. x$ L5 r
        return;
) \9 I1 X7 {7 G. w. T3 {    }+ E( r8 p: e+ u, q

( w. y7 q; b* q* M; B8 Y3 a    /* TODO: Add your application code here */
3 o+ K& v6 b/ {8 t( F" c        ' s5 V2 h9 ~: p; n* A) G+ F
        //new part0 J4 _7 A5 T9 d3 m9 E7 i; \
- Y, V5 L9 B# ?  C* c& \
        tag_t parttag=NULL_TAG;
4 m% Y( v4 p( }! ?% H- k0 m2 O
) j* Q; ^; a7 v/ I4 @        UF_PART_new("c:\\temp\\plmhome.prt",1,&parttag);
% I, i3 b2 ?) ^! _; Y0 t' A, g/ G) D5 n7 A
        //creat cyl
0 d8 K  b4 u! B' P
6 h  b: u& D$ r; \9 [                double origin [ 3 ]={0,0,0};4 c( e" h; F! g- C% D
                char *height={"50"};- N1 p  a8 \9 r$ a4 t
                char *diam={"100"};
: K* |  X, ^  D                double direction1 [ 3 ] ={1,1,1};. s1 _# Q- _4 E8 w2 Y  S3 I
                double direction2 [ 3 ] ={-1,-1,-1};                , h1 Q) q3 C4 c+ j7 [6 E
                tag_t cylFeatureTag=NULL_TAG;
' O# p8 H& e+ Z% Y8 n
2 g$ ?; P. B% k3 J( O6 o- H5 P        UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin,height,diam,direction1,&cylFeatureTag));* a! Q0 \, l' g- d. \* E+ ^2 g
        UF_CALL(UF_MODL_create_cyl1(UF_POSITIVE,origin,height,diam,direction2,&cylFeatureTag));
  G( u8 U3 [& V/ W/ H% L; y) D        //creat line
- a9 ~$ n7 X! Q! a! W        UF_CURVE_line_t line_coords;
" w' V! s* y2 v; Q7 l: I8 S% F        line_coords.start_point[0]=-50.0;
0 n% P6 E/ x1 ^+ D        line_coords.start_point[1]=-50.0;
  S" D: w. o7 ]1 V        line_coords.start_point[2]=-50.0;( ?1 l" P0 K1 J: f) }
        line_coords.end_point[0]=50;* \% v; f6 z" I* z
        line_coords.end_point[1]=50;% ]5 w; ~$ Q  b9 L% ~
        line_coords.end_point[2]=50;$ `1 ?3 A% W2 U1 w( Q
        tag_t linetag=NULL_TAG;4 P/ ?: ], y+ M3 h9 V

7 Q  _# ^0 b# P+ s  k        UF_CALL(UF_CURVE_create_line(&line_coords,&linetag));
9 }) i, _/ Y9 j2 ?        //creat point6 f/ y/ l0 }$ M: _: a& T/ r
        double pointstarTCoords[3]={line_coords.start_point[0],line_coords.start_point[1],line_coords.start_point[2]};
) D5 o( L- ]" R8 J        double pointendcoords[3]={line_coords.end_point[0],line_coords.end_point[1],line_coords.end_point[2]};
; T5 J" P) n- L: [7 M" M        tag_t pointtag=NULL_TAG;& [1 z) n6 B9 S+ {
        UF_CALL(UF_CURVE_create_point(pointstartcoords,&pointtag));
+ T7 e2 Z7 f2 h1 d1 H( T0 Z                double start[3];- N, C9 U* E1 @" T2 e3 \9 ^% M
                UF_CURVE_ask_point_data(pointtag,start);& B* Q. f- z1 J7 q  p/ d& }( h
        UF_CALL(UF_CURVE_create_point(pointendcoords,&pointtag));( b& b7 V9 s: t3 U
                double end[3];
5 B, {2 Z! y" s6 @2 T; o$ o) W                UF_CURVE_ask_point_data(pointtag,end);8 M- P6 Z0 {3 B) z- G0 O& @
        char msg1[128];; o4 p: N6 o5 U4 o/ n8 m0 R
        char msg2[128];8 w3 z1 ~3 p6 A- }, d0 Y( L
        sprintf(msg1,"start:\NX:%f\ty:%f\tz:%f\n",start[0],start[1],start[2]);
$ g8 e. P- V" X- Z  q1 g. p. k        uc1601(msg1,1);
0 F9 {" Z4 T: y8 H, ~        sprintf(msg2,"end:\nx:%f\ty:%f\tz:%f\n",end[0],end[1],end[2]);
" E9 ~) N5 Y9 x4 |  X3 \! y        uc1601(msg2,1);3 B6 m3 ]) D* A2 v" O' X/ V4 G' u
        //mapping point from abs to wcs+ y& z, n1 d; p' L# w6 V4 t
. g9 S- g( D% m5 e( F8 Q
        UF_UI_open_listing_window();
- N! W/ w- O' i8 v6 g9 A5 W( N        UF_UI_write_listing_window(msg1);1 {; d! y+ E# `2 \: i8 P% _$ w. S5 b
        UF_UI_write_listing_window(msg2);
4 E4 e8 q% C0 R8 @) g0 H6 H       
( h9 E- T& m1 Z! X$ G, L        //close# R: _* B# h) S3 `
        UF_PART_close_all();3 S  J  x% ^1 s* G/ W

2 \& r  `' p7 B+ k& V    /* Terminate the API environment */
  h+ G3 J1 b& i8 ?  ~0 y/ I    UF_CALL(UF_terminate());5 [) T) ~% n2 |
}3 {9 P5 Q, A0 X7 m9 ?$ @
0 _, y. c4 g. z& ~0 h
/*****************************************************************************- d* z. y" E+ M! }7 n0 L" ~8 V
**  Utilities
. n$ K* I9 a& W" e*****************************************************************************/' c: K1 e  C5 ]8 z% k, }: B8 y# G$ V& B
9 i6 N4 f% [& {# V+ ]
/* Unload Handler
& G2 N$ w8 u& w**     This function specifies when to unload your application from Unigraphics.: ?" N- @: p6 f) |! u3 D3 I
**     If your application registers a callback (from a MenuScript item or a7 P* {2 Q7 h" y+ q8 F, n
**     User Defined Object for example), this function MUST return
' H. j; B' H) s# s/ c" w! c**     "UF_UNLOAD_UG_TERMINATE". */
3 J, P+ Y9 |7 S. Vextern int ufusr_ask_unload( void )  }* q3 n! v6 x+ j* n
{
3 {6 |) H+ H. S2 k9 n    return( UF_UNLOAD_IMMEDIATELY );
! n. g* S. k: H4 B: i+ \- {) l" Z& N! Q}( A% J) ^" s" f0 d- `# i
) d. t. A$ Y# |
6 i5 X; X% h8 x( l( M0 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 编辑 " N( X4 ^. Q0 q9 r6 W! E
* ?# U1 U4 a) H1 M) T8 q+ I
L:\1

( \7 r9 P! x0 K7 t* x! K2 y: S                               
登录/注册后可看大图

2 I% w& z$ l& r$ G( k. |5 C$ f                               
登录/注册后可看大图

/ q) S3 @) x. p: U8 N) ^4 A6 o                               
登录/注册后可看大图
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二次开发专题模块培训报名开始啦

    我知道了