|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
【PLM之家NX二次开发自动装配项目】1.6 创建固定约束
- X' X8 V" e) e0 i* E3 W装配约束的创建过程,如何创建一个对象的约束为固定约束!
# w2 o! H9 }: N/ ]6 Q+ q
; w& M% {( w: g+ s( `7 m# u. P
4 R3 B+ H" I7 E& R9 ?$ B# I5 Y* Q+ F: A K( }
// 创建固定约束* {. b" V; y2 ^& ^# S# g* X# U
! `5 t" f; H+ U3 q; Q* u
9 ?9 J$ K+ B7 M4 }# h# Y
Positioning::ComponentPositioner *componentPositioner1;: I% m1 ~/ |- e+ S
componentPositioner1 = workPart->ComponentAssembly()->Positioner();
8 a% U) c* D+ ^5 O T }9 @$ I componentPositioner1->ClearNetwork(); E( N; M0 R& j$ H, j3 i$ R
componentPositioner1->BeginAssemblyConstraints();+ E& Z) x5 D9 H8 E2 V0 L
Positioning::Network *network1;. ~$ i# ?3 k2 |/ n$ E
network1 = componentPositioner1->EstablishNetwork();
9 {9 S3 g& L( R Positioning::ComponentNetwork *componentNetwork1(dynamic_cast<Positioning::ComponentNetwork *>(network1));
5 k# [% J7 o2 I componentNetwork1->SetMoveObjectsState(true);
& S6 N3 B3 }. G! Q) D! B- Y1 | Assemblies::Component *nullAssemblies_Component(NULL);: f8 C# s( z N ~
componentNetwork1->SetDisplayComponent(nullAssemblies_Component);+ C( i! R6 x+ X- e/ M/ [" }0 X4 J* L
componentNetwork1->SetNetworkArrangementsMode(Positioning::ComponentNetwork::ArrangementsModeExisting);
4 W) g" q; l7 q: a+ D+ T: Q Positioning::Constraint *constraint1;' b' A7 o. k# |8 j5 \- C8 j
constraint1 = componentPositioner1->CreateConstraint(true);
9 \! U" e1 [) b# Y3 Q# T Positioning::ComponenTConstraint *componentConstraint1(dynamic_cast<Positioning::ComponentConstraint *>(constraint1));* d* J' E r u6 v; N
componentConstraint1->SetConstraintType(Positioning::Constraint::TypeFix);. M* K+ e0 \1 q! N7 {' _
Positioning::ConstraintReference *constraintReference1; c, B/ ?( w! \
constraintReference1 = componentConstraint1->CreateConstraintReference(component1, component1, false, false, false);
; Y8 A. u/ A! P% a# w' K. { Point3d helpPoint1(0, 0, 0);
_* r0 D' Y2 c( s- N5 ~ constraintReference1->SetHelpPoint(helpPoint1);
6 u, W' ?: G& D) ?: @ componentNetwork1->Solve();
8 p. X5 r6 W8 V( g componentPositioner1->ClearNetwork();& P8 O! P8 ]% r
componentPositioner1->DeleteNonPersistentConstraints();
& |6 S1 }( X3 g2 [) q3 o. J' R Assemblies::Arrangement *nullAssemblies_Arrangement(NULL);* E# j0 C4 D r9 Q4 d5 S
componentPositioner1->SetPrimaryArrangement(nullAssemblies_Arrangement);
& t3 z% l. i+ w+ i$ f componentPositioner1->EndAssemblyConstraints();" d6 C7 W* }6 ]: V2 i! C
$ @+ B- c7 [: p0 L ?# m
|
|