Пример #1
0
//
//  NAME: selectDocument        
//
//  REMARKS:  Simple utility to have the user choose an open document to
//            perform some action on.
//          
//          
// 
//  RETURNS:
//      void 
static AcApDocument* selectDocument()
{
    AcApDocument* documentArray[10];

    AcApDocument* pDoc;
    AcApDocumentIterator* pDocIter;
    int nDocs = 0;;

    pDocIter = acDocManager->newAcApDocumentIterator();

    for ( ; !pDocIter->done(); pDocIter->step(), nDocs++) {
        pDoc = pDocIter->document();
        documentArray[nDocs] = pDoc;
        acutPrintf("%d.  %s\n", nDocs + 1, pDoc->fileName());
    }
    delete pDocIter;

    acedInitGet(RSG_NOZERO | RSG_NONEG, NULL);
    int iSelection;
    int inputStatus = acedGetInt("Which document should this command execute in: ", &iSelection);
    if (inputStatus == RTNORM && iSelection <= nDocs) {
        return documentArray[iSelection - 1];
    } else {
        return NULL;
    }
}
Пример #2
0
//
//  NAME: listDocuments        
//
//  REMARKS: Iterate over all the open documents. Very common piece of code
//           for MDI aware applications.
//          
// 
//  RETURNS:
//      void 
void
listDocuments()
{
    AcApDocument* pDoc;
    AcApDocumentIterator* pDocIter;

    pDocIter = acDocManager->newAcApDocumentIterator();

    for ( ; !pDocIter->done(); pDocIter->step()) {
        pDoc = pDocIter->document();
        acutPrintf("  %s\n", pDoc->fileName());
    }
    delete pDocIter;
}
void
ArxDbgUtils::getAllDocuments(AcDbVoidPtrArray& docPtrs)
{
    AcApDocumentIterator* iter = acDocManager->newAcApDocumentIterator();
    if (iter) {
        AcApDocument* tmpDoc;
        for (; !iter->done(); iter->step()) {
            tmpDoc = iter->document();
            if (tmpDoc) {
                docPtrs.append(tmpDoc);
            }
            else {
                ASSERT(0);
            }
        }
        delete iter;
	}
}
Пример #4
0
//枚举当前的已经打开的文档
Acad::ErrorStatus XAcDocOp::enumAcDocument(AcApDocuments &arr)
{
	arr.RemoveAll();

	AcApDocumentIterator *pIter;

	pIter	= acDocManager->newAcApDocumentIterator();
	if(pIter == NULL)
		return Acad::eNullIterator;

	for( ; !pIter->done() ; pIter->step())
	{
		arr.Add(pIter->document());
	}

	delete pIter;	//added 2006-11

	return Acad::eOk;
}
Пример #5
0
// getDocFromFilename()
//  Passed a filename, it finds the corresponding document pointer
//  Returns true if successful
bool CMDITestDialog::getDocFromFilename(CString csFileName, AcApDocument* &pNewDocument)
{
    // Iterate over the open documents. We will match the filename if:
    //      The filename specified matches the fully qualified path
    //      name, as returned by AcApDocument::filename()
    //      -or-
    //      The filename specified matches the filename portion of the 
    //      document name

    AcApDocumentIterator* iter = acDocManager->newAcApDocumentIterator();
    AcApDocument* pThisDocument = NULL;
    CString csThisFilename;
    CString csThisFilenameShort;

    csFileName.MakeUpper(); // uppercase comparisons

    while(!iter->done()) {   // Tiptoe through the tulips
        pThisDocument = iter->document();
        csThisFilename = pThisDocument->docTitle();
        csThisFilename.MakeUpper();
        csThisFilenameShort = csThisFilename.Right(csThisFilename.GetLength() -
            csThisFilename.ReverseFind('\\') - 1);

        if(csFileName == csThisFilename ||       // Full path match
            csFileName == csThisFilenameShort || // Matches filename only
            csFileName == csThisFilenameShort.Left( // Filename less extension
                          csThisFilenameShort.GetLength() - 4)) 
        {
            pNewDocument = pThisDocument;
            if( iter )
                delete iter;
            return true;
        }
        iter->step();
    }

    pNewDocument = NULL;
    if( iter )
        delete iter;
    // no match found 
    return false;
}
Пример #6
0
void CMDITestDialog::RebuildListBox()
{
    m_docListBox.ResetContent(); // start from an empty list box

    // at this moment, get all drawing names and add them to the list box.
    AcApDocumentIterator* iter = acDocManager->newAcApDocumentIterator();
    AcApDocument* pDoc = NULL;
    CString csFilename;

    while(!iter->done()) {   
        pDoc = iter->document();
        if(pDoc) {                     // #### make sure pDoc is not NULL ####
            csFilename = pDoc->docTitle(); 
            m_docListBox.AddString( csFilename );
        }
        iter->step();
    }
    if( iter )
        delete iter;
}
Пример #7
0
// commandStats:  Print out current Session and Cumulative Stats
void initStats()
{
    cmdr   = new AsdkCommandReactor();
    statFileName[0] = EOS;

    // Define dictionary to delete all its entries when it is deleted.
    sessionStats = initStatDictionary();
    acedEditor->addReactor(cmdr);
    acedRegCmds->addCommand(/*NOXLATE*/"ASDK_COMMAND_STATS",
                            /*NOXLATE*/"ASDK_CMDSTAT",
                            "CMDSTAT",
                            ACRX_CMD_MODAL,
                            &commandStats);
    acedRegCmds->addCommand(/*NOXLATE*/"ASDK_COMMAND_STATS",
                            /*NOXLATE*/"ASDK_CMDCOUNT",
                            "CMDCOUNT",
                            ACRX_CMD_MODAL,
                            &cmdCommandCount);

    bStatsFileUpdatePending = Adesk::kFalse;

    // Initialize Global struct array
    docData.setLogicalLength(0);

    // Fill array from existing documents
    AcApDocumentIterator* pDocIter = acDocManager->newAcApDocumentIterator();

    for (;!pDocIter->done(); pDocIter->step())
        // add an entry for the document, if some other notification hasn't
        // already done so.
        lookupDoc(pDocIter->document());

    delete pDocIter;

    // Establish current document, if there is one yet.
    if ((docData.length() > 0) && (acDocManager->curDocument() != NULL))
        curDocGlobals = docData[lookupDoc(acDocManager->curDocument())];
    else
        curDocGlobals.doc = NULL;

    pDocReactor = new AsdkDocReactor;
    acDocManager->addReactor(pDocReactor);


    resbuf tempRes;
    int i, j;
    // set the statFileName to be <LOGINNAME>.txt
    // remove blanks and tabs from LOGINNAME, so we have a more 
    // reasonable statFileName.
    if (acedGetVar(/*NOXLATE*/"LOGINNAME", &tempRes) != RTNORM) {
        sprintf(abort_msg, "%.*s Command\nStatistics Gatherer\nFailure 1",
                PRODUCTL, getProductName());
        acrx_abort(abort_msg);
    }
    strcpy(statFileName, tempRes.resval.rstring);
    acdbFree (tempRes.resval.rstring) ;
    for (i = 0, j = 0;
         (statFileName[i] != EOS) && (j < LOGINNAME_LENGTH);
         i++) {
        if ((statFileName[i] != ' ') && (statFileName[i] != '\t')) {
            statFileName[j] = statFileName[i];
            j++;
        }
    }
    statFileName[j] = EOS;
    strcat(statFileName, /*NOXLATE*/".txt");
}