PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

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

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

[复制链接]

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

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

gsmfxsmy 楼主

2016-3-20 19:15:41

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

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

x
/*****************************************************************************; L& K1 h. Q; f$ G1 s# m4 U+ ^$ m
**8 [" Y; D) @6 u
** creat cly.cpp
- X8 y. A" ~% k$ o: c) G# R1 y# u3 t6 d**/ H" r% J% I% C# h
** Description:  }5 G( x/ a- i9 Y9 u# i
**     Contains Unigraphics entry points for the application.
+ f; a; W) d' y**
, S8 c0 |! ^: M( w  s9 ^4 \+ h) \*****************************************************************************/
! r! W' k& _2 O- k
# K' j, J/ ^/ C* Q8 w7 z: \/* Include files */
% X; H  P' d. }) |1 R+ D. z#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
1 I' s& c2 W) X  @6 P% L9 D6 o#   include <strstream>' D  W. e5 ~; c: [  m+ C3 Z! E( @
#   include <iostream>
7 A2 r3 S" G) i3 T2 r! ?$ A    using std:strstream;
2 ?6 L- [7 S2 |- ?0 z* R9 Y1 D    using std::endl;    / D7 o$ }; j$ O- H. F! a
    using std::ends;
0 F8 r; [0 x, T, [    using std::cerr;% k4 k4 N  A) |2 f% y* H# S
#else2 ]' P" F3 ~% q3 V: f
#   include <strstream.h>. \: c( M- ]6 P: x# u
#   include <iostream.h>- @( A( |1 g4 w; K. m2 e
#endif" M0 f+ N" h$ f# M
#include <uf.h>
. z: h9 Y" x7 t! {3 t& b#include <uf_ui.h>
( |6 c# W, t( L+ [+ s3 @+ D, N$ V#include <uf_exit.h>, B( x0 f" A+ c  U; Q8 e5 V& w* R
#include<uf_part.h>
- x" J% s; {% b#include<uf_modl.h>
% ?& ~- ^5 R$ n% p% S#include<uf_curve.h>
9 Q& c, j4 v& {# N#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))$ ?, X" y2 [# |

/ d* d0 F" G# ^  P9 V1 h  r  {" t; _- _( |
static int report_error( char *file, int line, char *call, int irc)
, O% j) G: g, v{
* e# b- c4 T5 y    if (irc); R/ `; S) j, q+ J7 W  I
    {
! h1 l5 ^5 {/ S, v8 i) @# c! ^- _        char err[133],  D+ d# `7 e' u- L. f$ J- Q
             msg[133];
5 w, P2 d. Z- v3 _7 L% I' v
9 C" ?; z) M9 F, K; D4 z2 A        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",% v! _- U3 Y1 F7 x
            irc, line, file);. g# R, p' g5 v6 W! J- C
        UF_get_fail_message(irc, err);" ]9 w( F& U; o0 d( i% ], Y
! Y* `6 i7 R* ?# M) Z
        UF_print_syslog(msg, FALSE);' L- a6 N; x$ B
        UF_print_syslog(err, FALSE);& I- ?( d  Q! M' }: w
        UF_print_syslog("\n", FALSE);
" \) ]+ ~" `- ~# W0 }- K        UF_print_syslog(call, FALSE);, e+ t8 i; l: `3 ?
        UF_print_syslog(";\n", FALSE);7 ]: V7 k% j2 }. }4 r* L
" M% Y1 P% O: I: x5 Q1 C
        if (!UF_UI_open_listing_window())- z2 \: p/ P  \; E
        {
  N; u: o+ r) M3 n            UF_UI_write_listing_window(msg);9 x$ Z3 z! M' V: d0 e) `1 {
            UF_UI_write_listing_window(err);
, R" X3 J) `5 D' |# M            UF_UI_write_listing_window("\n");# C, L2 e+ c: a
            UF_UI_write_listing_window(call);
9 ]8 j5 G" g; V            UF_UI_write_listing_window(";\n");
+ m' C3 P- M+ H" C" T        }
2 Z/ X( M8 k& K! n/ `+ W7 U8 q    }! J9 [* S( j0 H% N( z9 w- _

" ^' p1 g' X3 S1 S) k7 [! t0 X    return(irc);
( E( S; w: e5 @5 A}9 T$ V+ h! j; y! N5 T
7 a0 n) |* b7 d& C: h
% m2 `6 F8 t7 n$ u
/*****************************************************************************. {& H: s! |, W. `) R/ H3 B
**  Activation Methods/ j' K. d" F: w( X+ U( I5 u$ u
*****************************************************************************/" u, c% O4 H: n8 I5 T
/*  Unigraphics Startup
2 k# c1 u4 \) R1 e& l**      This entry point activates the application at Unigraphics startup */
6 u8 V8 Z$ b& D! h+ ~3 Kextern DllExport void ufsta( char *param, int *returnCode, int rlen ); r1 u  j5 A  G8 w
{
( _" }0 ]# a4 \    /* Initialize the API environment */% V. c) n0 C8 t+ l0 B2 B
    if( UF_CALL(UF_initialize()) ) 3 A) R" L8 r3 [' j  l" M# P
    {
- l: v( O4 ~' o  x9 `* N        /* Failed to initialize */# K) ^* V$ I0 x4 W  Q% O
        return;
& i3 q, J3 V( ]3 N+ K% c" R  P, z. `    }- \$ U  [6 Z# N& O" t# ^/ e

0 ^2 u5 c, C' ?    /* TODO: Add your application code here */
0 k, d  k% s. W. b* R9 P4 D  _       
/ S( l7 I8 ~5 {( d        //new part
. H3 C1 ]9 w8 v! `/ M
& S- V* C/ M2 G5 s* {; N% G1 n        tag_t parttag=NULL_TAG;& l2 U/ z( s/ ]( M, ]' a% J0 V' C
+ L' H+ X1 a5 V. M" Y
        UF_PART_new("c:\\temp\\plmhome.prt",1,&parttag);1 n8 t$ B5 |! C% |
. B0 A2 q; U* B
        //creat cyl8 N$ U8 _' d" H/ H# K: x% W
, [  n, Z1 R' G
                double origin [ 3 ]={0,0,0};1 O$ S; G* z) Z* K
                char *height={"50"};1 A  _" W0 P9 N) t2 v' }
                char *diam={"100"};
* q  d6 o8 m! w; H% F) E! \% m9 N                double direction1 [ 3 ] ={1,1,1};: U) ~. v9 A; a/ T: i
                double direction2 [ 3 ] ={-1,-1,-1};                . t) p3 b1 s# N  O
                tag_t cylFeatureTag=NULL_TAG;/ Q- z8 M7 j; G1 z/ o

% x$ |) _1 }) |& f# a# k* P        UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin,height,diam,direction1,&cylFeatureTag));' `1 W2 q# R  D$ ^: i
        UF_CALL(UF_MODL_create_cyl1(UF_POSITIVE,origin,height,diam,direction2,&cylFeatureTag));: x: P7 E8 ^! z, R- I  Y/ i
        //creat line
, j# w& ]. T# K9 p, ]        UF_CURVE_line_t line_coords;3 ?" t+ J6 U1 _
        line_coords.start_point[0]=-50.0;4 K$ T2 z( `( U- }
        line_coords.start_point[1]=-50.0;: }6 Q1 h/ v- _0 Z1 n; v* {
        line_coords.start_point[2]=-50.0;
/ I/ U- w6 [( j        line_coords.end_point[0]=50;
% T+ g$ }; ~- N& U        line_coords.end_point[1]=50;; M/ d- ]# `3 _
        line_coords.end_point[2]=50;# I7 A7 T1 l. `4 t; Y( D5 x  X5 K  p
        tag_t linetag=NULL_TAG;
2 a. E$ f: n  _4 p/ r0 ]% ]0 ~! u
0 P: h, Y  k$ S& w& j: G6 \$ X        UF_CALL(UF_CURVE_create_line(&line_coords,&linetag));, d+ E6 t! _+ i4 ?. \# g+ j
        //creat point& ^# _- x5 @8 \, r  u3 G
        double pointstarTCoords[3]={line_coords.start_point[0],line_coords.start_point[1],line_coords.start_point[2]};0 D- l. b0 C, ~: h. A# ]6 d7 F
        double pointendcoords[3]={line_coords.end_point[0],line_coords.end_point[1],line_coords.end_point[2]};
5 O3 @& F! ^3 Z5 n6 k        tag_t pointtag=NULL_TAG;  h2 E" G  Z" [- f, o" x. y
        UF_CALL(UF_CURVE_create_point(pointstartcoords,&pointtag));
* o; ^& i6 N5 ~6 e                double start[3];4 w  S9 h# s: u( s
                UF_CURVE_ask_point_data(pointtag,start);9 M8 R% ~9 C" B1 L  l4 c% z4 z7 k
        UF_CALL(UF_CURVE_create_point(pointendcoords,&pointtag));
! ~1 R5 E0 L; t1 b& R/ K& G' X                double end[3];; y) A- ^- c6 S# e5 E
                UF_CURVE_ask_point_data(pointtag,end);7 B8 X/ N% ?7 a; O: J
        char msg1[128];: A, y: K) n  c) u
        char msg2[128];! ~( [  A& _) j: N6 x
        sprintf(msg1,"start:\NX:%f\ty:%f\tz:%f\n",start[0],start[1],start[2]);
" q* X( {3 |5 v# w& E6 _8 W        uc1601(msg1,1);$ ]2 k  V4 w; E$ h+ l+ k, ]
        sprintf(msg2,"end:\nx:%f\ty:%f\tz:%f\n",end[0],end[1],end[2]);
* g9 C: v2 a: D        uc1601(msg2,1);
2 I. n$ |3 P' B* X        //mapping point from abs to wcs
  s+ J. t. ~$ k% b7 }# J: i% `! J: A8 V: B% _& ^
        UF_UI_open_listing_window();8 t8 v  l! ^: u) E" j: p. Y
        UF_UI_write_listing_window(msg1);
. g: R  x2 L. H; K# ]$ }        UF_UI_write_listing_window(msg2);5 f) J* E1 X6 ?. A" S4 c7 D2 j
       
4 T. ~# R: R' [" K" P        //close( B$ X8 g- s, A, j3 d
        UF_PART_close_all();* U1 v5 j, z$ P1 \

: }! ~! |9 Y/ i    /* Terminate the API environment */, n7 P2 h' ]) f8 {7 E/ E
    UF_CALL(UF_terminate());
" g7 y' ~! J+ P2 h% Y# R. o1 A6 R, P}
. T  W8 d  Q& r- A( L5 p  N9 O. T
% {- {8 e8 P1 ^* i$ u/*****************************************************************************
" i, a7 w/ ], k; |) r' `, n**  Utilities
; Q( L" `! f9 V4 W' p*****************************************************************************/
* m: l0 }  H+ ]/ m5 C$ J+ C0 a8 p. X
/* Unload Handler( s: \; K) G" J6 m/ q* c# b2 Q
**     This function specifies when to unload your application from Unigraphics.# Z2 J1 f# O& ?3 _: F; a/ s
**     If your application registers a callback (from a MenuScript item or a5 C+ N' i+ ]1 l( c. E
**     User Defined Object for example), this function MUST return% l% s1 A, n8 k3 M6 [
**     "UF_UNLOAD_UG_TERMINATE". */) Z5 H! [( R6 B
extern int ufusr_ask_unload( void )
" N0 H/ T1 h6 k{6 a" j& h- O" j1 n/ n
    return( UF_UNLOAD_IMMEDIATELY );( B. S- n# i# {& ^( u. X& R
}
2 s7 N( `3 Q3 r
: t) r8 ^) Q7 [0 ~" r, k: m; [6 @  d1 Y# b2 W) |1 S* a& ^* G
上海点团信息科技有限公司,承接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 编辑
/ Q! a2 V3 v( Q$ i4 h2 j5 X' v. n, L  a! C# g9 C* l
L:\1
3 K# \6 y, t8 n; y
                               
登录/注册后可看大图

) Z9 U( X* g+ o/ C                               
登录/注册后可看大图

0 M% k0 {' Y7 x# B1 t; w! M                               
登录/注册后可看大图
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二次开发专题模块培训报名开始啦

    我知道了