Showing results for 
Search instead for 
Did you mean: 

Getting Occurrence Info - C++

Valued Contributor
Valued Contributor


Hey all,

I'm currently rebuilding several applications in C++ and am having a heck of hard time nailing down some syntax. I'm fairly new to C++ in general and am just now getting to the point where I would *almost* consider myself dangerous.

Currently I'm working on at tool to report out occurence information from a SE assembly. Specifically I'll be reporting out filenames, and whether an assembly is to be shown at the next level or not.

I can open SE, and open a specific asm document without issue, however, when it comes down to getting information from the occurrences I'm clearly missing something. See below for the code that is giving me fits:

 int _tmain(int argc, _TCHAR* argv[])





    ApplicationPtr pApplication = NULL;

    DocumentsPtr pDocs = NULL;

    AssemblyDocumentPtr pDoc = NULL;


    pApplication = StartSolidEdge( true ); //


    pDocs = pApplication->Documents;



    pDoc = pApplication->ActiveDocument;

    OccurrencesPtr oOccurrences = NULL;

    OccurrencePtr oOccurrence = NULL;



    oOccurrences = pDoc->GetOccurrences();


    int ii = 0;


    printf("Found %d occurences\n", oOccurrences->Count);


    for (ii = 1; ii Count; ii++)


        oOccurrence = oOccurrences->Item(ii); //

        printf("Occ %d of %d\t", ii, oOccurrences->Count);

        printf("name:\t%s\tnext_level:\t%d\n", oOccurrence->OccurrenceFileName, oOccurrence->DisplayInSubAssembly);

        oOccurrence = NULL;




    return 0;



Oh, and on another note, how do I get Intellisense to work in VC++ 2005? I seem to have the namespaces imported correctly, but the methods, properties, objects etc dont work with Intellisense, or even the Object Browser.

 Any and all help would be much appriceated.



Posted by: Jeremy Bateman
Post date: 10/10/2008 12:16:10 PM


RE: Getting Occurrence Info - C++

Valued Contributor
Valued Contributor


I attached a demo to show you how I do things.  Your problem is the use on "int" in the loop.  Remember that int in C++ is short in VB\.NET.  You must use the "LONG" keyword in C++.  That translates to int in VB\.NET.

Regarding intellisense, it sucks in VS.NET 2005 and gets much better in VB.NET 2005.  Tips that I use to get it to workSmiley Tongueerform a "Clean Solution" and "Rebuild All"Close VS.NET, delete .ncb file located in same folder as .sln.  When you open back VS.NET, it will rebuild the .ncb (intellisense database).Patience.  Intellisense is updated in a separate thread.  Sometimes it just takes awhile for it to update.

p.s.  Take note of how I setup my includes in stdafx.h.

Good luck!


Posted by: Jason Newell
Post date: 10/13/2008 5:27:30 AM

RE: Getting Occurrence Info - C++

Valued Contributor
Valued Contributor


Great, thanks for the example Jason! I actually had just stumbled across my int error in finding another sample on the UGS solutions search.

As for Intellisense, i rebuild the database, but it's still far from perfect. Luckily I only have a handful of these apps to rebuild and thus far have been able to find decent C++ samples, and using previous SDK's and SEspy I should be able to peice together all the rest.

Thanks again.



Posted by: Jeremy Bateman
Post date: 10/13/2008 6:22:05 AM