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

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

[复制链接]

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

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

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了
5 Q) e  b) @/ G% v% F% W+ V
! c  Z) }7 X& V$ R我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。8 s8 Y- f6 I! Y+ N, O
QQ图片20150521182535.png & A% t* j7 R9 j! Q, a
我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。
9 q" D7 P& J* W  y) l
/ e# _* q/ G6 V! W一段ja录制代码:# K  T- _( a! ^2 u" u

. Q- L! O" z8 b: |2 s        Motion::MotionSolution *nullMotion_MotionSolution(NULL);
8 X8 u& H1 c# }1 Z8 q        Motion::MotionSolutionBuilder *motionSolutionBuilder1;- H0 ?0 D* c1 t+ G/ w' H5 g
        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);
' j. R1 b/ v9 q; s$ N' h
+ u* V  B8 e) I8 Z3 y8 u
: z8 n/ ~8 |: E& a2 o: o        motionSolutionBuilder1->SetTime(10.0);$ _+ q, U6 N) r
        motionSolutionBuilder1->SetStep(500);
1 F* v. `1 _2 W/ G8 E( ]8 M        motionSolutionBuilder1->SetName("Solution_1");
+ z2 h! C3 z* l1 X& }3 ^        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);( d1 r' e- R% W3 e
" `% _* ?9 n* X+ i9 Z& N

/ i* R' ?% q; o6 p. d" X
* r8 c% F0 ?3 y* k4 B. O: k) g        Point3d origin1(0.0, 0.0, 0.0);& R$ |5 O1 G4 A3 s5 {* [
        Vector3d vector1(0.0, 0.0, -9806.65);
) @2 O7 @8 `1 r" u( E' T3 g        Direction *direction1;
! }" V& E$ C+ v# n& a  i2 e        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);2 A" S) d6 D  Z# |
        motionSolutionBuilder1->SetGravityVector(direction1);3 ]3 Y- N4 \4 K+ W
/ C8 R5 X+ I) Q  M; ^) @. y
        NXObject *nXObject1;
" w& d! V; x8 _        nXObject1 = motionSolutionBuilder1->Commit();- T) q$ a! }( x3 j& S
        motionSolutionBuilder1->Destroy();
8 J# s. ]" c. {       
& J: @9 Q0 O& n' ^8 Z. t        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));, X0 n: y5 B) G6 R
        motionSolution1->SolveNormalRunSolution();
: ~) k/ N' H, L% X3 I2 h& ?
+ t! S) q) a- C1 |+ l, H' }2 V, \
! ^& k4 P+ k% K6 \/ K
就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云.../ D9 |* k/ t7 f- r0 ]* G0 X
上海点团信息科技有限公司,承接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函数有一些可以用的代码但我接不上这样子/ G+ p* L6 r- P! L4 H
/ A7 N) B) i. |2 B# {
PartSaveStatus *partSaveStatus1;4 q8 g- j& E% p  d, J
        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);1 s- F5 ^5 r, ]( x4 z$ ]6 s1 m9 `
& s* h  h' s: M
        delete partSaveStatus1;
7 @* K. X4 O$ I6 M( ]
) ?6 s5 H% Z2 @
( S( O  a+ R+ a- G0 V        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");% I. H  W" L- R! t
' L9 v! r; v" [3 @

0 H3 j. ]& q+ |* {, D
) l' D9 l& k! ~: {* Z1 D        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);
/ H2 f  W& }: B" n4 x! \
9 R3 a9 I0 u5 j7 l+ g0 f        theSession->MotionSession()->Environments()->CheckMotorLicense(false);1 ?0 J5 f/ ?  p, ~& ^
1 ?  M! i  K  q" @% H$ F. \
        theSession->MotionSession()->Environments()->CheckCosimLicense(false);
# r! f. P% l8 L, V& F) |' U- s  e
        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);
# E2 F* w7 }$ x8 L" }& B
: n. Y+ ]/ U( N7 W& u: z9 G& s  K        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);
" j5 U! K% r6 d* c6 B- N$ A: ]& Q. J
3 M! @, z9 p) K7 y( h, d; ^; X! F2 t# n2 s3 m- T5 b: h8 l
        NXString motionSimName1;% s- N6 w  V3 o3 |  z$ [2 M6 k
        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");
- N3 w6 G8 }7 m  Y: T2 \7 o7 B! y) H( I; q  O: _8 l: c
        workPart = theSession->arts()->Work();9 y& e7 z/ H, Y. t1 F/ e' q7 h
        displayPart = theSession->arts()->Display();
9 P: `+ P- `0 H: i6 V/ X% S        Motion:hysicsConversionBuilder *physicsConversionBuilder1;
4 N% m# T9 @1 [" E/ Q        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);% b) m; h3 ]7 B9 J: f

# z/ K/ j& |7 m6 Q        physicsConversionBuilder1->Destroy();, Z  K& I8 ^5 T; O  q% f

5 q- v5 Q' q# B& d- Q1 Y3 z        theSession->MotionSession()->InitializeMechanisms();
* B2 L: ]/ ]* ~( U9 Y3 u$ J, x! z, j$ f  W( M0 u
        Motion:ink *nullMotion_Link(NULL);
4 l) k, X7 V% K        Motion:inkBuilder *linkBuilder1;
4 t0 L) M9 _7 h& j        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);
9 F6 V0 P" }+ q3 H# V6 \% m& U+ ~+ u
        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));7 j5 |6 x  M- {! ]! F
, P* V9 \4 }  t' R2 A, T
        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");; u- o* L) e# Q7 K6 {

& W7 r  n) ~2 T6 X' k        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");1 Z' {" _$ d2 e2 _
* x" y  q' k& x% D8 Q
        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");
# t$ F8 t$ B5 T) T. F' v  H/ l+ B( L6 g, C; n2 n8 `
        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");
+ _9 u1 f$ I, @8 X* ^& g, r. H; u+ [* v4 f7 I; e$ S( Y5 t5 T" C( e
        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");$ w0 _- [7 [  c7 _0 A( g" b
' x2 @1 O! C% l% S' ?$ y$ M
        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");
% X) Z" |: ?6 I- @" o$ B% G0 W- B5 ~" n
        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");
' X% v9 B7 x' b, ?* o
- O5 F# ]) M: q8 E       
3 Z- ]; N8 j  q( C, X9 [+ {
2 Z) f4 e$ ~: g, }        linkBuilder1->SetName("L001");
$ ^, [  c+ i! @% q% i# c% Y. f# p' k7 ?$ Q  O8 A
# C' K  }( P4 }7 \  F- t6 j
        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));
5 S0 @/ j5 J9 x        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));8 s- |6 j6 z. u4 @# `
        bool added1;  i) T4 |* L4 }) B- V# g0 s
        added1 = linkBuilder1->Geometries()->Add(body1);+ l' w) U7 X6 x, S# G1 t

( C; F6 t$ L3 Q9 k- \( X        Direction *nullDirection(NULL);  z% W6 b3 ]' ~9 x5 d
        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);
4 ?6 U; x: M4 s) G+ o- ?; g0 V" S. A7 p4 S, K
        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);, J4 P4 v$ l2 ~. p$ s4 ?, b+ R
- l7 v$ P1 W2 b& Y9 Q& ~0 `
        NXObject *linkObject;2 g; z' `5 T* ?, D. f8 U& W
        linkObject = linkBuilder1->Commit();
) f  I0 k( n6 s1 D
  G2 m- M7 G$ ]1 K
# a! S) Q( @" h        linkBuilder1->Destroy();
0 }, w  k. m- A7 {' [. r; ]- p: N# [) g& p2 @1 x$ k

  [5 B( F( V) n0 d7 z0 F; D* U/ i& N! H
- d! V: W, N( y+ y" f4 v) ^0 X
        ; h/ ]6 g) u" [$ Q* m) ]
& K$ W; }" ]; W+ f2 k
        Motion::Joint *nullMotion_Joint(NULL);! H/ |% z2 n7 V; n
        Motion::JointBuilder *jointBuilder1;7 U# _/ v! R* W8 d
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);$ v8 t7 c8 K1 ^) Q3 z
' X" i. A6 s: ]2 a

( b$ N- a: j3 D# E
' J  I1 E1 k$ Y/ A8 z        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");( n1 N" u& o; Z% a. o3 n
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");
' ?& m, x$ \6 C4 w8 G        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");
3 y9 r* o! k+ k4 J9 [        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");$ x5 g% C- J/ E! h7 _; l3 ]( Y
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");
. t) l9 m5 q  v3 Q% z# A9 Y0 ]( T        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");0 _$ [: Q* A- @( A! R5 D! r5 Q7 m5 |
: k) _! Q2 T) z7 c; ?
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
8 Q! Z5 e; D! F7 W        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
( D" E# q* U& r4 `        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);- a. U' k5 H. y
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);$ A9 Z. C" n' A
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
( c8 P7 a# \/ g- _$ E        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
6 J$ a0 E. @# r; B; O        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");5 \6 c! G) H; R+ G7 X, K, d: @
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);; C' A" \# g% n$ K- w+ p
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");9 ^: Z) U0 O% X
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);  c+ ~, r1 n2 |9 p) k
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);' I% y1 x/ _4 h9 E# w
% j' ?) b* P8 M! z0 I6 P
        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));0 s" m7 b+ R" P8 i
        jointBuilder1->JointDefine()->SetFirstLink(link1);0 o$ w8 w/ V) Y* |4 K& n4 H/ V

