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

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

liuyang77177 楼主

2015-5-21 18:40:22

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

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

x
大神们好 - - 我又来问问题了% R4 n# |! q7 U! z) k
& W- ~* m  Z. ]& O; N# C! ^+ x
我已经把程序的基本架构代码弄好了,扫掠问题已经解决了,现在我们这项目走到了最后一步,不过似乎做不下去了。
" Q9 j9 u3 D; U1 R5 a0 a2 s2 e QQ图片20150521182535.png # s' }4 B1 D7 R! @1 x: o; J
我要做一个运动仿真带干涉分析,但是NXopen++不给提供运动按钮的ja录制,我似乎也找不到如何可以通过语句使得运动自动进行,求助各位大神了,是否可以通过某语句使得动画开始或者做一个步进动画,还是我应当如何把我的open++里面的语句转到ufun语句的架构下来做动画,谢谢老师们的解答。
( a/ `9 x; e, n( k: `
. g% Y, d9 z2 n一段ja录制代码:
8 c7 h, V% `6 c$ N* S# d, P
/ g: \7 ^4 t5 l4 m- ~& ^        Motion::MotionSolution *nullMotion_MotionSolution(NULL);, D5 V$ \0 V, g  H2 g4 k
        Motion::MotionSolutionBuilder *motionSolutionBuilder1;7 Z$ M5 ~% l% ]6 b. v' D
        motionSolutionBuilder1 = workPart->MotionManager()->MotionSolutions()->CreateSolutionBuilder(nullMotion_MotionSolution);% W2 w# u: a* K; w
& I; e: S# j' C# Q) o( ^

" D$ O7 h. M- ]3 H4 }        motionSolutionBuilder1->SetTime(10.0);
1 ]3 j; G# |# W1 X. v1 f" U        motionSolutionBuilder1->SetStep(500);" a6 j% d+ D5 g: z/ n! D/ |
        motionSolutionBuilder1->SetName("Solution_1");
# h6 o" a+ A, n2 S& V& a' o+ d        motionSolutionBuilder1->RecurdynSolverProperty()->SetStaticIntegratorType(Motion::RecurdynSolverProperty::StaticIntegratorTypesRobustNewtonRapson);( ?1 n/ o+ }- ~6 [$ Q! f

( `8 Q. o/ c- j$ _1 k* r; B! ~4 R5 b
. I0 {; J+ t2 o! g8 _4 p; f" ]3 Q1 E
        Point3d origin1(0.0, 0.0, 0.0);3 m: ?" M2 m7 R4 s% [
        Vector3d vector1(0.0, 0.0, -9806.65);
, M+ L; ^: a' X1 Z1 _* z9 a        Direction *direction1;  X# Y5 @0 ?1 z
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);
5 N& O! t+ N8 m& F        motionSolutionBuilder1->SetGravityVector(direction1);0 |1 F$ |. M: k, s7 l+ d

7 F. l' x' Z  ]2 k2 A6 }        NXObject *nXObject1;, t* H$ l' X/ V. k% H/ S, E5 h
        nXObject1 = motionSolutionBuilder1->Commit();
6 A/ t2 R) _$ b/ A) Y% i2 ]+ I: \        motionSolutionBuilder1->Destroy();
  o! v. D/ M5 i       
