马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Question
I would like to use ActiveX Automation in an ARX application to find all the
XREF block table records. How can this be done?
Answer
There are four interfaces needed, IAcadApplication, IAcadDocument, IAcadBlocks
and IAcadBlock. One approach is to use MFC's ClassWizard to generate them from
the acad.tlb by your selection. Then it is just a matter of using the interfaces.
In the sample below, the names are printed out at the Acad command line.
Note: See "Using MFC and ClassWizard to Access AutoCAD ActiveX Automation" in
the ObjectARX Developer's guide for more information on using the ActiveX interface.
#include "stdafx.h"
#include "acad.h" // generated by MFC ClassWizard
// no error checking for code brevity
void printXrefBtrs()
{
IAcadApplication iApp(acedGetAcadWinApp()->GetIDispatch(TRUE));
IAcadDocument iDoc(iApp.GetActiveDocument());
IAcadBlocks iBlks(iDoc.GetBlocks());
for(long i=0; i<iBlks.GetCount(); i++)
{
_variant_t x(i);
IAcadBlock iBlk(iBlks.Item(x));
if(iBlk.GetIsXRef() == TRUE)
{
CString str = iBlk.GetName();
acutPrintf("\nBTR # %d is a Xref with name: %s", i,
str);
}
}
}
|