Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm having troubles inserting an existing part or assembly into a new part (programmatically) with Derive option.
By using Inventor, to create a derived part you have to create a new part from scratch and then Manage\Insert\Derive.
I implemented the code below and it seems working fine to me, but it doesn't open the 'Derived Part' form:
bool InsertNotInteractiveDerived(const std::string filePath, const std::string extension)
{
bool res = false;
CComPtr<Document> pInvDoc = m_InvenApp->ActiveDocument;
CComQIPtr<PartDocument> pPartDoc(pInvDoc);
if (pPartDoc != NULL)
{
res = true;
_bstr_t bstrFilePath(filePath.c_str());
CComPtr<PartComponentDefinition> pPartCompDef = pPartDoc->ComponentDefinition;
CComPtr<ReferenceComponents> pRefComponents = pPartCompDef->ReferenceComponents;
if (extension == ".ipt")
{
HRESULT hres = S_OK;
CComPtr<DerivedPartComponents> pDerPartComponents = pRefComponents->DerivedPartComponents;
CComPtr<DerivedPartUniformScaleDef> pDerivedParUniformScaletDef = pDerPartComponents->CreateDefinition(bstrFilePath);
CComPtr<DerivedPartDefinition> pDerivedParDef;
hres = pDerivedParUniformScaletDef->QueryInterface(&pDerivedParDef);
if (FAILED(hres))
return false;
CComPtr<DerivedPartComponent> pDerPartComp = pPartDoc->ComponentDefinition->ReferenceComponents->DerivedPartComponents->Add(pDerivedParDef);
}
else
{
CComPtr<DerivedAssemblyComponents> pDerAssyComponents = pRefComponents->DerivedAssemblyComponents;
CComPtr<DerivedAssemblyDefinition> pDerivedAssyDef = pDerAssyComponents->CreateDefinition(bstrFilePath);
CComPtr<DerivedAssemblyComponent> pDerAssyComp = pPartDoc->ComponentDefinition->ReferenceComponents->DerivedAssemblyComponents->Add(pDerivedAssyDef);
}
}
return res;
}
What should I do for opening the 'Derived Part' form?
T&R
PS: I'm developing my application in C++, but also VBA answers will be fine (I'll try to convert them to C++ later) .
Solved! Go to Solution.