+ B# F. c7 O9 y# F; Q4 l        Motion::MotionSolution *motionSolution1(dynamic_cast<Motion::MotionSolution *>(nXObject1));
% ?5 }6 {+ b" l4 S% X5 w/ m0 H        motionSolution1->SolveNormalRunSolution();  Y* t, P. {: x" M  v0 F

! u% T* o6 Y' v/ W4 O& \* v3 B+ K" Q* ]$ j4 n1 b/ X2 ?4 Z

. A& ^8 A9 Y+ n# w6 \! q7 F7 }6 l( ?3 [就是我想通过我建立的这个motionsolution (在nx程序里是result) 通过语句命令开始动,然后动画结束之后删掉部件云云...
% l: Q+ f+ H; j8 c" {- g
上海点团信息科技有限公司,承接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# }0 _; r1 {# E. F
# O" h( B; {# r$ U  K6 E, K+ SPartSaveStatus *partSaveStatus1;% s4 a( }7 ?9 F# l7 m/ s5 \/ ]
        partSaveStatus1 = workPart->Save(BasePart::SaveComponentsTrue, BasePart::CloseAfterSaveFalse);
! {* y/ B. l5 G4 r- @3 f2 M
0 ?4 \; V/ H' p/ W5 |8 F        delete partSaveStatus1;
1 V8 F0 C2 M' X0 m1 {) _" z- f
6 w0 w( _% T- N$ P* T* L9 A0 [
+ Z% `% e+ v9 ~- P0 ^5 }        theSession->DataManager()->LoadFile("G:\\UG\\UGII\\motion_try\\motion_try.afu");+ |& S3 e$ p6 q- P( G
( V2 D4 ]* F# U3 n' T" v

# v' ^# B$ w! ^! E: _% e
* s( @! g) m6 Z3 C' g        theSession->MotionSession()->Environments()->SetAnalysisType(Motion::MotionEnvironment::AnalysisDynamics);
; U- r5 r6 u2 ^. @
# j7 c! C; \4 J# E! B        theSession->MotionSession()->Environments()->CheckMotorLicense(false);( x+ h6 F1 v& V

$ C6 v0 [3 G  k/ r) F' D" t) T8 \+ f        theSession->MotionSession()->Environments()->CheckCosimLicense(false);
4 |5 j' _! W7 J- q2 z/ l2 H7 l; N& z- \' G$ @
        theSession->MotionSession()->Environments()->CheckFlexbodyLicense(false);
! a) T7 D6 [! v5 ~% I% }% S2 J. P# V$ C6 t- X2 L
        theSession->MotionSession()->Environments()->SetComponentBasedMechanism(false);
1 B; ~9 X. e6 T% b& w, b& \! [% a' p; S) [0 j8 d

% y, A- g8 m+ B+ J, L- p        NXString motionSimName1;
. f0 k6 u" t$ C0 D8 N        motionSimName1 = theSession->MotionSession()->CreateNamingSimulation(workPart, "motion_1");' n" J$ q8 @) Z( |6 K- A: ^
2 ^3 N7 a: _3 w& N/ i( A$ Y, ]
        workPart = theSession->arts()->Work();
2 t+ I9 k% U4 L$ h) k3 }        displayPart = theSession->arts()->Display();, p' p0 x; q& K( `
        Motion:hysicsConversionBuilder *physicsConversionBuilder1;# ~- ?* P4 `: k
        physicsConversionBuilder1 = theSession->MotionSession()->CreatePhysicsConversionBuilder(workPart);3 Z+ ^! I& o. I8 x2 k- ^4 X  `

3 @1 T7 L& v4 o. g        physicsConversionBuilder1->Destroy();7 d3 `0 m: d" c- Q- ?

# z" S  I/ W% a' s* v* i$ ]        theSession->MotionSession()->InitializeMechanisms();" ?* G/ P0 g4 D! ^
3 D0 k# c6 g. f: L: j5 k
        Motion:ink *nullMotion_Link(NULL);% L$ ~& W7 Y) r4 b% |2 |
        Motion:inkBuilder *linkBuilder1;
/ R) A0 p$ V* V0 j        linkBuilder1 = workPart->MotionManager()->Links()->CreateLinkBuilder(nullMotion_Link);( C' I" n+ A' K6 H. ~/ t
5 N8 z( G5 C2 W: u" U7 a8 k- I& u
        Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));2 F% O1 ]7 }' F: i& A$ T
