|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
【PLM之家NX二次开发自动装配项目】1.6 创建固定约束
) T8 U; q0 }+ @: [: K1 p1 X装配约束的创建过程,如何创建一个对象的约束为固定约束!& b% ]2 p+ T3 U$ q# ], ?
8 o5 B5 [9 f G# _# c6 K2 H# ]% h* g" |6 }, V3 p( e
- S! A/ R1 s z3 O5 D+ }
// 创建固定约束
2 G/ C# m% |( F9 e- |: g3 M9 V- L4 v, U6 @3 G
7 T. C" m( I; R' W* `# A+ a" M9 S, h
Positioning::ComponentPositioner *componentPositioner1;
- P# Z, G- q) q. N8 P; c componentPositioner1 = workPart->ComponentAssembly()->Positioner();
4 \! K* O8 {4 p0 [! O4 ^ componentPositioner1->ClearNetwork();
( Q( l( k7 ]- _2 ]' f% v, u componentPositioner1->BeginAssemblyConstraints();
8 a+ z' B& A" ]6 P+ i/ r$ p/ g: G( i Positioning::Network *network1;) B9 q3 d' P7 d0 Y
network1 = componentPositioner1->EstablishNetwork();
2 O6 ^1 J6 a1 K( O Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));* }8 J! ^. _8 W/ O g R6 J7 \
componentNetwork1->SetMoveObjectsState(true);" z% ~* W9 Z- u$ a, B
Assemblies::Component *nullAssemblies_Component(NULL);7 S, g } @7 v: l
componentNetwork1->SetDisplayComponent(nullAssemblies_Component);9 x4 {# [4 I' e2 ]
componentNetwork1->SetNetworkArrangementsMode(Positioning::ComponentNetwork::ArrangementsModeExisting);" ]1 Q* o( t) t$ F7 z. z# Q* F/ _
Positioning::Constraint *constraint1;: e" r8 K" D4 U" Q" x3 z
constraint1 = componentPositioner1->CreateConstraint(true);; l. J0 }) R; [: |0 K% J4 [, f h
Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));! ~% G. h/ Z% E% g. O
componentConstraint1->SetConstraintType(Positioning::Constraint::TypeFix);
; i- B3 t/ V5 v: g4 x Positioning::ConstraintReference *constraintReference1;
/ A7 l6 E6 |. X; D e4 P constraintReference1 = componentConstraint1->CreateConstraintReference(component1, component1, false, false, false);& B, g; u4 D8 ^/ F b
Point3d helpPoint1(0, 0, 0);
: [# s7 ` h% c0 Z# z9 h constraintReference1->SetHelpPoint(helpPoint1);5 ^1 g- k, Q8 a# X4 E( r
componentNetwork1->Solve();2 |' ?4 | n }- k* z
componentPositioner1->ClearNetwork();
8 ~* Y# I. j) E- W6 W$ v* v componentPositioner1->DeleteNonPersistentConstraints();
! u ^, t. t o0 \; O0 _+ s9 q' l Assemblies::Arrangement *nullAssemblies_Arrangement(NULL);
$ X& Y+ P* Z x componentPositioner1->SetPrimaryArrangement(nullAssemblies_Arrangement);: d9 w! H" d7 B/ I, u; B
componentPositioner1->EndAssemblyConstraints();: F: k2 f. s( K6 S! O. V- R7 |: Q
0 v9 \. l& g! Z |
|