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

[求助] 运动仿真动画播放

[复制链接]

2015-5-21 22:30:13 3636 2

liuyang77177 发表于 2015-5-21 18:40:22 |阅读模式

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了
& N+ V! Y# a8 t$ h! ^0 {. G" F6 R1 d- `
3 g( U5 I6 V4 a  {" q5 f. k我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。8 M8 [/ U$ [  U$ a2 i  ~8 L# C
QQ图片20150521182535.png ( M; o8 g" M/ g6 C5 B
我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。2 @* j# U/ P* u* k$ h

' r3 W9 O* V0 z3 ^一段ja录制代码:! Z- o( ^0 H$ ]

; @0 J" \' e' S' p/ ^- b        Motion::MotionSolution *nullMotion_MotionSolution(NULL);+ s8 [1 `- |8 D4 F- ?
        Motion::MotionSolutionBuilder *motionSolutionBuilder1;
- ~1 {7 }' L2 j4 `8 L; V        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);
2 h& O4 O$ ^1 j( U+ g- H9 Q& v' [" c5 X/ @. h

/ s! @$ D" @6 M- e1 ~        motionSolutionBuilder1->SetTime(10.0);
4 L! f) g" {0 ]2 q/ Q( q# C- A' |        motionSolutionBuilder1->SetStep(500);
, D! s+ e, I6 z! y% e% W        motionSolutionBuilder1->SetName("Solution_1");4 X1 h* ~% n/ D6 w4 f
        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);
, }% ~& B0 p4 U: d6 d# l4 o6 k& |! M1 @4 R3 z. N) W" u  j6 {, T
8 g4 k1 S+ \9 r* Y2 ~- ?( o
& U2 R! j* A  T1 D. s; E! g
        Point3d origin1(0.0, 0.0, 0.0);
. e5 h' A5 R" a, l        Vector3d vector1(0.0, 0.0, -9806.65);
' w/ O; _& e3 ?, Y- Z        Direction *direction1;9 e1 g: R$ a! N) W  T  y) u. K
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);" n9 @  P; h0 w1 p# N
        motionSolutionBuilder1->SetGravityVector(direction1);6 w2 y1 r- Y4 H) b

: @( [6 I7 g+ L/ _9 x) V; v        NXObject *nXObject1;
% `! m( p' t5 O" l3 l+ v        nXObject1 = motionSolutionBuilder1->Commit();
5 x2 L' @) `' q' U: c7 _        motionSolutionBuilder1->Destroy();
2 M* K' a, v) t$ r0 ~. e. h3 e) I        " Q0 n8 w0 x+ s$ u% p
        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));
' X  |6 f3 D2 @6 t( u% T  m        motionSolution1->SolveNormalRunSolution();  [; ^$ p2 _! v

. O' T- w: R# d1 W. Q2 ~; t( H! n+ v/ p3 b) X

. Z1 X. V/ T1 m% q/ v就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云...1 I: n4 X2 H2 k0 C( ], W9 o
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复2

liuyang77177 发表于 2015-5-21 22:27:05

liuyang77177 沙发

2015-5-21 22:27:05

再补一段前面建立连杆和运动副的代码....再前面还有建立实体的代码就不贴了....就是还想问一下...我的nxopen++里面的实体nxobject和featrue::feature以及body如何兼容ufun函数编程啊,可能ufun函数有一些可以用的代码但我接不上这样子
4 [. V: s8 n5 W* N
2 c; k" h8 T; U0 e. ]8 DPartSaveStatus *partSaveStatus1;
! G$ l: q+ f4 y: ?7 }        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);: y6 A1 j( P9 B5 [$ W; o
& E; ]" J- f5 w5 w" j' X! J
        delete partSaveStatus1;
& A1 |6 C+ s/ r9 P- @4 K1 S3 X, i& Z% O

3 h. z7 V' @3 w; Z( m) O9 t        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");
! K! V2 a7 r/ u- o' j+ V" j9 d- B# R' l5 \' `1 c

/ c. X  V) @9 q4 ?8 ]" S* C3 Z  a1 ^* C5 p6 \6 r$ ~2 g
        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);5 w% S. y! J4 e

; s3 @# z9 H9 y" x( r/ L        theSession->MotionSession()->Environments()->CheckMotorLicense(false);
# B: s  r$ T8 Z6 @6 i( L; S& k* m; r0 w: ^& F
        theSession->MotionSession()->Environments()->CheckCosimLicense(false);
# C1 Y+ B' C% X: ~$ E# N9 P  q1 {! [- w  a# \' \+ J
        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);( y' T/ t9 J  i. A3 m
. `' Z) r1 C5 L# M
        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);% R9 ~+ o7 f2 Y0 x

1 F/ {+ p$ A" V$ k: |
" G1 n8 g0 U. `5 v# ~) Q        NXString motionSimName1;
) Z) W: h8 r# t9 D6 R% u7 m        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");4 c) I4 f- D. ^" U, c9 }
3 b6 r2 {8 n7 g/ y9 g% |) h
        workPart = theSession->arts()->Work();