6 a* i1 [3 u1 J, s: o8 {& q  @& J
        linkBuilder1->MassProperty()->MassExpression()->SetRightHandSide("0");
3 |2 O% \3 U  B7 B  @" @- F6 u7 g, p: Z5 `. l. J
        linkBuilder1->MassProperty()->IxxExpression()->SetRightHandSide("0");5 ~' q2 U( E+ E* w' l& n" r# I

: P& P% ?8 \4 J; p        linkBuilder1->MassProperty()->IyyExpression()->SetRightHandSide("0");
, T+ T4 k; U/ O$ M: _" A8 _$ [/ J0 |" G; |$ W- u) f: l
        linkBuilder1->MassProperty()->IzzExpression()->SetRightHandSide("0");1 R9 z6 j4 {' I" E

& h( |5 M3 w; Y/ z        linkBuilder1->MassProperty()->IxyExpression()->SetRightHandSide("0");
+ N2 d+ }7 l0 l* t' h. ~' |& O( M% P+ Q7 R1 L$ a$ I$ H
        linkBuilder1->MassProperty()->IxzExpression()->SetRightHandSide("0");
( T, c9 r/ o# S* z7 ^4 X6 U0 \
6 b7 H  e/ p# ]' f0 H6 [; g6 B        linkBuilder1->MassProperty()->IyzExpression()->SetRightHandSide("0");# o% s0 a  N+ |( T

# v: f( s9 |6 X       
6 W; ~8 Q" R8 c! {
: s. M4 R6 o( u4 k: z3 x4 D8 [        linkBuilder1->SetName("L001");' Y. E# H) I0 i
* y% X& j6 {7 ~4 |/ i; k
' K. E4 X% |( j
        Assemblies::Component *component1(dynamic_cast<Assemblies::Component *>(workPart->ComponentAssembly()->RootComponent()->FindObject("COMPONENT motion_try 1")));0 A/ {$ t9 R6 Z0 [
        Body *body1(dynamic_cast<Body *>(component1->FindObject("ROTO#.Bodies|"+obname)));
+ e. q* }7 ~& Z9 c        bool added1;8 G6 k1 \6 g- {* d: K1 T
        added1 = linkBuilder1->Geometries()->Add(body1);+ n0 m' i3 F, K: J. z6 G
$ n2 `$ |" N( G4 ?+ I4 s# f( L( n
        Direction *nullDirection(NULL);
- E2 U/ e' p1 s        linkBuilder1->InitialVelocity()->SetTranslateVector(nullDirection);' W! S8 Q- f1 H2 y
3 m, U# D; u% b. {+ K! E* L
        linkBuilder1->InitialVelocity()->SetRotateVector(nullDirection);
% c# i3 y0 K6 s$ v0 [9 i0 D+ _7 g9 m! [- Q& P
        NXObject *linkObject;, o+ k- s, L, j' t
        linkObject = linkBuilder1->Commit();4 N) u! u$ N6 Y! i9 p, Q# l
% K2 q2 f$ ?& S* o8 [9 k

2 T! s, R7 n0 i$ J        linkBuilder1->Destroy();
7 u! z( h2 G7 [5 x! O+ @7 X$ `& x8 U/ d! h9 v

6 `  W4 @, r% t; ~7 x3 Q+ H4 u, |" b

6 N3 G( ~/ ?- K! C3 p; c8 ?. s, B       
. ~  M$ E% Q  f" w
; P, Y1 |! ?+ U1 R        Motion::Joint *nullMotion_Joint(NULL);
3 s1 ^' W" B6 c' m0 E) _        Motion::JointBuilder *jointBuilder1;/ G8 g3 v9 u; ]- j6 T% u2 X4 F
        jointBuilder1 = workPart->MotionManager()->Joints()->CreateJointBuilder(nullMotion_Joint);
8 u$ G' e; g+ ]9 i5 L/ ?3 n8 s' Z, i; Z$ M- s( J# a
4 v  t* q+ C/ O2 w# C0 G

+ ^1 I: g7 ^. n$ d        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->DisplacementExpression()->SetRightHandSide("0");# _  ~0 p# [' N$ C! I
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");
+ Y% f+ O: \% P& @# [        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->AccelerationExpression()->SetRightHandSide("0");
% s7 X4 n8 f4 R3 W0 B9 v        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->DisplacementExpression()->SetRightHandSide("0");8 z# e) \7 q4 \+ a0 }3 e
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("20");
4 `; b5 ]' I$ k) c. G  J9 K        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->AccelerationExpression()->SetRightHandSide("0");
9 ~0 ^4 q, y, ]5 {& M7 c$ b) p$ ]$ K- j+ R" G
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);5 k( r) l+ U1 U8 r& b0 x; J
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);/ R# q. n7 n3 U% t- C4 h8 j/ m
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);4 q5 P5 F# N# ]' m
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);; f+ j, W7 C/ i) g
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);/ C( P  o0 a9 S. g- p
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);' I$ ~0 j+ A5 w0 H$ [
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("0");+ h( S8 K+ i' M8 b
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);  Q3 ~& j! Z* x2 s# L! P7 r
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->VelocityExpression()->SetRightHandSide("0");0 k0 j. |0 d' b( D& k/ U
        jointBuilder1->JointMultiDrivers()->MotionTranslationZ()->SetFunction(nullNXObject);4 E" Y3 T( D' i- m( c+ b( a. b% v
        jointBuilder1->JointMultiDrivers()->MotionPointOnCurve()->SetFunction(nullNXObject);
