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

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

[复制链接]

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

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

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了
9 u7 h: T: L7 G1 E1 c8 j, K. X! D% O- A
我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。
9 b! N, A$ y5 C+ Q" B4 }1 m QQ图片20150521182535.png
) ~2 S- z6 h( _1 q- V& r我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。
; M4 z: M" P9 s& C3 q
1 T7 p; a8 E) R1 h6 f& B一段ja录制代码:
: l6 U  i$ q, y. ~" i; T" a3 |6 @) D; {
; J& J& e- d$ X0 n$ z( Q" z% l        Motion::MotionSolution *nullMotion_MotionSolution(NULL);
5 v+ c: @( s& @- x1 {        Motion::MotionSolutionBuilder *motionSolutionBuilder1;* ^2 y1 \4 w6 K
        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);% w& M$ A; e, g6 @
; c/ p  a* A7 c; Y% o" S
6 k& a1 _% U- w0 P8 ]2 c
        motionSolutionBuilder1->SetTime(10.0);+ }! }8 J# L+ x, T# X! {
        motionSolutionBuilder1->SetStep(500);& f# Y8 M5 m- a* Q0 c8 S
        motionSolutionBuilder1->SetName("Solution_1");
1 q! K+ [6 D! C7 ~5 [- ?        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);
! r- ]4 \8 j) }0 o& f
) H9 g( \0 o# L# y4 D" C0 E2 g/ ]) T$ I$ J% Y( @/ g: `

! C4 C5 T( d) t% k        Point3d origin1(0.0, 0.0, 0.0);4 J7 [5 `7 r) x" s
        Vector3d vector1(0.0, 0.0, -9806.65);! h. U6 L+ `8 \5 N' G+ w) F2 S
        Direction *direction1;
7 c# n, B0 e' ?& C& }6 y        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);! j$ ]& d  D: F6 ^2 P  f5 `) K
        motionSolutionBuilder1->SetGravityVector(direction1);. V  p( R8 D- `( S$ f

) L9 f5 J, L( c        NXObject *nXObject1;- x, h  a  Q4 `0 j6 c
        nXObject1 = motionSolutionBuilder1->Commit();
4 U6 a, j) p0 k4 I4 Y" m        motionSolutionBuilder1->Destroy();
" F/ z8 q( N* k        ( a3 c/ W3 ~0 g; `0 N
        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));
" Y* y2 O9 x4 f        motionSolution1->SolveNormalRunSolution();9 J# S1 Y7 c# n! G4 p; \

4 M) u4 G. S, D  a7 ?- @" A4 l1 u% g. O: Q# Y3 I6 \
3 ?. }9 P; [+ ?" N! T2 i
就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云...
7 U5 O$ c$ v& S) t0 ^1 T, L
上海点团信息科技有限公司,承接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函数有一些可以用的代码但我接不上这样子
1 v1 O0 U. y3 |
# E0 i2 ]  c, J6 J( W, m0 T9 vPartSaveStatus *partSaveStatus1;" @1 p4 j8 A+ V! n2 n6 }
        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);
$ Z2 M) \1 X& W
0 ?' m6 r0 c+ o1 {        delete partSaveStatus1;
% ^5 D" y. t. j9 y+ @! h9 m+ P; H6 K# b1 C- N; y  r7 l5 s; E0 k

5 z+ }4 S. U7 g6 t. s: @/ I! Q        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");
/ S# D+ {6 t: b
7 B" q. ~. b2 r
& @9 b. i. a2 v% T4 p! k
+ p/ L: [$ @, _# R        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);
! t; S" f7 q) ^. N: m# ]' i4 ?. a7 Q5 S
        theSession->MotionSession()->Environments()->CheckMotorLicense(false);. ]* Y& k! f7 [2 I8 @$ G& x& J" D

( y  E6 K, ]6 _& P% Z7 N3 T4 s; ~        theSession->MotionSession()->Environments()->CheckCosimLicense(false);$ Y+ F1 o( ]9 ^+ P! b

* q7 M( E( e4 h5 \        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);
7 Z, `3 @+ `; T' P
+ m6 g% j7 F8 L% e9 e        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);
6 ?! G) Y1 K9 s; J$ ]  l9 P* Q7 g4 P9 [  W# D7 n/ E
6 ^: A2 f- w( e2 }! j' O4 u
        NXString motionSimName1;
5 @0 [8 B1 M5 ~0 F, a* x: R& H        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");
4 ]& D7 ]2 {' Q. S$ l: V2 V
8 p9 t8 |/ A* f& B' O9 j* Y        workPart = theSession->arts()->Work();! v; z* b! ^% z6 M) P& R/ c2 e0 X
        displayPart = theSession->arts()->Display();
8 P0 v+ p' {; O1 s, {" q/ \        Motion:hysicsConversionBuilder *physicsConversionBuilder1;
* c( D  ?1 y9 Y- _' v        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);/ t* V8 x9 ]2 Z: f% y/ B

8 l: r9 Y' d. n1 S        physicsConversionBuilder1->Destroy();0 @. ~2 L# F8 E6 N9 L' ?

, h7 V; w/ V9 U. f; n$ J) l: F        theSession->MotionSession()->InitializeMechanisms();
0 V# V; e$ ?/ v1 D( A8 [+ u$ t" l9 m5 b8 K: y
        Motion:ink *nullMotion_Link(NULL);
, g7 b  v3 J% l/ p* k        Motion:inkBuilder *linkBuilder1;. z+ t) ^  g) Z9 Q9 `2 Y: g& ?9 v
        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);) X# q; X0 E0 ~% H
6 G: q6 G4 N( l( p2 H
        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));
% @0 `+ n( J- W: _
% O0 H, V8 K3 w9 Y- O3 q        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");/ ~' x8 ?2 Y4 y7 L& r4 u4 d* d
. }: W7 Q9 e' x, o
        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");; Q9 N& \- @; r8 ]/ N
