|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
【PLM之家NX二次开发自动装配项目】1.6 创建固定约束
* h* [' G* F% c* d4 U) t装配约束的创建过程,如何创建一个对象的约束为固定约束!
7 d- ]8 {- @3 C# H0 n
L6 x& q/ e4 z% A) ^% }
: |) _3 a+ t# j3 t( z |; q) }
I, J k1 D j7 W2 p: h- I5 I+ `1 t// 创建固定约束' u+ O6 Q! Z1 F o
+ q* m5 r4 K3 E$ W' O( Y' t' h7 r
) B8 d- ?) _: F4 {4 h: r Positioning::ComponentPositioner *componentPositioner1;4 F8 m" i3 x$ P7 C2 F
componentPositioner1 = workPart->ComponentAssembly()->Positioner();
6 u8 Y* P6 U+ \) N0 D- {" g. N componentPositioner1->ClearNetwork();
8 O r9 A8 d' D5 q4 D; V H componentPositioner1->BeginAssemblyConstraints();, U" I* O% \# b/ Y( V: {
Positioning::Network *network1;/ ~ V0 v0 E: q6 }1 ?! }+ J
network1 = componentPositioner1->EstablishNetwork();" X& N2 |- u1 j' k2 i( r3 U% S1 e
Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));) U7 h: u+ E C" g( R
componentNetwork1->SetMoveObjectsState(true);- |/ d* J7 _# ]0 ^9 l
Assemblies::Component *nullAssemblies_Component(NULL);" T# @. P* E8 B) u! I" i
componentNetwork1->SetDisplayComponent(nullAssemblies_Component);
4 Y* s' Z* |# i; d0 F: z componentNetwork1->SetNetworkArrangementsMode(Positioning::ComponentNetwork::ArrangementsModeExisting);
$ B" J; {% |2 T* e! Q8 K2 U Positioning::Constraint *constraint1;3 W. \6 C1 ]3 V
constraint1 = componentPositioner1->CreateConstraint(true);
5 F e# E/ y: } Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));
4 J% G" Q N3 c7 L% W componentConstraint1->SetConstraintType(Positioning::Constraint::TypeFix);
# I2 G' P3 h4 r( ~/ k. u Positioning::ConstraintReference *constraintReference1;; C. j4 [1 u* Z) ?1 j7 y) y
constraintReference1 = componentConstraint1->CreateConstraintReference(component1, component1, false, false, false);
2 O, J( @& n, F' z Point3d helpPoint1(0, 0, 0);- @6 C7 H+ ~+ N8 a
constraintReference1->SetHelpPoint(helpPoint1);
+ a( p+ v9 V8 }, ~/ g9 K3 } componentNetwork1->Solve();
6 Q5 w4 |0 ]( H0 l- {+ K componentPositioner1->ClearNetwork();3 d5 N8 i# C: f1 X; Z+ c
componentPositioner1->DeleteNonPersistentConstraints();6 ] B! k1 ^2 E3 B: O* v7 a0 |
Assemblies::Arrangement *nullAssemblies_Arrangement(NULL);
3 l; X" h1 n2 B1 l0 ?9 K componentPositioner1->SetPrimaryArrangement(nullAssemblies_Arrangement);+ \* u! n ]/ u, y" g
componentPositioner1->EndAssemblyConstraints();
. Q, P5 S$ L) V& |* x0 @9 d: B
/ X; X( w" _3 |# j7 |7 A& X0 D. s |
|