! m4 U% e$ T; I- H
. t5 f9 {( F  c6 P. e9 P9 S        Motion:ink *link1(dynamic_cast<Motion:ink *>(workPart->MotionManager()->Links()->FindObject("L001")));
4 Y9 d0 w3 R$ h: G- N: N        jointBuilder1->JointDefine()->SetFirstLink(link1);
4 q* E" s3 o1 [* B0 c6 ^; Q8 c5 u5 I
$ Y" d3 C5 W% t
        NXMatrix *nullNXMatrix(NULL);
: q! b) C+ O" ^! S1 U& h        jointBuilder1->JointDefine()->SetSecondMatrix(nullNXMatrix);) X' c4 X  R" j7 ]0 r2 e. J
- A3 w+ R$ {' p: d
        Part *part1(dynamic_cast<art *>(theSession->arts()->FindObject("motion_try")));
: T, L7 B( |9 J" H: I        PartLoadStatus *partLoadStatus1;1 O1 @- ?5 b' ?# R8 P0 G
        partLoadStatus1 = part1->LoadFeatureDataForSelection();5 M5 F' O* G' v  v  Y( v
4 ]; X& N5 n0 @: V5 B6 {0 W
        delete partLoadStatus1;3 h: G0 B, @( v  A+ @
        Scalar *scalar3;+ g) N  a# ?& M2 k
        scalar3 = workPart->Scalars()->CreateScalar(0.46951534452273, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);
& q" V: F2 D" h- I& X0 J/ l1 R( R" u& y1 v* H
        Scalar *scalar4;* c7 G3 N' L7 {. T" v6 \. Z
        scalar4 = workPart->Scalars()->CreateScalar(0.440129914258558, Scalar:imensionalityTypeNone, SmartObject::UpdateOptionAfterModeling);
" y( V. L7 ^0 l9 E1 |: P: R/ \3 N. B  [2 y, V) ]0 X1 j, J
        Features::SweepAlongGuide *sweepAlongGuide1(dynamic_cast<Features::SweepAlongGuide *>(part1->Features()->FindObject("SWEEP(7)")));
9 R, A- u7 W5 @' y3 p$ ]; E        Face *face3(dynamic_cast<Face *>(sweepAlongGuide1->FindObject("FACE 10000000 {(-0,0,0) SWEEP(7)}")));
, O( d2 U6 s$ Z! Y        Point *point3;
( Y$ f, `  k  z2 _        point3 = workPart->oints()->CreatePoint(face3, scalar3, scalar4, SmartObject::UpdateOptionAfterModeling);( n* @& \  S: N3 a4 P/ a" m3 J

1 f2 n' j4 \) A* K# r$ X7 {6 Z7 c) v* z$ D3 g$ T
        NXObject *nXObject12;5 {/ U$ x( @3 g4 v6 p
        Xform *xform1;6 t' M& c# `8 U) b1 Y- J9 W; l, [8 Z$ I
        xform1 = workPart->Xforms()->CreateExtractXform(face3, SmartObject::UpdateOptionAfterModeling, false, &nXObject12);6 C9 I" v7 X0 b% o

, O% H" u7 f! U0 ~( l        Point *point4;1 r5 E7 O8 \6 r2 R3 I
        point4 = workPart->oints()->CreatePoint(point3, xform1, SmartObject::UpdateOptionAfterModeling);
3 v/ u' @" q. Z/ P: O# j9 V# V4 g; K  A* \
        jointBuilder1->JointDefine()->SetFirstOrigin(point4);: ~$ c, a# J* Q% ~% t
* D" r* v* J& j5 q2 [5 G' g

( u) Q3 m8 U, @( O9 @4 I        Point3d origin1(0.0, 0.0, 0.0);% E2 C# m7 a2 N7 P# z, e
        Vector3d vector1(0.0, 0.0, 1.0);
4 k/ \7 ~) y/ H6 X        Direction *direction1;1 h$ K+ J; T6 O( ]; e0 c
        direction1 = workPart->Directions()->CreateDirection(origin1, vector1, SmartObject::UpdateOptionAfterModeling);$ f5 n3 Q1 W! h. }
; c- F1 _- e; V& J6 v4 a
        jointBuilder1->JointDefine()->SetFirstVector(direction1);
; f5 P) }, v' W: K6 _  f! A2 X! M5 N9 Y3 S# n& t
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetTypeOption(Motion:riverOperation::TypeConstant);
/ Z: i' n7 x6 M8 N# k" j
# ~. q: Q- F$ _% y        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->SetFunction(nullNXObject);* M% c0 m4 U" c& s+ Y
4 q8 e1 _+ b# J& o: a  b! O, |
        jointBuilder1->JointMultiDrivers()->MotionEulerAngle1()->VelocityExpression()->SetRightHandSide("20");
4 p% F/ M4 S$ }
, Q; J$ K3 F# p1 u  g) z5 M( ], }) P* g: M, A6 P
        NXObject *nXObject3;
- |  f% b$ [. j. [        nXObject3 = jointBuilder1->Commit();  t+ D( |8 {4 D8 P8 w

' ]" x9 X; _+ 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

为什么会有表情 - -!
  I: t0 H5 a' p# S; {  N% [# i' [1 E9 R% q; k
有一段ufun实现步进运动的代码请老师们指点,如何兼容已有的nxopen++代码
, v7 m) [) F3 {; w/ `; l( ]$ D7 |& P: Z) A; O( \/ p! v# H
.....
- h7 Z& x" \/ W& X6 `* j6 p- s+ j; j# P# Z
UF_MOTION_init_articulation();1 U+ u; C! g) G- \
for(int i=0;i<360;i++){
0 i' }0 J" w  Y1 J  UF_MOTION_step_articulation(1,&i_ret);, p2 T1 i* z9 ~4 g0 u! {
}4 _+ F4 z% h$ n' C+ z
UF_MOTION_terminate_articulation();
) M$ h7 n7 s' D4 u* b7 NUF_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二次开发专题模块培训报名开始啦

    我知道了