|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# o E( I p* r3 S6 y+ SNX二次开发源码分享:选择体导出Step格式
, E% o$ f+ Q3 t" m8 x; r u l6 `- E* s, S. G/ S; I4 y5 m
void StepExport::do_it()% h u: _" P3 s. Z1 ~% z
{
5 ]6 T- @8 l; w1 H- h# ` std::vector<TaggedObject*> objectArray;; u+ h/ K- _. l* f3 ]
if (select_bodies(objectArray))$ ~+ I6 }- f, t- N$ i$ R3 ~- a
{
* y4 h d P W4 w8 B2 Z i1 I NXOpen::Session::UndoMarkId markId1;3 l) U( C) m' g a" N8 n: d
markId1 = theSession->SetUndoMark(NXOpen::Session::MarkVisibilityVisible, "Start");
* F. `; q# m% i& u6 J) R NXString sBaseDir = theSession->GetEnvironmentVariableValue("UGII_BASE_DIR");3 E% y& I; `) d8 q
NXString sCfgFile = sBaseDir + "\\step214ug\\ugstep214.def";& b# {( ?. ]6 [! b% }* u! V3 j1 V- v x
NXString sPartSpec = displayPart->FullPath();3 N p! t) Z* O
std::string sFolder = sPartSpec.GetText();
0 k4 b0 d2 Z2 Y/ D" z3 I/ Z) x1 x, C std::size_t found = sFolder.find_last_of(".");* L$ c; S+ z8 n" q ]
NXString sStepSpec = sFolder.substr(0, found) + ".stp";
" w# U! ^/ ^. n/ n' O. y5 d NXOpen::StepCreator *stepCreator1;
& S: B0 {6 c' `# O4 b5 R9 @ stepCreator1 = theSession->DexManager()->CreateStepCreator();
: C4 `% S2 K/ \9 _) q stepCreator1->SetExportAs(NXOpen::StepCreator::ExportAsOptionAp214);
* H% x5 r' ^+ D! a$ _ stepCreator1->ExportSelectionBlock()->SetSelectionScope(NXOpen::ObjectSelector::ScopeSelectedObjects);
( S; K6 `! i, j stepCreator1->ObjectTypes()->SetSolids(true);
0 K w+ ~! L8 S) g Y1 I% s+ | stepCreator1->SetSettingsFile(sCfgFile);
- `+ H+ H; T" n: r d9 a stepCreator1->SetInputFile(sPartSpec);
: L0 W, X* X2 w$ c3 j& P% t. Y9 y stepCreator1->SetOutputFile(sStepSpec);
, N5 A$ a% }: P5 `! e" j3 Z0 n2 m stepCreator1->SetFileSaveFlag(false);5 e% g) M8 b! o! q+ u$ R
stepCreator1->SetLayerMask("1-256");% o% ~/ y$ P5 {5 y# j
std::stringstream sBodyList("");
# @& w4 h3 Q0 J" D( L/ x5 t* e4 U std::vector<TaggedObject*>::iterator iter;7 v; a& v( L) s5 V1 l6 c1 |
bool added1;# J8 B( `; o! U
for (iter = objectArray.begin(); iter != objectArray.end(); ++iter)
9 h$ E- E, F/ S: j, \% S1 g( y {4 S' S: U# O0 S$ }! l7 ~
Body* theBody = dynamic_cast<NXOpen::Body*>(*iter);
# @2 b% w) h3 V6 V9 ?: Z0 J if (theBody)
% O; c5 t: \6 ]' D* I( Q9 { {
( I2 q( p2 s1 | added1 = stepCreator1->ExportSelectionBlock()->SelectionComp()->Add(theBody);+ C5 J0 g+ f3 w% w j; I
sBodyList << "Adding Body " << (theBody)->Tag() << std::endl;
& G7 ]5 E. c* S5 H }
1 M" `6 B0 D" z! Y C8 M }
$ i5 V7 [! y8 w& S; R/ _ // Debug output
: p( a5 B# H2 J7 @3 [- ?- \ print("UGII_BASE_DIR = " + sBaseDir);
" s& y- [; L" s ~& ?8 f print("Settings File = " + sCfgFile);
' }9 u0 I8 |. h& L6 x2 A print("Input File = " + sPartSpec);0 ?+ ]3 K5 e$ \ h" X
print("Output File = " + sStepSpec);
- `: a2 J5 s* A$ }, E' A print(sBodyList.str());
" T" d1 I% O6 L- |$ T |% [- x NXOpen::NXObject *nXObject1 = stepCreator1->Commit();
; [9 U+ l- d' B2 L1 z2 O, F stepCreator1->Destroy();
/ Q2 l, C6 r, S2 g }5 W; t3 o7 m7 G, o/ e' F8 P: b5 C
* R( F9 O j `3 S/ i K% }' d% n/ ]}5 l9 @/ F* |! n' e$ N
. y4 D. k) C% a( r
|
|