PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了6 c6 |% _! i8 _. u) ?

5 n- v7 R! M6 g: D- o7 B我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。
7 x' P" m/ ^, d7 g. N: y QQ图片20150521182535.png # ^  R) g# J3 [; G
我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。
7 O' o6 R$ r! ~5 m. M1 H) U  p  ~; t9 R. D2 p" l/ d* \
一段ja录制代码:
  ?; f, ]# x4 U4 Z+ j% j+ K( M
; _1 b1 r4 `' R" Q2 c% m4 ]4 G        Motion::MotionSolution *nullMotion_MotionSolution(NULL);9 |. t  R8 G! K* R
        Motion::MotionSolutionBuilder *motionSolutionBuilder1;
6 R% b/ `6 E* V# Q1 _. k+ a6 F3 ]        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);
/ [* X8 t) z  d. s* Q8 L; k0 z$ y% a% V; D- k; `+ ^, K
2 q& F; n% y" {+ \, @1 f; g4 _
        motionSolutionBuilder1->SetTime(10.0);1 h& u/ A- L+ G3 F; @/ k' S
        motionSolutionBuilder1->SetStep(500);' W5 K9 b) Y( t: J( U; r, G& O
        motionSolutionBuilder1->SetName("Solution_1");
) ?- N2 b% ^7 Y        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);9 a! a; i5 J7 X

+ y1 _1 \* Q. }; u( M% z: K* A4 a; c4 g1 |# V
0 v1 L6 Z3 g( N2 z
        Point3d origin1(0.0, 0.0, 0.0);1 v1 f9 |3 K9 ?& b4 J
        Vector3d vector1(0.0, 0.0, -9806.65);2 R" e4 `9 R9 J( e& d, Q
        Direction *direction1;
$ ?4 i/ z: H& e& _0 b; J        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);! q+ z' W9 ]9 S9 J) ~
        motionSolutionBuilder1->SetGravityVector(direction1);
! L' c' {( W' L( ~
' ?3 K/ Y' C! p4 h        NXObject *nXObject1;
) u. _, ], ?9 [1 r( o& s        nXObject1 = motionSolutionBuilder1->Commit();
6 O! n. X# L$ \  l( `, Z; X; e        motionSolutionBuilder1->Destroy();5 T; k/ D. \6 w1 r" G1 t$ I+ N5 r' ]
       
0 k, r3 E; l5 J% l" K# z        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));
8 T( C& n8 E* S  }" b* q6 r' K        motionSolution1->SolveNormalRunSolution();' ~8 h/ W! D" F$ P4 {

! m7 u6 c  C  c' {* y# M9 d2 |. j9 D% }+ Q

) ~8 s9 i1 L1 B$ `) Z& W+ ?/ t就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云...
4 l' k* Y; N: I& N) Q' Q+ d
上海点团信息科技有限公司,承接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函数有一些可以用的代码但我接不上这样子( l# e, a3 l$ \& J$ v

* n+ V0 A3 t" V; |% A- gPartSaveStatus *partSaveStatus1;5 [9 l2 _# o: y( ?
        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);
; Q5 `5 ^+ f, f, ]2 i6 i6 k5 T0 c0 E1 ?  U7 C, ?% B. |  ?) V* n
        delete partSaveStatus1;% R$ k+ P6 Q9 J8 R3 {

% f6 P/ l* M$ z2 m7 J
8 f5 h' W7 K, d) R        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");( X7 q- Y; H8 ?# R( P# h6 o/ f9 D

& }3 J6 E4 C- x) W5 A5 G! f- N; [" L) C5 k3 m( w) ~- @: O

/ ?! j. b  f  d1 t        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);5 a0 t) N; x6 r9 Q
  z# g: |7 G  n: y$ i  M
        theSession->MotionSession()->Environments()->CheckMotorLicense(false);
, T5 q  b9 h  S: s1 R2 ], ]3 B$ h% I6 ?
        theSession->MotionSession()->Environments()->CheckCosimLicense(false);
