// This command demonstrates a little know method of opening a Part document without
// creating a window. It relies on setting the option input arg to an unsigned int. The
// value of the int is eight.
#define JDOCUMENTPROP_NOWINDOW 0x00000008
DocumentsPtr pDocs = GetApplicationPtr()->Documents;
if( NULL != pDocs )
V_VT( &vOption ) = VT_UI4;
V_UI4( &vOption ) = (unsigned long )JDOCUMENTPROP_NOWINDOW;
pPartDoc = pDocs->Open( "c:\\temp\\block.par", vOption );
if( NULL != pPartDoc )
FullName = pPartDoc->FullName;
In his example C++ code, he is able to "silently" open a Solid Edge document. By silent, I mean that he is opening the document without any windows being created in the GUI. If you study the code closely, you'll notice that he is passing a value of "8" to the 2nd parameter of the Documents.Open() method. If we examine the definition of that method,
we will notice that the 2nd parameter is named "DocRelationAutoServer". If you're scratching your head right now, I am too. To say that this falls into the "Not obvious at all" category would be an understatement. Regardless, the trick exists and does work. I've tested it will all Solid Edge document types with success. In my test, I converted the code to C# as shown below. Note that the C++ ULONG\LONG translates to C# uint\int. Best that I can tell, the API is mostly only checking the value. I've tested with C# ulong,long,uint & int and all worked.
static void Main(string args)
//var filename = @"C:\Program Files\Solid Edge ST8\Training\Coffee Pot.asm";
//var filename = @"C:\Program Files\Solid Edge ST8\Training\Test Drive_Part_QS1.dft";
//var filename = @"C:\Program Files\Solid Edge ST8\Training\bar.par";
var filename = @"C:\Program Files\Solid Edge ST8\Training\simulation\brace.psm";
var application = SolidEdgeUtils.Connect();
var documents = application.Documents;
// uint and int both work.
//uint JDOCUMENTPROP_NOWINDOW = 0x00000008;
int JDOCUMENTPROP_NOWINDOW = 0x00000008;
var document = (SolidEdgeFramework.SolidEdgeDocument)documents.Open(filename, JDOCUMENTPROP_NOWINDOW);
Taking a step back and looking at this objectively, my opinion is that while I'm grateful that this option exists, it's usability rating is pretty low. If you didn't read the original post or see this blog post, it's likely you would have never known about this ability of the API. In my opinion, the API should be enhanced with something like Documents.OpenInBackground(). That is much more obvious and usable.
This post wouldn't be complete if I didn't mention that as a responsible community member, I immediately filed an Incident Report (IR) with GTAC. IR 7520370 was created and is titled "Add ability to open documents silently via API". My hopes are that Siemens will consider enhancing the API to formally support this option. If you agree, you can call GTAC referencing IR 7520370 and request that your name be added. My understanding is that the more people that call in and add their name, the greater the weight of the IR during the prioritization process.