// BlkBrushDlg.cpp : implementation file // #include "stdafx.h" #include "BlkBrushDlg.h" //#include "arxtools.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CBlkBrushDlg dialog //************************************************************************************************** // 图块刷 //************************************************************************************************** void BrushBlock() { g_ssPickFirst.Free(); Entity entEquip; PickSet ss(SS_FREE); RBList rbMask(RTDXF0, _T("INSERT"), NULL); if(SelectEntities(_T("\n请选取要修改属性的图块 <退出>:"), ss, rbMask) == RTNORM){ Entity entSel; CBlkBrushDlg dlg(acedGetAcadFrame()); { CAcModuleResourceOverride vTemp; dlg.Create(IDD_BLK_BRUSH, acedGetAcadFrame()); } dlg.ShowWindow(SW_SHOW); acedGetAcadDwgView()->SetFocus(); XPoint ptText; if(SelectEntity(_T("\n请选择参考图块<退出>:"), entSel, rbMask) != RTNORM) return; dlg.UpdateData(TRUE); AcGeScale3d scale; double dRotation(0); TCHAR szLay[256]; entSel.GetData(8, szLay); int iColIdx(0); DList lstID; AcDbObjectId idBlock; AcGePoint3d ptSel; OPENOBJ_BEGIN(entSel, AcDb::kForRead, AcDbBlockReference , pRef); if(pRef){ ptSel = pRef->position(); scale = pRef->scaleFactors(); dRotation = pRef->rotation(); iColIdx = pRef->colorIndex(); idBlock = pRef->blockTableRecord(); AcDbObjectIterator *pIter=pRef->attributeIterator(); if(pIter != NULL){ for(pIter->start(); !pIter->done(); pIter->step()) { AcDbObjectId idAttr=pIter->objectId(); lstID.Append(new AcDbObjectId(idAttr)); } } } OPENOBJ_END(); for(long i=0;isetScaleFactors(scale); if(dlg.m_bRotation) pRef->setRotation(dRotation); if(dlg.m_bColor) pRef->setColorIndex(iColIdx); if(dlg.m_bLayer) pRef->setLayer(szLay); if(dlg.m_bBlkName){ pRef->setBlockTableRecord(idBlock); //块属性 AcDbObjectIterator *pIter=pRef->attributeIterator(); if(pIter != NULL){ for(pIter->start(); !pIter->done(); pIter->step()) { AcDbObjectId idAttr=pIter->objectId(); OPENOBJ_BEGIN(idAttr, AcDb::kForWrite, AcDbAttribute, pAttr); if(pAttr) { pAttr->erase(); } OPENOBJ_END(); } } int len = lstID.Length(); AcGePoint3d ptTmp = pRef->position(); AcGeVector3d vt = ptTmp - ptSel; AcGeMatrix3d mat; mat.setToTranslation(vt); for(int j=0;jclone(); AcGePoint3d ptPos = pAttr->position(); AcGePoint3d ptAlignment = pAttr->alignmentPoint(); ptPos.transformBy(mat); ptAlignment.transformBy(mat); attrNew->setPosition(ptPos); attrNew->setAlignmentPoint(ptAlignment); pRef->appendAttribute(attrNew); attrNew->close(); } OPENOBJ_END(); } } } OPENOBJ_END(); } dlg.DestroyWindow(); } } CBlkBrushDlg::CBlkBrushDlg(CWnd* pParent /*=NULL*/) : CModelessDialog(CBlkBrushDlg::IDD, pParent) { //{{AFX_DATA_INIT(CBlkBrushDlg) m_bBlkName = FALSE; m_bLayer = FALSE; m_bColor = FALSE; m_bRotation = TRUE; m_bScale = TRUE; //}}AFX_DATA_INIT } void CBlkBrushDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CBlkBrushDlg) DDX_Check(pDX, IDC_BLKNAME_FILTER, m_bBlkName); DDX_Check(pDX, IDC_LAYER_FILTER, m_bLayer); DDX_Check(pDX, IDC_COLOR_FILTER, m_bColor); DDX_Check(pDX, IDC_ROTATION_FILTER, m_bRotation); DDX_Check(pDX, IDC_SCALE_FILTER, m_bScale); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CBlkBrushDlg, CModelessDialog) //{{AFX_MSG_MAP(CBlkBrushDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CBlkBrushDlg message handlers BOOL CBlkBrushDlg::OnInitDialog() { CModelessDialog::OnInitDialog(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }