Reply

How to get the Assembly level features in c++

[ Edited ]

 

When we are trying to get the Assembly feature count and traversing for each feature details... the program is getting crashed... please let me know the proceeding

 

Posted by: Triad User
Post date: 4/27/2009 1:52:01 AM

4 REPLIES

RE: How to get the Assembly level features in c++

[ Edited ]

I'd be glad to help you but I need to see your code first. At least give me a demo snippet of the crash.

 

Posted by: Jason Newell
Post date: 4/27/2009 7:30:27 AM

RE: How to get the Assembly level features in c++

[ Edited ]

 

 Hi Jason,

  Thank you very much for the quick responce... i  hope the problem will be solved  soon.

 Note : I am using Solid Edge V 18.0

//*** I have attached the code... and i am uploading the test file also... please check with this... i have written the comments also ...where it is crashing

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

 

 HRESULT hres=S_OK;

 

 ApplicationPtr pSEApp = NULL;

 

 hres = CoInitialize(NULL);

 

 if (FAILED(pSEApp.GetActiveObject("SolidEdge.Application")))

 {

  // Dont have Solid Edge running. Create a new instance.

  HRESULT hr = pSEApp.CreateInstance("SolidEdge.Application");

  if(FAILED(hr))

  {

   ::MessageBox(0,"Failed to create an instance of Solid Edge",0,0);

   return -1;

  }

 

  pSEApp->PutVisible(VARIANT_TRUE);

 

 }

 if(pSEApp == NULL)

  return -1;

 

 DocumentTypeConstants nDoctype = pSEApp->GetActiveDocumentType();

 if(nDoctype == igAssemblyDocument)

 {

  IDispatchPtr pDisp = pSEApp->GetActiveDocument();

  //Process for the Assembly feature traversing

  AssemblyDocumentPtr pAsmDoc=(AssemblyDocumentPtr)pDisp;

 

  AssemblyFeaturesPtr pAsmFeat=pAsmDoc->GetAssemblyFeatures();

 

  //AssemblyFeaturesExtrudedCutouts information

  AssemblyFeaturesExtrudedCutoutsPtr pAsmFeatExtCuts = pAsmFeat->GetAssemblyFeaturesExtrudedCutouts();

  if(pAsmFeatExtCuts)

  {

   long nAsmFeatCnt = pAsmFeatExtCuts->GetCount();

   for(long l=1;l

   {

    //Application is getting crashed while getting 'AssemblyFeaturesExtrudedCutout"

    AssemblyFeaturesExtrudedCutoutPtr pAsmFeatExtCut= pAsmFeatExtCuts->Item(l);

   }

  }

 }

 

 return 0;

}

 

 

Posted by: Triad User
Post date: 4/27/2009 6:29:30 PM

RE: How to get the Assembly level features in c++

[ Edited ]

 

Not sure why yours is failing.  I pasted my code below and I also attached the solution.  I ran my example in Solid Edge ST.// AssemblyFeaturesExtrudedCutouts.cpp : Defines the entry point for the console application.//#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ HRESULT hr = S_OK; SolidEdgeFramework::ApplicationPtr pApplication = NULL; SolidEdgeFramework:Smiley FrustratedolidEdgeDocumentPtr pDocument = NULL; SolidEdgeAssembly::AssemblyDocumentPtr pAssembly = NULL; SolidEdgeAssembly::AssemblyFeaturesPtr pAssemblyFeatures = NULL; SolidEdgeAssembly::AssemblyFeaturesExtrudedCutoutsPtr pAssemblyFeaturesExtrudedCutouts = NULL; SolidEdgeAssembly::AssemblyFeaturesExtrudedCutoutPtr pAssemblyFeaturesExtrudedCutout = NULL; IfFailGo(CoInitialize(NULL)); IfFailGo(pApplication.GetActiveObject(_T("SolidEdge.Application"))); pDocument = pApplication->ActiveDocument; IfNullGo(pDocument); if (pDocument->Type == SolidEdgeFramework::igAssemblyDocument) { pAssembly = pDocument; pAssemblyFeatures = pAssembly->GetAssemblyFeatures(); pAssemblyFeatures->GetAssemblyFeaturesExtrudedCutouts(); pAssemblyFeaturesExtrudedCutouts = pAssemblyFeatures->GetAssemblyFeaturesExtrudedCutouts(); for (LONG i = 1; i Count; i++) { pAssemblyFeaturesExtrudedCutout = pAssemblyFeaturesExtrudedCutouts->Item(i); _bstr_t bstrName(pAssemblyFeaturesExtrudedCutout->Name); _tprintf(_T("%s\r\n"), bstrName.GetBSTR()); } }Error: pAssemblyFeaturesExtrudedCutout = NULL; pAssemblyFeaturesExtrudedCutouts = NULL; pAssemblyFeatures = NULL; pAssembly = NULL; pDocument = NULL; pApplication = NULL; CoUninitialize(); return 0;}

 

Posted by: Jason Newell
Post date: 4/29/2009 12:14:35 PM

RE: How to get the Assembly level features in c++

[ Edited ]

 

Hi Jason,

  Thank you very much for the reply, i checked your code also in Solid Edge V 18.0, it is failing...  So i want to check it in Solid Edge ST. I will back to you soon.

 

Posted by: Triad User
Post date: 4/29/2009 6:48:32 PM