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 3344 2

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

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了
, T0 n! w4 ^9 x
0 C; `( ]9 x& J3 u" d我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。2 k! K; Q# d$ N
QQ图片20150521182535.png 3 ~+ _, o3 N  z" I
我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。5 C2 L4 w. a. [1 u: U( j# _/ d

* t5 L3 z; Q+ W6 z一段ja录制代码:6 |3 B+ f7 ^7 U& u3 b

5 J' F& `5 u/ V) C        Motion::MotionSolution *nullMotion_MotionSolution(NULL);/ M  H/ z% Z3 J5 X5 x
        Motion::MotionSolutionBuilder *motionSolutionBuilder1;
  ]4 J7 Y# n6 p. a6 r6 ?" [/ {        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);: ?1 B" {/ P# S. K2 Z( S
. [. `6 ?6 j, q# Q) E
6 L$ |6 T( T! y* }9 Y0 n% s( M. q% _7 i
        motionSolutionBuilder1->SetTime(10.0);) p( X6 x" b2 w2 W
        motionSolutionBuilder1->SetStep(500);  o' L( V6 b: b( n0 F
        motionSolutionBuilder1->SetName("Solution_1");9 b9 M' D0 x5 ~+ P* O0 R3 U
        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);
9 [% F/ k0 k6 [
$ f2 w! V4 q* M8 J9 i1 E7 O  E3 v' E) u

0 a/ I  O8 u. ~+ |        Point3d origin1(0.0, 0.0, 0.0);# M2 g3 [4 b7 g( S2 b8 h
        Vector3d vector1(0.0, 0.0, -9806.65);( |$ k9 x' K6 m% U# a1 b
        Direction *direction1;$ G1 A2 |. l. g) ~4 J
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);) g9 m& D2 n6 @( v/ \
        motionSolutionBuilder1->SetGravityVector(direction1);) R2 _5 o: d8 L. f% o0 a

8 ~9 P- F( M+ i" H( B& G        NXObject *nXObject1;1 r- I9 R, u; v3 B3 R
        nXObject1 = motionSolutionBuilder1->Commit();/ l, x( H1 P7 t+ A) P
        motionSolutionBuilder1->Destroy();& c' X3 X+ x( M2 B) q
       
; C3 p" p3 t) @8 f) d        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));
# Z, s# m3 G" l# h" }5 q, G        motionSolution1->SolveNormalRunSolution();# O( f$ I& m2 F0 l8 Z1 b2 f

1 w, P: b2 \3 t0 g2 X$ `, c+ P* U- ?  H4 m% H3 Y1 k7 T4 R6 W, w  A

" {) m  I  t7 C) O3 z2 O就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云...
% |. m; y8 M3 l' h
上海点团信息科技有限公司,承接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函数有一些可以用的代码但我接不上这样子
" `- C% ^( m; L3 T. @) U( V$ R4 ]
; w9 U. ]7 i' UPartSaveStatus *partSaveStatus1;
/ d1 @# @$ y1 I# I& s5 p2 l4 j5 c        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);+ G8 f/ e9 ~+ }
; @& f# v' @0 d+ Z
        delete partSaveStatus1;. X; t( r4 I( p9 r
+ k( M1 Z6 \( n# l. b$ h
7 n  T0 h9 [& U
        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");& _# B+ u2 p% c  |- M! z* q
( ?4 I% a" v9 N  j

- @/ |% m5 V+ Q! `3 F, V
* y' G9 s2 g, |; A) R7 l% ~3 f  e        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);  P' P6 `9 _9 y) q; i

1 h- C) f$ a. t        theSession->MotionSession()->Environments()->CheckMotorLicense(false);
+ E) u8 ]$ j9 i0 M" D& X" d; F$ t/ h" K) S; [
        theSession->MotionSession()->Environments()->CheckCosimLicense(false);
6 Z( I1 b3 I+ s7 }4 V8 s% w- ^) \" \2 Q
        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);) l) r* t0 i% Q& ?) }$ P

( c* \6 U' e# H5 |4 w) S        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);, B( c4 A) @% C+ L& }" |* [' }

% v3 m" B& z* r, D6 e7 J/ S! j' K- w  w7 v$ Z' O) T) m
        NXString motionSimName1;
, K4 y3 q  F: o' ]6 F; d        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");, y' v# Q! G; d0 R2 ]" M+ m0 ?
4 T. O4 |0 ?. w* i* y. t* M
        workPart = theSession->arts()->Work();$ U+ _, j, r' u# l2 ?" {) s
        displayPart = theSession->arts()->Display();
" q9 a! |* Y( \. g/ D/ t        Motion:hysicsConversionBuilder *physicsConversionBuilder1;- _4 ]4 J, L$ u: X5 W; G+ X  k  ?
        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);+ q% n" Q- M0 K. f# K, Q& P

