INSERT IN AN ASSEMBLY AN EXISTING PART OR ASSEMBLY
Hi all,
Loock at the following code :
void CPartInsertAndAssemblySaveDlg::InsertAssembly()
{
IADSessionsPtr iSessions = NULL;
// Get all the open sessions in Alibre.
iSessions = m_pRoot->GetSessions ();
IADSessionPtr iSession = NULL;
iSession = iSessions->Item ((long)0);
IADAssemblySessionPtr assySession = NULL;
iSession->QueryInterface (&assySession);
IADOccurrencePtr rootOccurrence = NULL;
// Get the root of the assembly tree in the open session.
rootOccurrence = assySession->GetRootOccurrence ();
IADOccurrencesPtr occurrences = NULL;
// Get all the occurrences under the root occurrence.
occurrences = rootOccurrence->GetOccurrences ();
IADGeometryFactoryPtr geomFactory = NULL;
// Get the geometry factory from the session. This factory will be used to create
// a tranform which can be used to place a part inside the assembly.
geomFactory = iSession->GetGeometryFactory ();
IADTransformationPtr transf = NULL;
// Create a Identity transform for the part.
transf = geomFactory->CreateIdentityTransform ();
CString partName = CString ("BlockWithHole");
IADOccurrencePtr partOccurrence = NULL;
partOccurrence = occurrences->AddEmptyAssembly( partName.AllocSysString (), transf);
////
CString StrFilePath = "D:\\\\Alibre\\\\New Assembly (1).AD_ASM";
IADDesignSessionPtr objKettlePart;
objKettlePart=m_pRoot->OpenFile( StrFilePath.AllocSysString());
/// occurrences->Add( (VARIANT)objKettlePart, transf); ASSERT ???
}
I'ed modified the sample CPartInsertAndAssemblySaveDlg for adding an existing part-assembly bu the occurrences->Add( (VARIANT)objKettlePart, transf); instruction assert. I found the example in API's HELP in VB. Have I misundertood ? If I comment the instruction a new session is correctly opened displaing "D:\\\\Alibre\\\\New Assembly (1).AD_ASM".
Any suggestion ?
Ezio
:roll:
Hi all,
Loock at the following code :
void CPartInsertAndAssemblySaveDlg::InsertAssembly()
{
IADSessionsPtr iSessions = NULL;
// Get all the open sessions in Alibre.
iSessions = m_pRoot->GetSessions ();
IADSessionPtr iSession = NULL;
iSession = iSessions->Item ((long)0);
IADAssemblySessionPtr assySession = NULL;
iSession->QueryInterface (&assySession);
IADOccurrencePtr rootOccurrence = NULL;
// Get the root of the assembly tree in the open session.
rootOccurrence = assySession->GetRootOccurrence ();
IADOccurrencesPtr occurrences = NULL;
// Get all the occurrences under the root occurrence.
occurrences = rootOccurrence->GetOccurrences ();
IADGeometryFactoryPtr geomFactory = NULL;
// Get the geometry factory from the session. This factory will be used to create
// a tranform which can be used to place a part inside the assembly.
geomFactory = iSession->GetGeometryFactory ();
IADTransformationPtr transf = NULL;
// Create a Identity transform for the part.
transf = geomFactory->CreateIdentityTransform ();
CString partName = CString ("BlockWithHole");
IADOccurrencePtr partOccurrence = NULL;
partOccurrence = occurrences->AddEmptyAssembly( partName.AllocSysString (), transf);
////
CString StrFilePath = "D:\\\\Alibre\\\\New Assembly (1).AD_ASM";
IADDesignSessionPtr objKettlePart;
objKettlePart=m_pRoot->OpenFile( StrFilePath.AllocSysString());
/// occurrences->Add( (VARIANT)objKettlePart, transf); ASSERT ???
}
I'ed modified the sample CPartInsertAndAssemblySaveDlg for adding an existing part-assembly bu the occurrences->Add( (VARIANT)objKettlePart, transf); instruction assert. I found the example in API's HELP in VB. Have I misundertood ? If I comment the instruction a new session is correctly opened displaing "D:\\\\Alibre\\\\New Assembly (1).AD_ASM".
Any suggestion ?
Ezio
:roll: