LPSLDWORKS SwApp;
LPMODELDOC2 ModelDocPart;
HRESULT hRes;
VARIANT_BOOL retval;
//定义各类指针
SwApp = TheApplication->GetSWApp();
hRes = SwApp->get_IActiveDoc2 ( &ModelDocPart );
LPASSEMBLYDOC pAssmDoc;
hRes = ModelDocPart->QueryInterface(IID_IAssemblyDoc,(LPVOID*)&pAssmDoc);
LPMODELDOCEXTENSION modelDocExt;
hRes = ModelDocPart->get_Extension ( &modelDocExt );
//更改装配体的部件
LPCALLOUT Callout=NULL; hRes = modelDocExt->SelectByID2(_T("柄1-修正-3@hong1"), _T("COMPONENT"), 0, 0, 0,false,1, Callout,0,&retval);
hRes = pAssmDoc->ReplaceComponents(_T("C://Documents and Settings//Administrator//桌面//111//柄2.SLDPRT"), _T(""), false, 0, &retval);
hRes = ModelDocPart->ClearSelection2 ( true ); //更改装配体的配合
hRe