2 A. o$ y" r. R2 D) p- r; N        physicsConversionBuilder1->Destroy();
) A* @2 L! M" N" _+ f
9 K' i, I5 S! h; `        theSession->MotionSession()->InitializeMechanisms();
: b/ C' x: A- g6 g( L/ X1 i1 ^  [7 P- y
        Motion:ink *nullMotion_Link(NULL);# D/ Q0 u/ F0 ^) w* b% l) d
        Motion:inkBuilder *linkBuilder1;
  Y+ x. U9 F$ K  J$ _        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);
' M9 `7 L5 O1 j4 T% t0 H
  J# N9 `+ j$ E8 w        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));
& J! y' Y; X7 p7 o: U5 O% J
2 q1 q8 X6 P  ~( x: D& k        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");
+ G- X8 J  [7 @7 S. x& [& J
1 e4 z! c. }" n" ~3 d* j        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");
9 w2 V; A0 i" `& N+ c$ ]1 p( ~' r1 N. I1 {* M
        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");
0 M% I5 n# u: F" _, X0 ]# p& ~, k
" }& ]$ k  Z9 F5 v# S0 B' {7 \& r8 y        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");
8 I; y4 r2 q% s4 i% Z' K* \) E, k
" Q! i  |( [6 H) z/ R6 \        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");% B3 k% T: ?5 I
) H: L- c0 L6 l% M8 X% o* u6 q+ [# K9 x- j
        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");" B5 M9 b1 \/ L, r
( c  f. U9 N% Z6 h9 T& D$ _
        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");
& D. w& {/ r  }( i" G1 a
9 A; S0 U  b5 ~. v* _2 w! c9 g       
% H/ F& j# J. R, n$ D3 P% I7 ]( n
+ b, m+ j( w' t1 D8 l9 c        linkBuilder1->SetName("L001");, F9 Q; q! L, {6 v" W" T, t4 @0 v
/ N3 R$ `/ f8 {- g# {  g
( m3 ^2 m4 S$ ~6 T. V
        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));1 f8 T+ e+ D2 a5 V) j$ L5 R1 Q
        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));0 B. f" o4 k8 ~* V* c  k8 J
        bool added1;9 |; R* O$ s4 R) M
        added1 = linkBuilder1->Geometries()->Add(body1);
! S0 \, M+ R" K  k4 }' e$ E$ T
& _" e6 i2 u, Z  ~        Direction *nullDirection(NULL);) |* a/ n# V$ \/ U5 r
        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);2 [0 R3 r1 s( ?' V+ ?
8 j3 z5 S" H$ j
        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);
6 U) j# i2 [  s$ z6 @: x2 k: C8 j2 j& x2 X/ Z* e3 @& h
        NXObject *linkObject;
+ U3 g; I0 V: q0 ~0 l        linkObject = linkBuilder1->Commit();! K0 ^4 u) g5 c# `% m
% z, v) E8 n. l2 W. w! z

2 e9 g' I' {0 k+ E  j! D9 A        linkBuilder1->Destroy();
9 _; M+ o6 I& r& K1 i9 {4 _; Q: G, g# O3 b" H7 ]

* Q# Y3 z8 |( |& d5 J# f2 @& ^/ _8 M  E# k, s% K% c. U& Z, t
; ^5 g! K7 P8 Y. p# B; t' j: u
       
/ O! i( {( {2 B( ?  I5 b' o1 c( [7 O7 ~5 Q, E& F+ }
        Motion::Joint *nullMotion_Joint(NULL);
5 `  ]. i, l+ `! l2 n9 Z5 t; r& O        Motion::JointBuilder *jointBuilder1;6 \( y: c0 e! n) l
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);
+ w" ^9 }4 l6 B) C
) u. P3 L6 F2 I5 _, L6 L
; I1 I% i& _! |2 X! ]5 b( g) ]% z6 f( L! ?2 n
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");
# {7 G; ^8 g4 N3 f7 l+ V6 C        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");8 y8 B5 _; M0 W5 A2 u! @1 `: O+ c
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");: t( {3 A7 G8 H7 l! {
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");5 R3 }$ E) X! j6 G
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");
. m% c: n9 l- G( r7 e9 [! e        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");/ J0 a% b- ?1 g3 L7 {3 |8 ]

8 R) ^; f5 Q' k8 S5 z0 s( f( S' Z  B. x        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
1 ?; H+ k& X* D0 i2 g' v! l        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);
9 d0 h/ B5 H: t0 x- o3 q- q9 \        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);
2 k% c7 s+ h; k        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);
$ s: l8 B  f3 {! x$ b+ N        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
# W6 O+ Y7 h* T0 y        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
5 ]; u4 C; n8 o2 L9 e# t        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");
, J" r3 F. ~, U. p. m9 I; q; b        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);, S: }7 w' o+ ~
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");
# f* c: V  [8 _7 h( S  P! q        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);6 w/ G" @# m- ?6 [& C
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
( l% J: l) p* E8 e  X  q. Y' ^1 Y. H7 w3 h" a2 n% n( X
        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));' S; [+ ^# R- r  M: r5 a" v9 y
        jointBuilder1->JointDefine()->SetFirstLink(link1);0 y( C. b: i7 i6 O) c, l
, g- \; V2 N+ }5 l

0 j% Z/ Z1 p7 a; q& p7 w        NXMatrix *nullNXMatrix(NULL);
6 m% j, U' Q6 ~        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);
0 c6 k" D: ~* B- p- s# ]4 d$ D0 |/ ~' K& D; Z6 Q
        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
# Q, ^/ `' Z, N! }1 U        PartLoadStatus *partLoadStatus1;
$ f7 ?; v: G! r: F        partLoadStatus1 = part1->LoadFeatureDataForSelection();' ^: F5 F9 E* b- v; d+ M3 u

, `1 u) S, p, B8 [7 m* D6 C4 ]! e        delete partLoadStatus1;
  C0 z/ J$ H7 t2 E$ l2 j        Scalar *scalar3;6 \0 l: k) e8 q4 Y2 x& Y& d
        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);9 d, `! M* y2 z- X, P( d
4 s  a2 p% n4 Y0 G! i' o
        Scalar *scalar4;
! o& |/ ]! r' l1 V! Y) Q        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);0 v1 j  E! p- {4 m- H& k
, b: Q% N( |1 u( e3 `1 b
        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));
+ z+ p: K: K1 {3 a) Y& [/ v- d' I        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));8 E# z; S- Q$ Y6 h4 ]" f( N
        Point *point3;/ o7 b: c: I3 m- \. v& b4 B/ [
        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);
/ _: {3 M# i' O
6 W) Y  i% M0 k
% A" s1 R2 Z5 w2 N; R# L        NXObject *nXObject12;
; G5 f) a7 ?2 Q        Xform *xform1;
8 P* Y; Y2 {' i! W        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);. f5 h9 C+ ]& n5 x! X

9 B, E. _- U  d. Z% L7 O- n7 z        Point *point4;7 B  `3 B+ t# w) B
        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);
6 Q5 D1 g/ a7 A# I0 M! Y" G
( }- z7 o; |7 z        jointBuilder1->JointDefine()->SetFirstOrigin(point4);" w: D/ ?' n/ n9 s

( `1 K. [& k  n" D0 F/ H* d+ p7 `8 }, Q
        Point3d origin1(0.0, 0.0, 0.0);  L& [8 f+ k. w( X# |9 p4 O
        Vector3d vector1(0.0, 0.0, 1.0);
) y4 N0 W- `4 z7 ?        Direction *direction1;
' d' _: @- S; @/ l7 G        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);) Q" _. w& u8 V. y/ V
  f6 P# G! ?# d0 u* d
        jointBuilder1->JointDefine()->SetFirstVector(direction1);
2 _! J/ |3 ^- b" B( ?9 {; ]1 ^, n5 h9 i) f: I% ^
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);
% G, g5 |7 m5 T: d" @- X7 T9 z1 a9 d' p4 E9 g* f. C( Y9 R4 d* T
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);  |* B) P3 ]- o2 ?
7 K. w, ^1 V# ^9 J) J3 g
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");1 N5 i  a$ Z6 ^0 w

/ R5 V1 _. _# \% W$ h7 k' }
0 }& j% p5 }# @2 \0 c4 f& G        NXObject *nXObject3;
& |9 k0 @& v. L. j0 [; Z3 Q        nXObject3 = jointBuilder1->Commit();: E. D) F$ Y/ O( ~* ]' a. W! a

. U. `5 ]% X9 x; _        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

为什么会有表情 - -!
+ _, v: J4 X" k- W4 H) a4 L, W1 K( t$ q7 O* R2 {
有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
3 |* W9 V: f$ L, Y) f( \+ u' P  C
& `) b/ t: ~. C+ C. O) }: O/ m.....
4 J0 f% I8 Z6 l1 _0 r$ N9 c/ w- ?, o8 i/ P! V
UF_MOTION_init_articulation();  C4 J8 \5 X  E# k* V! ^
for(int i=0;i<360;i++){
! Y- ]. Z) q1 R& |6 _  UF_MOTION_step_articulation(1,&i_ret);
' Z; f6 _2 a) q! s" I}  f6 H, C6 h; k* W4 ~8 h
UF_MOTION_terminate_articulation();$ |: r+ S7 `% @3 |1 o( X
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二次开发专题模块培训报名开始啦

    我知道了