AnsweredAssumed Answered

MultiSelect2 not working

Question asked by George Kretsis on Oct 7, 2019

Hi everyone,

I am trying to use MultiSelect2 in C++ and cannot get it to work.

There are faces selected in the graphics window, and I want to transfer these to a PropertyManagerPageSelectionbox.

This is my code:


CComPtr<ISelectionMgr>        SelectionMgr;    swDoc->get_ISelectionManager(&SelectionMgr);
CComPtr<ISelectData>        selObj;            SelectionMgr->CreateSelectData ( &selObj );


long nSurfaces = 0;
SelectionMgr->GetSelectedObjectCount2( -1, &nSurfaces );


bounds[0].cElements = nSurfaces;
bounds[0].lLbound = 0;
SAFEARRAY*    selections;
selections = SafeArrayCreate(VT_VARIANT, 1, bounds);


for (int i=0; i<nSurfaces; i++)
    VARIANT v;
    CComPtr<IDispatch> disp = NULL;
    SelectionMgr->GetSelectedObject6( i+1, -1, &disp );
    v.vt = VT_DISPATCH;        v.pdispVal = disp;
    SafeArrayPutElement(selections, (LONG*)&i, &v);


long    retval, mark;
VARIANT    arr;    arr.parray = selections;


swDocExt->MultiSelect2( arr, VARIANT_TRUE, selObj, &retval );


Nothing is transferred to the box. I confirmed that the dispatch objects are returned correctly from GetSelectedObject6, but storage in the safe array does not seem to work well. Any suggestions?