I'm trying to get the Border of a drawing (IDW) but compilation fails...
error C2923: 'ATL::CComPtr': 'Border' is not a valid template type argument for parameter 'T'
Here's the code, all my other uses of ComPtr<T> work perfectly:
CComPtr<Sheet> pSheet = nullptr ; // Get some data about the sheet... double SheetHeight,SheetWidth,Border ; CComBSTR bstrSheetName ; pSheet->get_Name (&bstrSheetName) ;
pSheet->get_Width(&SheetWidth) ; pSheet->get_Height(&SheetHeight) ;
CComPtr<Border> pBorder; // <---- Border is not a type name !!!HERE!!! pSheet->get_Border(&pBorder);
What am I missing? get_Border exists as a function, but the type Border no it seems...
Solved! Go to Solution.
Solved by chandra.shekar.g. Go to Solution.
CComPtr<Sheet> pSheet = nullptr ; // Get some data about the sheet... double SheetHeight,SheetWidth,Border ; CComBSTR bstrSheetName ; pSheet->get_Name (&bstrSheetName) ;
pSheet->get_Width(&SheetWidth) ; pSheet->get_Height(&SheetHeight) ;
CComPtr<Border> pBorder; // <---- Border is not a type name !!!HERE!!! pSheet->get_Border(&pBorder);As per above code, pSheet is assigned to nullptr and not assigned any value to it. This is what missing in your code.
In my system, get_border is working fine. Try below C++ code to get border.
HRESULT Result = NOERROR; CLSID InvAppClsid; Result = CLSIDFromProgID(L"Inventor.Application", &InvAppClsid); if (FAILED(Result)) return Result; CComPtr<IUnknown> 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<Application> pInvApp; Result = pInvAppUnk->QueryInterface(__uuidof(Application), (void **)&pInvApp); if (FAILED(Result)) return Result; CComPtr<Document> pDoc; Result = pInvApp->get_ActiveDocument(&pDoc); CComPtr<DrawingDocument> pDrawDoc; pDrawDoc = pDoc; CComPtr<Sheet> pSheet; Result = pDrawDoc->get_ActiveSheet(&pSheet); CComPtr<Border> pBorder; Result = pSheet->get_Border(&pBorder); return S_OK;
Please feel free to contact if there is any queries.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
@chandra.shekar.g , thanks for testing. I rebuilt the whole solution and now Border is a recognised type.
Can't find what you're looking for? Ask the community or share your knowledge.