. g; S) L1 r3 h- ~. o2 [
        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");
: ?# B. S# o1 G- K2 J: [! b2 B. n$ @# ^8 s
        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");
% h+ O0 N$ r9 ~3 w
# p  J( H* k9 v        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");
; g5 p6 ~) Q6 u5 v* _  d
$ `$ X& W" d* l- W5 g; @" s: Z# K3 P        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");6 @7 M/ K; I. x. S
0 w# C$ q% ~; j: H. C/ m
        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");
! |9 d0 I; T1 q6 W. h9 J) e: {+ \8 Q: ^& {7 d) K5 G
        , J/ @3 f0 q7 F% @  S. j
6 P0 q: N! o  u. [& U& t
        linkBuilder1->SetName("L001");1 F; h% O& M" u! R1 i8 g

3 @9 W8 q9 k* H- K& n
- j& g) p# p2 d- u* l8 I$ ]. D        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));. m5 ]+ j5 \3 X8 {) B0 T" l
        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));
9 o# W$ o, H6 \7 T; E# n* i        bool added1;- R2 C6 R; Y$ ~2 Y
        added1 = linkBuilder1->Geometries()->Add(body1);
# Y0 V7 T3 y  k: K# Z. x
7 S- A. T. s9 c1 f* {# j4 ?        Direction *nullDirection(NULL);
  b* c/ j+ \& ~4 Y" E. z# a        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);1 s8 Q+ v3 b+ Y+ Y* B% h- t7 P7 S  H/ W

0 |" d6 n9 N" I1 F0 u1 x9 Z& G+ L        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);
7 k; i+ I8 H; Q/ q' c1 z+ v8 H. {, |; k& }
        NXObject *linkObject;+ i6 Y1 o* n/ i2 n
        linkObject = linkBuilder1->Commit();
  e( j/ }' ^. {0 J8 @- T
! E9 m, h7 K6 o, H) {( U
. n2 `- }/ j- w0 _        linkBuilder1->Destroy();
1 o( z1 ^6 x+ S) P
& [) O0 ?2 g+ F: s1 D! _% R5 o2 I6 ~9 W3 O6 i# a
; i8 H+ }& Y8 N  N
9 @  R6 b2 d* A# K. y' a. S9 L
       
