Hi, tanks for your reply!
I'm not working with any PLM system, just my C++ console application and PTC Creo Elements/Direct Modeling 19.0.
Using both 'OsdmObjects.tlb' and 'OsdmServer.tlb' files and following the C++ example provided in the program SDK folder (obtained during the CAD Editor installation) I've implemented the following program.
Code:
int _tmain(int argc, _TCHAR* argv[])
{
cout << endl << "- - - Start testing CoCreate - - - - - - -" << endl << endl;
::CoInitialize(0);
{
CComPtr<CoCreate::Osdm::IApplication> pIAppl;
CComPtr<CoCreate::Osdm::IDocument3D> pIDoc; // Remarks Currently, the only available document type is Document3D.
CComPtr<CoCreate::Osdm::IComponent> pIComp; // Base object for all entities that can be nodes of the 3D model structure tree: Assembly, CoordinateSystem, Part, WorkPlane
CComPtr<CoCreate::Osdm::IComponentArray> pICompArr;
_bstr_t fileToOpen = "c:\\temp\\aaaaa.pkg";
// anything up to 13.20
HRESULT hr = ConnectToOsdm(CoCreate::ServerType_Any, "16.0", 0, 0, &pIAppl);
if (FAILED(hr))
cout << "Not connected" << endl;
else {
cout << "Connected" << endl;
pIAppl->LockUserInterface(); // to suspend the user editor interaction
pICompArr = pIAppl->ILoadFile(fileToOpen);
cout << "List of Components:" << endl;
for (long int i = 0; i < pICompArr->Count; i++)
{
pIComp = pICompArr->GetItem(i);
CoCreate::Osdm::LoadStatus s = pIComp->InqLoadStatus();
cout << "\t" << i << ") " << pIComp->GetName() << " - status: " << GetComponentStatus(s) << endl;
}
pIDoc= pIAppl->InqIActive3DDocument();
// here I would like to Save aaaaa.pkg as bbbbb.pkg
// something like: pIDoc->Save("c:\\temp\\bbbbb.pkg");
pIAppl->UnlockUserInterface(); // to resume the user editor interaction
}
}
::CoUninitialize();
cout << endl << "- - - Test ends - - - - - - -" << endl;
system("PAUSE");
return 0;
}
I don't know wich class/interface can be used to save the aaaaa.pkg as bbbbb.pkg ... reading the 'CoCreate.OsdmObjects.chm' document, which describes the CoCreate object model I haven't found useful info.
Any hint?
T&R,
AB