Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"No Browser" when creaing a new part from scratch

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
oransen
408 Views, 5 Replies

"No Browser" when creaing a new part from scratch

I have a program which creates a new part. It works, but

 

  1. The browser pane sets to "No Browser"
  2. The actual part window is not maximised inside the Inventor but in "normal" mode.

 

If I click on the brower I can go into Model mode, and the No Browser option disappears.

 

And I can simply maximise the window using the maximise icon in the part Window.

 

But how do I do these programatically? And why is there no Model browser by default?

 

This is C++ COM from an external EXE.

Tags (2)
5 REPLIES 5
Message 2 of 6
philippe.leefsma
in reply to: oransen

Hi,

 

Can you provide the sample code, so I can test in the same conditions than you do?

 

Thanks,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 6
oransen
in reply to: philippe.leefsma

I'll try to simplify my code to get it into a single file to reproduce the error.

 

Message 4 of 6
oransen
in reply to: philippe.leefsma

I've found the call which has the effect of putting the part window in normal mode and setting the browser to "No Browser"

 

HRESULT CreateNewPartDoc (const CComPtr<Application>& pInvApp, CComPtr<PartDocument>& pPartDocument)
{
    // Get part document template
    _bstr_t templateFilename = pInvApp->MethodGetTemplateFile(kPartDocumentObject, // get the PART template file
                                                              kDefaultSystemOfMeasure,
                                                              kDefault_DraftingStandard,
                                                              vtMissing);
    // Get the list of Documents
    CComPtr<Documents> pDocs;
    HRESULT hr = pInvApp->get_Documents(&pDocs);
    if (FAILED(hr)) {
        return ReturnAndShowCOMError (hr,L"CreateNewPartDoc, get document list failed\n") ;  
    }
    const long ikNumDocs = pDocs->GetCount() ;
    wprintf (L"There are %d documents open in Inventor\n",ikNumDocs) ;

    // Create a new part document
    CComPtr<Document> pDocument;
    hr = pDocs->Add(kPartDocumentObject,
                    templateFilename,
                    VARIANT_TRUE, // create visible
                    &pDocument);  // return value
    if (FAILED(hr)) {
        return ReturnAndShowCOMError (hr,L"CreateNewPartDoc, Add part failed ") ;        
    }

    // convert generic document to partdocument
    
// THIS call causes the "problem" hr = pDocument->QueryInterface(DIID_PartDocument, (void**)&pPartDocument); if (FAILED(hr)) { return ReturnAndShowCOMError (hr,L"CreateNewPartDoc, get part document failed ") ; } return (hr) ; }

 

On that call to QueryInterface(DIID_PartDocument,... the browser disappears, though you can go to the part manually. Inventor 13. See the attached image

 

Message 5 of 6
philippe.leefsma
in reply to: oransen

I am using this code and it works fine:

 

HRESULT CreateNewPartDoc(
	CComPtr<Application> pInventorApp, 
	CComPtr<PartDocument> &pPartDoc)
{
	HRESULT hr = S_OK;

	CComVariant pSubDocType;
	CComBSTR sTemplate;

	hr = pInventorApp->GetTemplateFile(
		kPartDocumentObject, 
		kDefaultSystemOfMeasure, 
		kDefault_DraftingStandard, 
		pSubDocType, 
		&sTemplate);

	if(hr != S_OK)
	{
		return hr;
	}

    CComPtr<Document> pDoc; 

	hr = pInventorApp->Documents->Add(
		kPartDocumentObject, 
		sTemplate, 
		VARIANT_TRUE, 
		&pDoc);

	if(hr != S_OK)
	{
		return hr;
	}
        
	pPartDoc = CComQIPtr<PartDocument>(pDoc);

	return hr;
}

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 6 of 6
oransen
in reply to: philippe.leefsma

Your solution is much cleaner than mine, and works as you say. But now mine does too, I must have been doing something stupid before the call.

 

Anyway thanks, and I'll use your shorter clearer solution.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report