Not applicable output [SOLVED]

I have an application that must count all active model space viewports. Since "acedNumberOfViewports()" is not implemented (error LNK2001: unresolved external symbol) I figure that I can iterate "acedSetCurrentVPort(int)" across all viewport numbers and if return is eOk, that means that viewport is active. Problem is, that call acedSetCurrentVPort(int) to not active viewport prints"Not applicable" to command line.
I have two questions:
-Is there any other way, to count active model space viewports?
-Is it possible to suppress "Not applicable" output?

Comments

  • Dear Nikola,

    I would assume, that iterating the Paperspace block, to collect all AcDbViewPort entities, and checking their associated layout should work ?
    For "acedSetCurrentVPort(int)" which numbers do you use ?
    many greetings !

  • @Torsten Moses

    Thanks for suggestion. Iterating through model space viewports and checking their number method worked. I used this code:

    AcDbViewportTable* pVPT;
    acdbHostApplicationServices()->workingDatabase()->getViewportTable(pVPT, AcDb::kForRead);
    AcDbViewportTableIterator* pVPTI;
    pVPT->newIterator(pVPTI);
    pVPT->close();
    for (; !pVPTI->done(); pVPTI->step() )
    {
    AcDbViewportTableRecord* pVPTR;
    pVPTI->getRecord(pVPTR);
    int num = pVPTR->number();
    pVPTR->close();
    }
    delete pVPTI;

    For "acedSetCurrentVPort(int)" I used numbers from 2 through 6 for now (since ACAD has display limited to max of 4 model space viewports). Because this is not the case in brics, I was looking for dynamic method. The code above is solution to my first question.

    For second:
    -Is it possible to suppress "Not applicable" output?
    I tried changing CMDECHO to 0 but "Not applicable" is still printed to output.

  • Dear Nikola,

    maybe the NOMUTT sysvar (0/1) - which normally suppresses any output - can help here ?
    But be careful - if not properly restored, then nothing will be shown anymore at all, to commandline :-)
    many greetings !

  • Hello!

    Thank you verry nuch for your help, this works!
    N

  • @Torsten Moses
    I was testing NOMUTT on Bricscad 19.1.08 rev. 58779 and 20.1.05 rev. 70998 and on both I get following result. Am I missing something?

  • Dear Nikola,

    indeed - I can also reproduce the strange (getvar "nomutt") with latest V20.2.06 :-(
    I will have a look at the implementation code ...

    Nevertheless, it is best to unconditionally use (setvar "nomutt" 0) at end of the program, and at end of an error handler (if applicable) ...
    many greetings !

  • Dear Nikola,

    I checked (getvar/setvar "NOMUTT) ... all is fine, no worries;
    the "mystery" is, that our Lisp engine automatically resets NOMUTT=0, when the outermost, top-level Lisp is finished ...
    so when you use (setvar "NOMUTT" 1) on commandline, the NOMUTT sysvar is correctly set as 1, suppressing any output ... but immediately afterwards, when (setvar ...) is finished, the Lisp engine resets as NOMUTT=0, as no further Lisp follows ...

    That is just a safety measure to prevent missing output, in case a Lisp program fails to reset NOMUTT ...

    Inside your own DEFUN body, it does effectivey work as intended :-)
    many greetings !

  • Thank you very much for your quick reply!
    Nikola