$ T6 {( n; P2 U' q: l" x6 B        displayPart = theSession->arts()->Display();
$ X; c8 f0 R( a) v' ?        Motion:hysicsConversionBuilder *physicsConversionBuilder1;
* F9 V8 c& W% ~  }+ R- k) H* l# Y        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);$ _/ y) w# J  a2 Y8 w6 R
1 ^# h6 `! {9 d
        physicsConversionBuilder1->Destroy();; F: J& V! e6 A

! ]+ _: }7 x0 r3 t        theSession->MotionSession()->InitializeMechanisms();
2 @3 p# U1 f' g
( ?: S1 {: T7 p( \2 l        Motion:ink *nullMotion_Link(NULL);& f. B' v2 ~, b3 L+ `7 ~
        Motion:inkBuilder *linkBuilder1;
, H6 L: _4 m" k) [        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);; ~/ z' e6 T* F6 r- S5 _: T
. ?, j7 ~7 O& F2 c7 Y; X
        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));# q! a' A# y  l5 f! w& ]8 S

; ]) ^( X! j1 H) n, [% w5 ?        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");
1 P0 @- @: A) b3 ^/ e- _
% j' H( l8 B2 P        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");
- g. `8 N+ ?- ]/ g3 E
  G0 k6 q% l3 {( d" ?        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");
+ h; S& h1 P3 f' q2 T& T1 i7 z4 M7 J: A* {& x. W
        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");0 u! d9 t3 `" r- h( x

5 j9 w' A# q0 b, U* Z0 f- Z% y8 W        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");
3 |* _1 H8 z( y
* _/ H5 \; r6 p: A        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");
8 [7 U0 v9 T5 F, G6 J% }0 s- p9 J
1 t$ d1 n0 f6 n9 e        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");
3 ^- a! ?9 j& t6 [5 L' n& F+ b% R( F; o# ]+ y& w
        1 S( N. \# m/ j
7 Y% y; M& C) [8 v
        linkBuilder1->SetName("L001");1 E8 o! ]4 V+ c2 m& _9 t/ C

0 F! l% P( K$ @. N: P* M  z- c- \. `; K; f0 d/ b) \! i
        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));
& l: I5 k; J2 `+ k- Z        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));
0 T6 ~( l% C4 l% b" Y+ Y        bool added1;$ ]2 N: A7 _/ W" ]
        added1 = linkBuilder1->Geometries()->Add(body1);
5 g2 @: h3 K0 O% v% F
, W: x; O3 N( v( i0 Z2 C- @& R' L        Direction *nullDirection(NULL);5 y# ]) H. d; F) g
        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);& Z7 r. O0 \& F" N( b6 x" Y9 L/ [

! F' C# {6 m  b0 _# P5 C        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);) M1 n3 t! a% q8 t
) k7 |7 `( G3 v- D
        NXObject *linkObject;4 j3 t' G3 n3 |: j
        linkObject = linkBuilder1->Commit();
1 q. n6 [& f4 S2 Z
7 M4 U3 F" `$ W6 Q7 r- W3 N( ]! Q1 @. Z; \+ ~) G/ U# a
        linkBuilder1->Destroy();2 x" S% x" d/ K2 j
8 F6 c7 Y6 \  g2 L# F& A  h
0 v7 R/ [% w; U3 p3 |$ o

& J0 s/ v. L8 ?
/ W& s/ v. E0 F2 n/ j( S) t9 E       
/ |$ I0 R4 x" f  Q* w- c& _/ `, R2 j
        Motion::Joint *nullMotion_Joint(NULL);4 s2 k7 |. x' m( {6 Q
        Motion::JointBuilder *jointBuilder1;" o: `, K, H) g8 H8 ~# M
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);" Z$ n: t/ W7 v8 q1 R. i) e
" H9 J; h* D1 K; G+ y6 l4 r! K
* Y2 ~, _& N7 Q: {+ _
, l  u* R2 {4 g0 i. I
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");. k8 ~! ~. B; W! ]0 r  v4 H
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");, F0 v, W7 {2 E1 O: M' l
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");" }( c2 W8 t/ o$ S7 H, o, O# T$ ?6 X
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");
; J2 G  t7 k7 H6 |        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");$ x5 h% T; f1 k: N) }0 P
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");
: G7 P' T; `5 E0 a" I" G8 {1 A  @* f" |) a- w, C! F5 ~  r+ w
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);" D: I0 C; x) m( K/ Z
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);1 \( T" f7 z" a5 n
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);
0 S. z5 X( o8 U( r$ i        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);- O/ Q* ^* A; K" `' H; n
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);, e6 A$ l8 d9 C: O6 ?
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
. H5 y# h" O4 \+ o$ s        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");6 u: u5 W& }7 Z- d2 [  P! o1 O
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);2 I, g( a% n5 A; @8 p9 z7 Z
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");0 M4 r% l0 U+ k6 c
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);
' \- s) [' d2 v+ _$ [        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);9 z; @2 z# B; S! c" `3 F! ^

