266 lines
9.1 KiB
C++
266 lines
9.1 KiB
C++
#include "stdafx.h"
|
|
#include <DbWell.h>
|
|
#include "DbSlopeRoof.h"
|
|
#include <xtext.h>
|
|
#include "SelectBlkDlg.h"
|
|
|
|
void HelpTwtLaw()
|
|
{
|
|
XString sFile(256);
|
|
sFile << g_csSysPath << _T("TwtLaw.chm");
|
|
if((INT_PTR)ShellExecute(adsw_acadMainWnd(), _T("open"), sFile, NULL, NULL, SW_SHOWNORMAL)<=32) {
|
|
adsout << _T("\n帮助文件TwtLaw.chm不存在,或您没有安装HTML帮助系统(安装IE 4.0或更高的版本)。");
|
|
}
|
|
}
|
|
|
|
void HelpTwt()
|
|
{
|
|
XString sFile(256);
|
|
sFile << g_csSysPath << _T("Twt.chm");
|
|
if((INT_PTR)ShellExecute(adsw_acadMainWnd(), _T("open"), sFile, NULL, NULL, SW_SHOWNORMAL)<=32) {
|
|
adsout << _T("\n帮助文件Twt.chm不存在,或您没有安装HTML帮助系统(安装IE 4.0或更高的版本)。");
|
|
}
|
|
}
|
|
|
|
|
|
void HelpFlash()
|
|
{
|
|
XString sFile(256);
|
|
sFile << g_csSysPath << _T("flash.chm");
|
|
if((INT_PTR)ShellExecute(adsw_acadMainWnd(), _T("open"), sFile, NULL, NULL, SW_SHOWNORMAL)<=32) {
|
|
adsout << _T("\n帮助文件flash.chm不存在,或您没有安装HTML帮助系统(安装IE 4.0或更高的版本)。");
|
|
}
|
|
}
|
|
|
|
//void HelpFlash()
|
|
//{
|
|
// XString sFile(256);
|
|
// sFile << g_csSysPath.Left(g_csSysPath.GetLength() - 5) << _T("\\flash\\flash.htm");
|
|
// if((int)ShellExecute(adsw_acadMainWnd(), _T("open"), sFile, NULL, NULL, SW_SHOWNORMAL)<=32) {
|
|
// adsout << _T("\n帮助文件flash.htm不存在,或您没有安装HTML帮助系统(安装IE 4.0或更高的版本)。");
|
|
// }
|
|
//}
|
|
|
|
|
|
void FiltreErase()
|
|
{
|
|
PickSet ssAll(SS_FREE);
|
|
|
|
if(SelectEntities(_T("\n请选择删除范围<退出>:"), ssAll, RBList()) != RTNORM)
|
|
return;
|
|
Entity entSel;
|
|
PickSet ssSel(SS_FREE);
|
|
ssSel += ssAll;
|
|
|
|
int ret = SelectEntity(_T("\n请选择指定类型的图元<删除>:"), entSel, RBList());
|
|
while(ret == RTNORM){
|
|
BOOL bIsBlkMask = FALSE;
|
|
ssAll.Redraw(4);
|
|
ssSel.Free();
|
|
TCHAR szLayer[256], szEntName[256], szBlkName[256];
|
|
entSel.GetData(8, szLayer);
|
|
entSel.GetData(0, szEntName);
|
|
long len = ssAll.Length();
|
|
if(entSel.Is(_T("INSERT"))){
|
|
bIsBlkMask = TRUE;
|
|
entSel.GetData(2, szBlkName);
|
|
}
|
|
|
|
RBList rbMask(RTDXF0, szEntName, 8, szLayer, NULL);
|
|
RBList rbMask2(RTDXF0, _T("INSERT"), 8, szLayer, 2, szBlkName, NULL);
|
|
|
|
for(long i=0;i<len;i++){
|
|
Entity ent = ssAll[i];
|
|
if(bIsBlkMask){ //安图块名精细过滤
|
|
if(ent.MatchBase(rbMask2))
|
|
ssSel += ent;
|
|
}
|
|
else{
|
|
if(ent.MatchBase(rbMask))
|
|
ssSel += ent;
|
|
}
|
|
}
|
|
ssSel.Redraw(3);
|
|
ret = SelectEntity(_T("\n请选择指定类型的图元<删除>:"), entSel, RBList());
|
|
}
|
|
if(ret == RTCAN){
|
|
ssSel.Redraw(4);
|
|
return;
|
|
}
|
|
|
|
else
|
|
ssSel.Erase();
|
|
}
|
|
|
|
|
|
|
|
void test2()
|
|
{
|
|
|
|
// Entity ent1, ent2;
|
|
// SelectEntity("\n pick 1", ent1, RBList());
|
|
// SelectEntity("\n pick 2", ent2, RBList());
|
|
// XPoly2D poly1(ent1);
|
|
// XPoly2D poly2(ent2);
|
|
// poly1.Compress();
|
|
// poly2.Compress();
|
|
// poly1.flag = 1;
|
|
// poly2.flag = 1;
|
|
////
|
|
////
|
|
// DList<XPoly2D> lstPlyTmp,lstPlyTmp1,lstPlyRes;
|
|
// lstPlyTmp.Append(new XPoly2D(poly1));
|
|
// lstPlyTmp1.Append(new XPoly2D(poly2));
|
|
//
|
|
// Subtract(lstPlyTmp,lstPlyTmp1,lstPlyRes);
|
|
// int len = lstPlyRes.Length();
|
|
//
|
|
//// PickSet ss(SS_FREE);
|
|
//// ss.Get("X",NULL, NULL, NULL);
|
|
//// ads_command(RTSTR, _T("wmfout"), RTSTR, _T("c:\\123.wmf"), RTPICKS, (long *)ss, RTSTR, _T(""),RTNONE);
|
|
////
|
|
// return;
|
|
|
|
TCHAR szName[256];
|
|
ads_getstring(0, _T("\n请输入名字:"), szName);
|
|
AcDbBlockTable* pBlockTable = NULL;
|
|
acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead);
|
|
if(_tcsicmp(szName, _T("*")) == 0){
|
|
AcDbBlockTableIterator *pIterator=NULL;
|
|
pBlockTable->newIterator(pIterator);
|
|
pBlockTable->close();
|
|
for(pIterator->start(); !pIterator->done(); pIterator->step()) {
|
|
AcDbBlockTableRecord *pRec=NULL;
|
|
if(pIterator->getRecord(pRec, AcDb::kForWrite)==Acad::eOk && pRec) {
|
|
TCHAR *str = NULL;
|
|
pRec->getName(str);
|
|
CString csRecordName = str;
|
|
if(csRecordName.Find(_T("*")) > -1 && csRecordName != _T("*MODEL_SPACE") && csRecordName != _T("*PAPER_SPACE")){
|
|
AcDbObjectIdArray idArray;
|
|
pRec->getBlockReferenceIds(idArray);
|
|
int len = idArray.length();
|
|
if(len == 0){
|
|
pRec->erase();
|
|
}
|
|
}
|
|
pRec->close();
|
|
}
|
|
}
|
|
delete pIterator;
|
|
return;
|
|
}
|
|
AcDbBlockTableRecord *pRecord = NULL;
|
|
if(Acad::eOk != pBlockTable->getAt(szName, pRecord, AcDb::kForWrite))
|
|
return;
|
|
pBlockTable->close();
|
|
pRecord->erase();
|
|
pRecord->close();
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 旧图转化
|
|
//***************************************************************************************************
|
|
void SetEntityLayer(Entity ent, const TCHAR* szLayer)
|
|
{
|
|
InitLayer(szLayer);
|
|
AcDbObjectId eId;
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbGetObjectId(eId, ent);
|
|
acdbOpenObject(pEnt, eId, AcDb::kForWrite);
|
|
if(pEnt){
|
|
pEnt->setLayer(szLayer);
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ConverseOldDwg()
|
|
{
|
|
PickSet ssAll(SS_FREE);
|
|
ssAll.Get(_T("X"), NULL, NULL, NULL);
|
|
PickSet ssDel(SS_FREE);
|
|
for(long i=0;i<ssAll.Length();i++){
|
|
Entity ent = ssAll[i];
|
|
TCHAR szLay[256];
|
|
ent.GetData(8, szLay);
|
|
if(ent.Is(_T("ATS_PIPEVALVE")) && _tcsicmp(szLay, _T("GJ-阀门")) == 0){
|
|
SetEntityLayer(ent, _T("EQUIP_阀门"));
|
|
continue;
|
|
}
|
|
else if(ent.Is(_T("ATS_EQUIPMENT")) && _tcsicmp(szLay, _T("GJ")) == 0){
|
|
SetEntityLayer(ent, _T("EQUIP_管件"));
|
|
continue;
|
|
}
|
|
else if(ent.Is(_T("ATS_EQUIPMENT")) && _tcsicmp(szLay, _T("EQ-喷淋")) == 0){
|
|
SetEntityLayer(ent, _T("EQUIP_喷淋"));
|
|
continue;
|
|
}
|
|
else if(ent.Is(_T("ATS_EQUIPMENT")) && _tcsicmp(szLay, _T("EQ-消防")) == 0){
|
|
SetEntityLayer(ent, _T("EQUIP_消防"));
|
|
continue;
|
|
}
|
|
else if(ent.Is(_T("ATS_EQUIPMENT"))){
|
|
BOOL bIsWell = FALSE;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbEquipment, pEquip);
|
|
if(pEquip){
|
|
const TCHAR *szBlkName = NULL;
|
|
AcDbObjectId eqId = pEquip->GetBlock2d();
|
|
OPENOBJ_BEGIN(eqId, AcDb::kForRead, AcDbBlockTableRecord, pRecord);
|
|
if(pRecord)
|
|
pRecord->getName(szBlkName);
|
|
OPENOBJ_END();
|
|
CString csBlkName = szBlkName;
|
|
if(_tcsicmp(csBlkName, _T("$TWTSYS$00000187")) == 0 ||
|
|
_tcsicmp(csBlkName, _T("$TWTSYS$00000186")) == 0 ||
|
|
_tcsicmp(csBlkName, _T("$TWTSYS$00000190")) == 0 ||
|
|
_tcsicmp(csBlkName, _T("$TWTSYS$00000336")) == 0 ||
|
|
_tcsicmp(csBlkName, _T("$TWTSYS$00000191")) == 0){
|
|
TPipeInterface face;
|
|
pEquip->GetInterface(0, face);
|
|
AcDbObjectId nextPipeId = face.m_idPipe;
|
|
CString csLay = _T("WELL_其它");
|
|
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(pPipe->GetSysType() == TPipeSys::kRainWater)
|
|
csLay = _T("WELL_雨水");
|
|
else if(pPipe->GetSysType() == TPipeSys::kDirtWater)
|
|
csLay = _T("WELL_污水");
|
|
else if(pPipe->GetSysType() == TPipeSys::kFeedWater)
|
|
csLay = _T("WELL_给水");
|
|
}
|
|
OPENOBJ_END();
|
|
bIsWell = TRUE;
|
|
TDbWell *pWell = new TDbWell;
|
|
InitLayer(csLay);
|
|
pWell->setLayer(csLay);
|
|
pWell->SetNumber(pEquip->GetNumber());
|
|
if(pEquip->GetScale() > 50)
|
|
pWell->SetScale(pEquip->GetScale() / 100);
|
|
else
|
|
pWell->SetScale(pEquip->GetScale());
|
|
pWell->SetLabelLayer(InitLayer(LAY_DIM));
|
|
pWell->SetTextHeight(g_nDimWellHeight);
|
|
pWell->SetTextStyleId(InitTextStyle(g_csDimWellStyle));
|
|
pWell->EnableDrawLabel(FALSE);
|
|
pWell->SetLocation(pEquip->GetLocation());
|
|
pWell->SetBlock2d(pEquip->GetBlock2d());
|
|
CString csName = ReadXdata(ent, _T("TG-WELLNAME"));
|
|
pWell->SetWellName(csName);
|
|
AddToCurrentSpace(pWell, Adesk::kTrue);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
if(!bIsWell)
|
|
SetEntityLayer(ent, _T("TWT_室外"));
|
|
else
|
|
ssDel += ent;
|
|
continue;
|
|
}
|
|
}
|
|
ssDel.Erase();
|
|
}
|
|
|
|
|
|
|