How to suppress user prompt during IAcadDocumentPtr::Export ?

How to suppress user prompt during IAcadDocumentPtr::Export ?

cdnbake
Enthusiast Enthusiast
864 Views
2 Replies
Message 1 of 3

How to suppress user prompt during IAcadDocumentPtr::Export ?

cdnbake
Enthusiast
Enthusiast

Good morning,


In my ARX module for ACAD 2014-2017, I am trying to export the current view to an image file by using the method IAcadDocumentPtr::Export.

 

After creating a selection set, I call the function as follows:

 

IAcadDocumentPtr pActiveDoc;
/* determination of active document omitted */
IAcadSelectionSetsPtr pSelectionSets = NULL; pActiveDoc->get_SelectionSets(&pSelectionSets);
IAcadSelectionSetPtr pSelectionSet = NULL; _bstr_t bstrtSelectSetName(L"SelectAll"); hr = pSelectionSets->Add(bstrtSelectSetName, &pSelectionSet);
hr = pActiveDoc->Export(bstrThumbnailFullFileName, _T("bmp"), pSelectionSet);
hr = pSelectionSet->Delete();

(I omitted error handling and NULL checks in favour of readability.)

 

While executing pActiveDoc->Export, AutoCAD prompts me for a selection anyways: "Select objects or <all objects and viewports>:".
Do I need to suppress this user prompt explicitly?

If so, then why do I have to pass a selection set to the method in the first place?

 

I also read this article and tried

hr = pActiveDoc->get_ActiveSelectionSet(&pSelectionSet);

beforehand, but the result was the same.

 

 

It would be great if someone could help me with that.

 

 

Have a nice day,
Bettina

Bettina Kutsche
CIDEON
take the value perspective.
0 Likes
Accepted solutions (1)
865 Views
2 Replies
Replies (2)
Message 2 of 3

cdnbake
Enthusiast
Enthusiast
Accepted solution

Hello everyone, 

I got the export working without AutoCAD prompting for an object selection! Smiley Happy

 

I simply had to call the method Select() on my previously created SelectionSet:

_variant_t variantEmpty;
variantEmpty.vt = VT_ERROR;
variantEmpty.lVal = DISP_E_PARAMNOTFOUND;
HRESULT hr = pSelectionSet->Select(acSelectionSetAll, variantEmpty, variantEmpty, variantEmpty, variantEmpty);

Now after calling pActiveDoc->Export() a BMP-Image gets saved as desired.

 

Have a nice day, 

Bettina

Bettina Kutsche
CIDEON
take the value perspective.
0 Likes
Message 3 of 3

cdnbake
Enthusiast
Enthusiast

Update: I have to add a small note about the method IAcadSelectionSet::Select().

 

If you call it on an empty drawing with no objects in it, for example right after creating a new file, the selection set will be empty as well and the IAcadDocument::Export() method will prompt you for input again.

 

For this special case, I had to set up a timer which fires VK_RETURN into the AutoCAD console to simply confirm that I want to export the whole viewport.

// if selection set is empty send timed VK_RETURN
long lCount = 0;
hr = pSelectionSet->get_Count(&count);
if (lCount == 0)
{
  acedGetAcadFrame()->SetTimer( SEND_VK_RETURN_TO_COMMANDLINE_START, 500, NULL);
}

I know this is a bit error prone, since it completely relies on the windows hook finding the correct application window where it can post the key event just in time. Thus, if someone has a better solution in petto, I will happily change it. Smiley Happy

 

Have a nice day, 

Bettina

Bettina Kutsche
CIDEON
take the value perspective.
0 Likes