, `. g  u' Q  y( F2 E! K" L& Z        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));
+ l; ]: O! {8 s        jointBuilder1->JointDefine()->SetFirstLink(link1);
+ W6 N$ ]% {3 v) Q' L0 f% i3 A
4 A5 b: K6 k4 b( h3 l: t0 w0 f
        NXMatrix *nullNXMatrix(NULL);$ H! s; o7 C. I
        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);, N+ H5 |* Q3 t3 I  A) U

+ F8 y) K$ l1 V6 G' _( S- Y        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
7 O( ~& Q1 Q6 e3 S        PartLoadStatus *partLoadStatus1;
, x' s7 p7 q& u( F2 \- u2 U! b' [: ^        partLoadStatus1 = part1->LoadFeatureDataForSelection();
: K* l  w- L# o4 K+ e3 g9 U$ _# q+ Z2 G1 }2 S6 `
        delete partLoadStatus1;( }& B. ~8 I9 ~
        Scalar *scalar3;
& ~: s. Q4 c' p! l; y' t$ r        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);. b5 m. Q: j6 b4 u' V

4 [9 S5 b0 t! n3 ]' U: i7 c        Scalar *scalar4;
( E% K" A6 p8 g( C2 A8 s0 ]        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);1 e, p0 f" C! Q; {6 m1 q/ h
0 P& J9 J' A, s$ W$ G+ P; ^9 u
        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));
* X, O% G" o( M& H( _5 E- d3 |4 ]        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));7 S( F4 F6 `% z$ V$ W: C5 ~$ a
        Point *point3;
  B, S& E% \  U, ?$ r        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);2 [" ~9 {1 D" d$ [

, [& Y. G0 r, v$ c: {, v4 N, _8 {7 q3 i3 u
        NXObject *nXObject12;
  e9 l+ C# A; |  c' [& m, [        Xform *xform1;
* X4 I6 a; y7 L3 L. e# W        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);' N$ P/ _$ Y/ T' y/ L% n
0 m: @! @% C5 {' C# g
        Point *point4;
& W) |% ~5 f! B8 c9 J& R3 p& x        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);( Z4 Z" D+ b: F/ K) s, G

( B- Z  B5 K6 Z: H# q        jointBuilder1->JointDefine()->SetFirstOrigin(point4);
  U/ d, _3 ?( P3 T" T0 D( M; g: o: O* \- o0 T+ @+ f0 g7 u$ u5 I, J
1 u0 _3 l! \8 z( @/ u9 [
        Point3d origin1(0.0, 0.0, 0.0);
2 f1 o3 e( ~4 N( e        Vector3d vector1(0.0, 0.0, 1.0);2 O4 e/ a1 U7 I, X( L
        Direction *direction1;! F4 a( }" G& M# J1 o
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);
6 g* G# e/ s* o6 M) z$ p
5 C/ L2 }% ~4 e" D  t        jointBuilder1->JointDefine()->SetFirstVector(direction1);4 Y/ U1 M. ^. e% Z' x

3 V0 X6 o) J% l% _- d        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);
! t* f/ Q, v) Y* `3 S8 T. R) `; S, W8 J/ c, y8 c) [  H  n
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);( e* Y  s# D3 U  Y4 }5 I' ^$ B

6 ]& g, S0 d7 T2 y        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");
( |% T# ^' i$ k0 Y) E( b! J$ ?5 @' D  q5 n
5 d: X; x# X9 n' N0 h/ l1 h
        NXObject *nXObject3;
4 |/ F$ P4 G; i$ n& G        nXObject3 = jointBuilder1->Commit();
/ x* j% P" I% S  x! ~
4 `0 E; g# U/ @# [        jointBuilder1->Destroy();
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

liuyang77177 发表于 2015-5-21 22:30:13

liuyang77177 板凳

2015-5-21 22:30:13

为什么会有表情 - -!
7 l+ w$ Z" c- ?" r0 A2 A4 L& j8 |- e+ ?3 Y# }. u8 K5 H7 }
有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
3 X( n: }; B5 r7 |9 x) D5 L
. z& f& ?; P, g8 ?( l.....  p; d3 t( g+ Z( X
, K4 [2 E7 H- J' V, p' s( E4 I
UF_MOTION_init_articulation();
  h+ w% y& t. l7 bfor(int i=0;i<360;i++){$ a& w6 o, H" R1 M5 d
  UF_MOTION_step_articulation(1,&i_ret);
& k" v2 d  @1 L! x( A}
. L% U7 ?( f% u( n+ n) v! \  cUF_MOTION_terminate_articulation();
# w! }4 M$ M+ a% A8 x4 mUF_MOTION_terminate();
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了