Component Definition

Top  Previous  Next

A part component definition is contained inside a part document. The component definition contains the nitty gritty of the actual objects you want to manipulate and add to. Often there are lists of components, like sketches, features, workplanes etc:





To get the PartComponentDefiniton from a PartDocument use this:


   CComPtr<PartDocument> pPartDocument ;

   ... init pPartDocument in some way...


   // Get the component definition inside the PartDoc...

   CComPtr<PartComponentDefinition> pPartCompDef;

   hRes = pPartDocument->get_ComponentDefinition (&pPartCompDef);

   if (FAILED(hRes) || (pPartCompDef == nullptr)) {

       return ReturnAndShowCOMError (hRes,L"get_ComponentDefinition failed") ;



An AssemblyDocument and an AssemblyDocumentDefinition has the same sort of structure. Here you can see just two of the many lists inside an AssemblyDocument:





There are other lists inside an AssemblyComponentDefinition. Here is an example of getting the AssemblyComponentDefinition and the constraints list inside it:


   // Init this in some way......

   CComQIPtr<AssemblyDocument> pAssemblyDoc = pDoc ;


   // Get assembly component definition

   CComPtr<AssemblyComponentDefinition> pAssemblyCompDef;

   hRes = pAssemblyDoc->get_ComponentDefinition(&pAssemblyCompDef);


   CComPtr<AssemblyConstraints> pConstraintList;

   hRes = pAssemblyCompDef->get_Constraints(&pConstraintList) ;




Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)