" A" s- y! C# D* u6 u
0 ]: S$ ^4 f5 U# R2 @        NXMatrix *nullNXMatrix(NULL);+ \$ `0 l' X3 ~6 s1 c( d
        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);
+ s7 l* }$ b. c! V9 M* S+ O
8 r& O( m3 a: a  @0 h2 M        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
0 k! E1 x7 a' e- R        PartLoadStatus *partLoadStatus1;
2 z4 n9 C" ~9 D, U        partLoadStatus1 = part1->LoadFeatureDataForSelection();  L$ n2 u+ T4 Y. |' W

$ w/ e9 }$ e4 W$ [0 c+ S. T, v, N: ?        delete partLoadStatus1;, L0 h; n/ s( t( P8 Y4 S. j& C' \
        Scalar *scalar3;
# ]9 A% H  C' C1 @5 b% L9 [% N' l        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);
2 L2 E5 l( R4 M7 z3 K
* O( \! x7 G/ w8 d! c        Scalar *scalar4;0 k0 h: c6 K- v) |5 [& ^
        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);  h' u+ g( Y8 {* D2 X8 N' r

/ S0 m. \* ?! J9 S6 y        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));
5 H& U# d0 m7 @, ]  _0 P! o        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));
8 W. }6 x5 H0 D$ y* G        Point *point3;
: o. P5 v, D5 N( a6 f. N! m0 p        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);
! B( A0 [' Y( F/ t% p' g, W1 `
& F3 Z3 V( T( j  O  v  ]3 y0 V$ r1 b: _" w
        NXObject *nXObject12;
' Z' O( H3 B" D  O+ H7 g( x        Xform *xform1;& @/ a3 H4 m: {
        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);9 x7 `- @4 H1 r! G0 c
. c7 F* W: W+ G. m9 \. I
        Point *point4;
# r% E  X2 C/ M0 ^        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);
9 X5 B/ A; ]" t- O
) G- b, D8 o) A" d' |- L% {        jointBuilder1->JointDefine()->SetFirstOrigin(point4);
; x, E8 @. [% ^, R9 s* ]# F9 e, ~" T6 G- Y: z) C

! W( w0 Y$ W+ \6 x8 {        Point3d origin1(0.0, 0.0, 0.0);
  P& x- E6 X  _6 }0 G! ?        Vector3d vector1(0.0, 0.0, 1.0);
; D  D  l) e' y% p2 v1 j  s- n        Direction *direction1;" |* q1 g0 |  g
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);# x3 X" b' |5 f" E4 O  G

) o4 o, Z2 s# A6 R- X, M        jointBuilder1->JointDefine()->SetFirstVector(direction1);
, c! C9 K* A: N, V
; `' h6 [, N+ D! W+ _0 ]) ]5 L* e        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);/ ?3 _4 A2 g. L8 I/ m! q+ a
+ ^; v7 Y: l) ~" Q5 Q. |4 D! n# A5 F
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);: X1 e1 F, [, R( l( b% U5 w9 \1 L( c

2 q8 Y  G+ |* N+ X6 `        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");( q3 e; L  o3 g' l/ i' W+ d. f' @

8 I, x1 J1 \1 H1 d
" M! e8 t# G3 d+ P6 K        NXObject *nXObject3;+ E* W' P6 ^' K! C4 d1 X
        nXObject3 = jointBuilder1->Commit();( o& g  ~3 }( E% ~0 e* H. A* I, I
% E" a, {" p. s( D3 y
        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 L7 W; s2 J3 x- V7 n

5 ^7 M4 U  k2 ]0 z" a  a, ^有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
) f4 r1 l9 K0 o+ a* V  `" D# `$ O9 l. t- u* Y
.....
* n! ?! }0 A( U( W" }
1 r% T. z- H1 o; ]- VUF_MOTION_init_articulation();
* w8 ?. t8 m" j( O+ R1 E, ofor(int i=0;i<360;i++){
# h, \+ L" l. Q# {! M& e. |# d  UF_MOTION_step_articulation(1,&i_ret);
) n6 y3 ?0 {; W  R" _8 Y6 f}
7 d% j6 }* y$ G7 o7 s5 {" z) mUF_MOTION_terminate_articulation();' b/ W9 g; r2 }
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二次开发专题模块培训报名开始啦

    我知道了