0 e1 E7 n7 F+ E0 W- a; W3 ?
1 P4 E; [  z' N7 b" F/ B        Motion::Joint *nullMotion_Joint(NULL);
; R. d& c- r5 D8 P        Motion::JointBuilder *jointBuilder1;& V3 `. Y( W2 }4 G, c* p7 @: ^
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);  A  L$ {8 o5 h- @! u

0 I4 n5 k! v6 N, d# E/ v* R( x6 Y, k& @" }3 z, q
4 A% M2 L0 u$ D, \8 M) z
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");
1 Y) v' p: N/ {7 l; x        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");5 o4 E5 Z; _2 H- s6 @
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");
! n% Y! w) q1 [- T+ Z( f: r& H        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");8 r$ p$ M. X; d+ k) X5 ?% T
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");
% Y$ q' L; _" G* {/ \. M        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");
  \7 e, ^$ E0 y9 s/ F) N# f) P: w" c* k
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);' h5 O: t1 y! P0 \" P3 C
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);8 f. F; N5 \2 _. V
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);1 ]5 v3 w0 R. L! K
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);2 J* [/ {0 T! V4 A+ J- `
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
6 F1 B' a1 M1 r7 W2 q8 T; `6 A        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
; c( g/ z+ D5 f- p* Y4 R        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");0 g# O# O6 K3 _
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
$ |( d4 ~- [2 Z& C0 r        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");
7 w. ?' M. K% @        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);& f) v# ?% _) ?% q
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
, s3 I+ g6 e% I' j! i( t( q2 [  v, U1 r' s/ @; C- [! g2 I* |
        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));* P( G4 X2 ~& H! }. F. \. _7 Q) |
        jointBuilder1->JointDefine()->SetFirstLink(link1);/ M& `9 _# e) b# c) V; \
: m  y  B2 r' k7 e( A8 n/ j% N
6 P- Z' K" V8 I3 @
        NXMatrix *nullNXMatrix(NULL);
+ g8 o$ g& [; L        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);; E+ a; P1 W* y) L. M( Q0 u/ ]; W( ?0 P
6 y1 N1 Y& P4 p" b5 O
        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
/ Q* o" ^: c$ f* l        PartLoadStatus *partLoadStatus1;
  J6 \6 b% P* X        partLoadStatus1 = part1->LoadFeatureDataForSelection();6 J) \3 X% V( j0 ?7 `0 d3 |
) |9 n1 y9 J, n% I
        delete partLoadStatus1;
  v, [; M& x3 p' c4 Y& Q        Scalar *scalar3;
$ r5 A6 b5 Q0 x5 O' F0 x7 Z6 I        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);" K- j  j4 G6 {& p& S! |
! ]0 b" L2 S, B0 V
        Scalar *scalar4;, p  b: a; ]1 |+ T& m/ k
        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);
$ u9 u+ }3 P6 h
! v  g: u% C! {  A0 n! i        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));
2 n  ~( C7 v& m9 U( f" A; @# l        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));
0 |& @7 V" u% Y( J8 b5 i        Point *point3;0 i7 N/ y+ U" {( R
        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);" U* w" N" n. k" C% a$ r

9 c8 \9 U* L3 `6 X" Y; `% E8 E  N/ g9 l+ a% `
        NXObject *nXObject12;  o% T; J' k. f: X/ I% f+ {6 i$ E
        Xform *xform1;
. @9 ^( L$ F, f7 D3 d+ j        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);
: p, n+ Y1 z* g, f4 l+ z$ p. l4 T
* {: i8 \& n  D  t        Point *point4;
) Y5 l2 \' M" q3 N. L        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);# E& t- S9 S) \, B9 P
: c5 T3 ]( E' c  }$ C* P% a/ m
        jointBuilder1->JointDefine()->SetFirstOrigin(point4);1 I( O6 b* Q7 B

8 o5 {5 g# ]' K/ d$ T1 \7 h% h. k0 A% p0 m8 [1 n1 [7 u
        Point3d origin1(0.0, 0.0, 0.0);
/ H: g+ t7 A8 Q9 p$ \3 d        Vector3d vector1(0.0, 0.0, 1.0);
3 E5 t' O9 Q( _4 I0 @; [" S' `        Direction *direction1;
7 }7 ^+ X3 @+ V0 d: V3 U2 ^        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);0 D5 Z5 C9 Z2 i3 n  k5 e8 E
  s) v9 K- q& D  M" y! a6 c
        jointBuilder1->JointDefine()->SetFirstVector(direction1);2 \5 U; y; O6 D; `
( }5 `6 j! u% t
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);4 k# I5 {) U8 q. X
7 }8 m$ I" ^6 j  J
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);, L/ n5 s, D2 ]

  I' M  k, z4 v$ w$ }        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");( \) x( q" V1 B0 }* f6 Z

8 [, ^' m9 n; ?" g) s* \" M( q6 p2 y3 A( F# C1 c
        NXObject *nXObject3;% W0 \- i. O, M- x1 I) q
        nXObject3 = jointBuilder1->Commit();
8 i9 z! H/ j) b4 n7 j' ^4 J/ R& M6 ]5 F6 h# @+ q
        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 ~9 j! I5 c# m7 l+ a, J' r1 H: b# A! c2 n% D  t6 Z  g3 T, T
有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
% Y7 w7 P# T# m) p  u1 I: G! k* C7 B. v9 q& j9 I  V! u  B
...../ m9 J: s6 L7 A
6 U: e( e- J' O! L
UF_MOTION_init_articulation();
) f. ?  n% n/ k- F4 y1 D7 t4 afor(int i=0;i<360;i++){: h+ P( v; U! U' J5 s# ~  z) a
  UF_MOTION_step_articulation(1,&i_ret);( t3 @. D" c: O9 i* i; C$ K
}0 m( ]3 A' J, w) N2 U7 x$ Q" V4 y! ^
UF_MOTION_terminate_articulation();) c( I- b* I& i; [$ \' Z% h2 H
UF_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二次开发专题模块培训报名开始啦

    我知道了