9 \; x, s- H/ m, ?! l5 x: f/ [# P
( _2 [1 F1 e5 i3 J7 a4 q" J        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);
2 X! I( @9 F: N& T5 a0 v8 w
# k9 \- K8 ^8 C+ W+ L+ K2 S) L# y4 x        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);3 s1 `9 h! {' P' B8 p0 f

# u! f2 I% c2 n4 [5 G
8 X5 ?* D4 A9 R; j$ t) v( K1 z        NXString motionSimName1;
% R. x: K" y  B5 s& K        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");  y, M$ U6 r  b; m

# Z  ~5 B* _7 d        workPart = theSession->arts()->Work();
+ l2 a5 F2 |$ p" D, @0 C        displayPart = theSession->arts()->Display();
) I7 b% I/ a: e$ o' [* o        Motion:hysicsConversionBuilder *physicsConversionBuilder1;
5 T* Y/ S) \! B* g- H; {        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);, ?* i( B, n# J; t3 G" Y. Y6 \

0 j, ~2 c1 F3 t9 G$ E! y. _        physicsConversionBuilder1->Destroy();2 S( I+ r5 |8 q- L
, n" f3 n, L' A  T6 |
        theSession->MotionSession()->InitializeMechanisms();
* ?( |& \" J& V' X7 c1 U
5 M5 V- w0 t/ v        Motion:ink *nullMotion_Link(NULL);
; B+ z' q/ }# q& A) V0 x! K        Motion:inkBuilder *linkBuilder1;
- }. o9 o. J  v1 E, e        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);
. Q% t# u3 @3 J* ]
9 t# i9 P6 w8 L2 W" Z5 i( h        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));6 i" R  a' l9 t% g8 n' K3 I6 G% k

+ s  F" i+ W( ]" D3 e/ {+ {/ }        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");5 O3 v+ q+ y" O2 ~
5 j# @, v! A, X! o& p
        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");/ q' a  \+ L- Y7 O/ v
" }3 e0 d+ |% |; U3 C3 G5 L6 a) D
        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");+ W5 @8 h' V4 J$ n' b
- F8 I3 D& j" x6 c: ^- G! r" m' A
        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");( }; {  k# m. ^! x$ ]% T! ?; c

. F+ ^- z) t" u' V        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");
; e8 A9 |' r: Q
" ]4 o& v0 R3 [* H+ k        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");
: R4 L, N0 n- v2 m- r4 o# ]- A8 U/ ^- z6 u2 h$ E# @' `
        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");  A. N6 J$ o/ C4 {4 ?6 {( y

0 i4 l: O' [  ?. u$ C( `       
: [" F; B4 Y  H: ^8 c( S% X. d
+ r  r; [; v0 `8 o, S- v0 m8 O# e. Y        linkBuilder1->SetName("L001");' Q1 \) k" C. G  E# S3 g. Z
' M2 Y" {4 Z7 b+ k1 e0 v
% x# T0 ~2 f# v. q6 V: T
        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));
& b0 _1 Y5 n4 {7 y3 j        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));
8 W4 g: _6 D2 F. A, _# l0 [        bool added1;
; S7 p, V* J* B" Y  X; N        added1 = linkBuilder1->Geometries()->Add(body1);
# o4 c) I( l: p) F& A# W, s) x
, k4 N4 _0 u3 u% g        Direction *nullDirection(NULL);" H/ x1 S; ?- b; _% k
        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);
0 a0 ?! {6 j6 J3 p, J! S. k
2 }' i+ v1 o+ m0 B" L: F1 m        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);2 |5 A, k) i" Z! a& |, m
! u& @* q: j- `0 y+ D, B: E
        NXObject *linkObject;
' G7 p" U; f: z# c, G) \        linkObject = linkBuilder1->Commit();
% W  k* _6 D% o' q$ m8 [
! C3 Q8 J3 e* b6 W; Y2 f8 n: \( K, g0 n" j/ }. J
        linkBuilder1->Destroy();$ D, F4 B$ X. C5 O7 _& v
5 x( l/ c( `; d7 I: \! w

9 ~$ Y3 J0 u$ z: k2 x) D  b% W) a- i# k7 I
$ `) o) B' Z0 Q! e
        # O9 d9 y* K. u+ \
! e$ u8 h! o! }9 z! n8 _
        Motion::Joint *nullMotion_Joint(NULL);
5 [9 _7 _' C4 ]+ ~        Motion::JointBuilder *jointBuilder1;( Z; `& V* _, _6 ~" V8 k  S) [. X$ Y1 X
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);; n+ x$ ~8 L" C2 Z

* ?- d1 t5 c* B( h; R8 ^. ?+ k+ ]3 O

2 T3 Q* l8 m( ~: p% R% g        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");
- d4 d& D/ E7 @+ S7 s        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");
" ^* D/ F7 U. H        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");2 g. Y2 Q. v! W
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");
! R/ Y; p. ?+ u' Y* w8 G+ b% m( s1 ]        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");
/ r2 w0 k3 A9 X& C        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");
% L& H( s  U; N, I1 _- q" E" q% O+ g& `. _+ l/ N8 f
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
# q/ ]6 y: I5 P+ }! f/ }        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);7 w- N3 o, I; m* `( Z. `- d  v, S0 o' p
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);. A" K4 K2 {7 @
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);7 L; x9 E7 h1 Z0 R/ S- ^
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);0 X- m) w5 ~1 a- d3 }
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);0 R! p* j1 V  Z: v/ ]- u/ T0 n! C/ k+ y
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");
+ m. e  m7 u% E! ]        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
  j( Z/ Z, X# ^2 J: }3 s$ \, t        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");/ E5 D& R! P  b6 @' z' r; C" [
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);/ U( l! d) L! Y  R3 d+ h
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);5 @# B# l$ `% e# Q4 X& L7 ]+ w6 r

6 W0 ~  u6 h! n! h7 s        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));; I' n# A! A% Q1 y4 Z1 U
        jointBuilder1->JointDefine()->SetFirstLink(link1);2 w& K3 I8 j5 U3 W3 l" C
/ ?0 O" x1 [/ Z: ^
$ [* t7 t2 E5 K; i- W0 }0 Z% {1 E
        NXMatrix *nullNXMatrix(NULL);) U) ?3 o& m/ w7 |& `
        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);, `' }0 U! p) G

2 ]; G3 P; d- P1 `3 f        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
) d; d8 G3 j" N4 r; l9 p8 Q        PartLoadStatus *partLoadStatus1;
) \' {" ^5 z; P/ q/ g3 E        partLoadStatus1 = part1->LoadFeatureDataForSelection();8 H4 r: i" ?! ^
/ f! E5 d* d* m! A( F
        delete partLoadStatus1;( u1 H& I7 `: c! R' q
        Scalar *scalar3;, ?6 Q5 |6 M1 ^! t- n- K
        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);
