PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

gsmfxsmy 楼主

2016-3-20 19:15:41

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

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

x
/*****************************************************************************2 o8 z5 P% G! ^9 M) W9 T% L( ?! A, J
**
5 W+ }! e1 P4 g& P+ l** creat cly.cpp
2 F) Z4 d# X' x( w! v**
$ {; |8 C$ F7 R6 j! F** Description:9 |  {2 m2 `7 [" U
**     Contains Unigraphics entry points for the application.
. K+ }5 b, ?3 g**4 Z# z4 U# Y  u6 V
*****************************************************************************/9 ^' r, e" V! k! o& f/ o

& {" k$ K1 c0 u5 D, m- |% T  B4 g/* Include files *// U* H- |  {2 @) [9 a
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )" S, t* Y4 ]+ x: _) c
#   include <strstream>
  b& w7 B( R% D8 ]; l# @1 {#   include <iostream>
% P) A7 l# C/ p6 o, T: P    using std:strstream;* L/ b0 M- W7 {* k6 H
    using std::endl;    2 E: g; T. g0 Y0 o5 j, [
    using std::ends;7 }: }: Z6 j( ^! f0 z
    using std::cerr;7 ~  `6 H2 e$ W$ M/ H
#else
& {$ Y' r9 x- `#   include <strstream.h>5 e- ]& K2 v" M3 M( `* r
#   include <iostream.h>' F5 z- w# `, h6 X+ a0 X- V) |
#endif
, T; T0 ^# Q# n  s#include <uf.h>+ i8 E% s$ {% [- S% m7 ]2 S
#include <uf_ui.h>. n/ ^# h6 S. f& k/ R9 [( E1 a
#include <uf_exit.h>/ B( ]) X9 T! n2 s
#include<uf_part.h>
2 m5 E. x6 G: S$ q+ q2 Y6 ~#include<uf_modl.h>
7 b9 N4 V' c1 l# k5 w#include<uf_curve.h>: e+ J0 ]! l3 }3 |
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
0 t/ n, _6 t5 V% t" b
+ ?& h& a" ~7 w- Q' W' o
  ?; W! n4 F4 d% r5 lstatic int report_error( char *file, int line, char *call, int irc)( h* [, c9 {6 U8 s& z
{
& H4 n' l8 j% |" a1 h0 R6 u    if (irc)/ t/ X+ Z' t& I' B
    {3 h: x8 [; R1 M
        char err[133],
2 L: _. T/ M$ a+ t             msg[133];
6 m7 i: K3 g1 j* F3 F) o+ p2 b$ N, r* v8 z( J; I( H
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
$ u0 Y: I0 D3 |7 ~  l: ^* ]            irc, line, file);
+ ]1 z5 c8 D; Q0 [/ O        UF_get_fail_message(irc, err);
! w+ ]0 P  e1 `" x" x8 u8 V( t/ H3 l: H6 K5 s8 U& O
        UF_print_syslog(msg, FALSE);9 B) u8 `  {2 h0 U
        UF_print_syslog(err, FALSE);
3 K, r2 u3 F: r7 A0 }& }        UF_print_syslog("\n", FALSE);
- P# H- I8 O8 q9 n" O. p# d# M: K5 |& x4 G        UF_print_syslog(call, FALSE);
  h: w# y0 p# M! z+ T% N        UF_print_syslog(";\n", FALSE);& N* ]+ E3 Q8 K4 Q
$ K+ R! G: X! Q8 b, u  Y1 V
        if (!UF_UI_open_listing_window())
. h: u4 c8 o7 @3 x, o        {
) M6 h4 I3 ]0 {            UF_UI_write_listing_window(msg);! o- t9 Y% |9 p& y3 q
            UF_UI_write_listing_window(err);* Y% P9 V5 i0 O8 P' l+ |! _
            UF_UI_write_listing_window("\n");
: W$ L: y# H! y8 e# w  b            UF_UI_write_listing_window(call);, L4 S+ M3 v( }/ z( W$ U7 j  \5 V+ Z
            UF_UI_write_listing_window(";\n");( q; l$ e9 O  l( z/ j8 r3 [
        }' V* e8 Y/ N" P/ s+ h
    }: e% u$ w# X6 G$ u$ v0 m# R$ P1 E

! K- S, t6 r: r  p    return(irc);
& T" q/ t; _. I}- D: X& `3 t8 @. Z
$ I" O8 P3 o8 O+ G! Z- t
# p: [; y- u- E5 {
/*****************************************************************************2 |6 l8 v# j# h7 B2 S, ^; M8 H
**  Activation Methods. C$ t2 w8 a1 @; w8 t; F
*****************************************************************************/+ ^: }/ G- j5 Q- q
/*  Unigraphics Startup
* B6 Y2 b/ v. F5 X: Q$ J+ m: y% ^**      This entry point activates the application at Unigraphics startup */
4 \" h- r3 K& @& i. o+ Zextern DllExport void ufsta( char *param, int *returnCode, int rlen )
, }- _5 y% v2 c{3 r' m2 u& M& w& ?
    /* Initialize the API environment */) U3 ^: t& h% p/ V; E' I; ^9 @
    if( UF_CALL(UF_initialize()) )
1 Y4 S1 @  K" }8 }    {! r9 S: B/ w" d9 j7 `- i" m5 j
        /* Failed to initialize */
  A5 ?& b) ~' E. I' N% u        return;
, Q. q+ j0 o4 R% o' ?8 N    }" g) n" i- F( \- K2 i4 V
4 G3 Z6 k2 z( b! k( j6 _
    /* TODO: Add your application code here */$ K! |/ `/ @5 ^' a' I
       
4 R  N% h4 L( ~) e7 v" F3 C; U% R  Z        //new part' |, ]) x; b# f! c0 r
3 {) A- Z9 e5 k; @; }0 s6 Z! ^+ j
        tag_t parttag=NULL_TAG;
$ o+ `% P  t& z* `( k, E/ I7 W
9 b# _: D# i7 L/ X        UF_PART_new("c:\\temp\\plmhome.prt",1,&parttag);
& v& p/ T# |3 x% e; }- }' V% R) t. V) r6 ~5 n  F/ n
        //creat cyl8 o7 e2 U' }: c4 [

) V& l7 B* j  ?& O( T% V                double origin [ 3 ]={0,0,0};
/ e( c" x; [# U4 ?  V& {                char *height={"50"};8 b* o+ l$ @3 a0 P* I+ X
                char *diam={"100"};
1 h  Q4 J' `) ~, Z+ B. b+ {                double direction1 [ 3 ] ={1,1,1};
0 z& p+ n2 g, {& Y9 o& J) e                double direction2 [ 3 ] ={-1,-1,-1};               
0 q$ i- q1 y# t! N                tag_t cylFeatureTag=NULL_TAG;
+ w' `9 t6 G: {4 J; q* d% T6 C0 F- Y. S3 i- [4 k  H0 i
        UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin,height,diam,direction1,&cylFeatureTag));  ?; r* F' c4 A& N, Y( Z# w/ c
        UF_CALL(UF_MODL_create_cyl1(UF_POSITIVE,origin,height,diam,direction2,&cylFeatureTag));6 l6 u2 [# T, D; W' `
        //creat line/ d3 d) P$ K4 K8 j0 \, z) s. t
        UF_CURVE_line_t line_coords;1 Y; L; w4 N# I- w5 J6 v0 ^
        line_coords.start_point[0]=-50.0;% c" |" K  k/ c" k: t
        line_coords.start_point[1]=-50.0;
: e; Y1 X* r4 |        line_coords.start_point[2]=-50.0;
* c7 T( P" U5 D. A+ [        line_coords.end_point[0]=50;
+ C0 O. w& x9 D. D6 u5 j        line_coords.end_point[1]=50;
) s3 u% w% L3 v/ o# N+ L+ r        line_coords.end_point[2]=50;. @! f% t1 b# d6 h$ t1 j
        tag_t linetag=NULL_TAG;
- l2 _) E  ~: ^, w7 F6 J/ m0 U
& a% C& b8 g1 ?        UF_CALL(UF_CURVE_create_line(&line_coords,&linetag));7 b, Y) X; g/ \0 x" H: V
        //creat point( a' h6 G' S- G/ d$ H/ ]- g: [
        double pointstarTCoords[3]={line_coords.start_point[0],line_coords.start_point[1],line_coords.start_point[2]};/ l; D' |- z' r! Y
        double pointendcoords[3]={line_coords.end_point[0],line_coords.end_point[1],line_coords.end_point[2]};
  W% a- a* Y5 T. \        tag_t pointtag=NULL_TAG;
% S8 j1 f# O& i- ^- N& }( P        UF_CALL(UF_CURVE_create_point(pointstartcoords,&pointtag));
" n4 }( Z& p4 N1 \  V                double start[3];" A: J% _2 z# L& X& N
                UF_CURVE_ask_point_data(pointtag,start);
4 M( z; H5 f5 U: J        UF_CALL(UF_CURVE_create_point(pointendcoords,&pointtag));% f  B4 k  U* n5 |; N2 G
                double end[3];5 o7 _- b* q3 M& {+ e/ D1 X
                UF_CURVE_ask_point_data(pointtag,end);
3 c+ \) n  B1 D% Z        char msg1[128];) N+ ^4 K# v. |6 w1 d1 s. w& j  ~
        char msg2[128];# |  b; [6 Y4 s' E( u3 t8 Z
        sprintf(msg1,"start:\NX:%f\ty:%f\tz:%f\n",start[0],start[1],start[2]);
; \) Y5 g5 q3 a" q  C$ s4 S, g        uc1601(msg1,1);
! Q2 F7 n+ i$ D: ^& E9 o/ J: T2 R        sprintf(msg2,"end:\nx:%f\ty:%f\tz:%f\n",end[0],end[1],end[2]);$ [5 I2 Z- M! Z% A
        uc1601(msg2,1);/ v. V1 z7 m0 V" H7 f7 g% j" G1 I
        //mapping point from abs to wcs
% a' R5 a- G& z) w$ o8 E4 P+ T, E% {- k0 j6 K1 \4 O3 {
        UF_UI_open_listing_window();: C- g$ C# h0 L% {- p9 }) C
        UF_UI_write_listing_window(msg1);
! f: d2 E3 F. f6 y        UF_UI_write_listing_window(msg2);
! `4 t" y, _2 Y          j% @  Q9 A% X! ]6 v( ^
        //close
9 L+ U$ R* H# ]- D2 }4 O5 ?        UF_PART_close_all();
' V2 Q! L' x8 \+ k" S. `) c& F
0 O0 M, [9 f. S* \. R, i    /* Terminate the API environment */. e  F. s+ G# w& U" Y+ a: C' M
    UF_CALL(UF_terminate());/ E# a7 y3 O$ [# S
}
5 q5 [0 x- }: l0 h8 H, l5 t- d' B& \4 t
/*****************************************************************************2 f! l. M. X8 w/ x9 ]
**  Utilities
; e6 k$ i. c7 P5 p7 B. J4 u*****************************************************************************/
, H. {4 f7 K; y( I0 M9 ^
/ \) H& x  L$ p( J9 h: X/* Unload Handler7 Q6 n0 F; ~- a2 J
**     This function specifies when to unload your application from Unigraphics.
: J5 c' \6 \$ H. q**     If your application registers a callback (from a MenuScript item or a
9 U# Q6 k  E* s* H: t**     User Defined Object for example), this function MUST return5 X, D1 p. j# v; ~1 _& r
**     "UF_UNLOAD_UG_TERMINATE". */6 m0 Y8 h6 q2 v6 x' S
extern int ufusr_ask_unload( void ), j! u  Q6 s- U, Q, K
{
3 o8 f6 T: v( i. l, P    return( UF_UNLOAD_IMMEDIATELY );
0 ~, T, a0 n8 b& C' v+ Q}
0 t9 L6 _1 [  k+ j0 c& `8 m2 r# S+ S7 ?% ]* K+ c! z9 [

" u( ]# {+ D: H9 h/ r$ X& |, h7 r
上海点团信息科技有限公司,承接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 编辑
" Z" _% K6 q4 f/ C2 d# w5 }& B; \9 P0 s) l$ c
L:\1

! _7 H; U1 M, l0 ~, {( \! ?                               
登录/注册后可看大图
7 F( i0 V3 A; a& x- F
                               
登录/注册后可看大图

' V9 \1 b' g* l" x( u                               
登录/注册后可看大图
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二次开发专题模块培训报名开始啦

    我知道了