Visibility

Visibility

Anonymous
Not applicable
483 Views
2 Replies
Message 1 of 3

Visibility

Anonymous
Not applicable
Hi all, can any one help me in checking the visibility of the document. I am expecting codein vc++. thanks in advance.
0 Likes
484 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Here's a modified version of the SimpleExe sample that's delivered with
Inventor. To determine if a document is visible you need to check and see
if it has any views. This demonstrates that process. (Watch out for line
wrapping.)

static HRESULT GetInventorInformation()
{
HRESULT Result = NOERROR;

TCHAR Str[_MAX_PATH];

CLSID InvAppClsid;
Result = CLSIDFromProgID (L"Inventor.Application", &InvAppClsid);
if (FAILED(Result)) return Result;

CComPtr pInvAppUnk;
Result = ::GetActiveObject (InvAppClsid, NULL, &pInvAppUnk);
if (FAILED (Result))
_tprintf_s (_T("*** Could not get hold of an active Inventor application
***\n"));

if (FAILED(Result)) return Result;

CComPtr pInvApp;
Result = pInvAppUnk->QueryInterface (__uuidof(Application), (void **)
&pInvApp);
if (FAILED(Result)) return Result;

// Iterate through the open documents to see if they're visible or not.
CComPtr pDocuments;
Result = pInvApp->get_Documents(&pDocuments);
if (FAILED(Result)) return Result;

long docCount;
Result = pDocuments->get_Count(&docCount);
if (FAILED(Result)) return Result;

int i;
for (i=1; i {
CComPtr pDocument;
Result = pDocuments->get_Item(i, &pDocument);
if (FAILED(Result)) return Result;

// Check to see if it's visible by looking to see if it has any views.
CComPtr pViews;
Result = pDocument->get_Views(&pViews);
if (FAILED(Result)) return Result;

long viewCount;
Result = pViews->get_Count(&viewCount);

VARIANT_BOOL bVisible;
if (viewCount > 0)
bVisible = VARIANT_TRUE;
else
bVisible = VARIANT_FALSE;

if (bVisible == VARIANT_TRUE)
_tcscpy_s (Str, _T("Visible"));
else
_tcscpy_s (Str, _T("Invisible"));

CComBSTR bstrDocName;
Result = pDocument->get_DisplayName(&bstrDocName);
_tprintf_s(_T("%s is %s\n"), bstrDocName, Str);
}

_tscanf_s(_T("Continue: %s"), &Str);

return Result;
}

--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 3 of 3

Anonymous
Not applicable
thank you brain. its working. thanks again for your code help
0 Likes