( C, `9 C! e+ C4 S0 p, u( A  s0 O* U% h# i; k: B. ~& I1 F8 g! w
        Scalar *scalar4;: T: ]7 J: v% |6 [0 ^- P" {: _3 s
        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);7 e# y& `( h% F0 U

$ O5 V/ l9 ?& {1 Z# v0 G( |        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));5 F$ {- ^, W+ c- T* |/ [
        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));
1 m! E4 _1 M/ E3 e: W        Point *point3;
3 M  G% J4 e- f( t" @' c        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);
3 u! e% m+ q% Z6 ~' v8 D% w; p; S$ X* O: W% u5 v" V% p2 `
) m5 W7 S# J$ h
        NXObject *nXObject12;8 Y" O5 H! J$ |! U7 s# f' f) A- i
        Xform *xform1;: s8 y% V0 u2 s* J
        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);
* ^- V. c. r5 d. e! Q
5 Y8 B- j- r$ E4 d8 v* |1 J6 `        Point *point4;
9 d& }. B# ]+ X        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);/ w; `' e' `0 [- [; y. d/ ^! _

" a( _4 A3 r6 }2 m( p! N9 Y. R        jointBuilder1->JointDefine()->SetFirstOrigin(point4);
, ^4 E$ x( o0 g
( S& _7 F! A4 H5 {  y! `
+ s7 l. p5 [+ @& k        Point3d origin1(0.0, 0.0, 0.0);
# k. w- \. O1 n5 p5 z- [        Vector3d vector1(0.0, 0.0, 1.0);
% a" v2 a* N1 Q, p1 t6 H        Direction *direction1;1 T! Z0 A: }# M/ Y' J
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);
+ a' j$ v4 a& ^& l: |, z# Y; ^; `6 C; a7 U3 V" J" F3 I$ Q5 {( K' d& g- L
        jointBuilder1->JointDefine()->SetFirstVector(direction1);
6 D2 U1 Q) f& H+ O$ F3 z
$ \% D) b5 B! p0 Y" M        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);" F+ L2 m1 d/ c6 V$ d. S& a1 S

9 Q7 R7 q3 c3 y4 K2 v        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
- R$ u0 `1 S2 m& Q7 m0 f$ ?) b! U
8 |/ ]4 Y$ E& z7 [5 o7 @+ i* a( Z9 D1 G        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");0 Q4 R6 w4 K. j, v" B7 X7 B7 w4 Q

  i5 c5 @. {5 U) y; {, Z$ q5 p( r
0 ]. X  `) y/ c) }: o        NXObject *nXObject3;
$ I$ Y9 J: x! j' H3 @; y6 O& r        nXObject3 = jointBuilder1->Commit();
5 k& C5 ~% M; F
4 C0 v" I1 e7 ]! K: o        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

为什么会有表情 - -!3 [( g/ l+ q9 O1 n; {8 _& _
( e9 i- f; K1 e+ z( N/ Z2 D: ~$ u( p
有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
6 \9 V% [0 h3 k" F2 K3 O/ O$ M
+ U% G9 m8 I$ g* k( T8 ~.....4 M1 L: v: c! d2 W

1 I- i( y+ @* V: f# e/ RUF_MOTION_init_articulation();/ p' N9 s8 ^& ~( K% d8 q
for(int i=0;i<360;i++){% U' t$ b; [9 ]$ x. h& O# p
  UF_MOTION_step_articulation(1,&i_ret);
: q5 S4 x2 A8 W4 C. ^7 Y2 z3 u}" k4 }; d/ W9 p2 d( ~- E1 \) Z
UF_MOTION_terminate_articulation();5 o% H. A1 U% w5 u3 ^
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二次开发专题模块培训报名开始啦

    我知道了