1082 lines
33 KiB
C++
1082 lines
33 KiB
C++
#include "stdafx.h"
|
||
#include "rxregsvc.h"
|
||
#include "TgAs.h"
|
||
#include "BuildOutLineDlg.h"
|
||
|
||
// [2010-3-16 10:46 wubo] 移植到新Geo库
|
||
// extern GEOAPI XString GetTempFileName(const TCHAR *pExt);
|
||
extern TARCH_IMPEXP AcDbObjectId AddBlock(AcDbBlockTableRecord *pRec, BOOL bDoneClosed);
|
||
extern TARCH_IMPEXP int ExplodeBlockRef(AcDbBlockTableRecord &blockRec, ads_matrix matForInsert, DList<AcDbEntity> &entSet);
|
||
extern GEOAPI XString GetTempSymbolName(const TCHAR *symb);
|
||
// [2010-3-16 10:45 wubo] 移植到新Geo库
|
||
// extern GEOAPI XString Int2Char8(unsigned nIndex);
|
||
// [2010-3-16 10:46 wubo] 移植到新Geo库
|
||
// Test Command
|
||
void CheckXD()
|
||
{
|
||
AcDbObjectId idMSpace;
|
||
AcDbBlockTable *pBlockTab=NULL;
|
||
AcDbBlockTableRecord *pMspace=NULL;
|
||
VERIFY(acdbCurDwg()->getSymbolTable(pBlockTab, AcDb::kForRead)==Acad::eOk && pBlockTab);
|
||
VERIFY(pBlockTab->getAt(ACDB_MODEL_SPACE, pMspace, AcDb::kForWrite)==Acad::eOk && pMspace);
|
||
pBlockTab->close();
|
||
resbuf *rbxd=pMspace->xData();
|
||
pMspace->close();
|
||
if (rbxd) {
|
||
adsout << _T("\nOK!");
|
||
ads_relrb(rbxd);
|
||
} else {
|
||
adsout << _T("\nBad!");
|
||
}
|
||
}
|
||
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
/*
|
||
void ExplSaniware()
|
||
{
|
||
XString sDwbFile;
|
||
if (GetFileDia(sDwbFile, 0, _T("DWB"), _T("门窗文件"))!=RTNORM)
|
||
return;
|
||
XStringList lstEntry;
|
||
XPathParser parser(sDwbFile);
|
||
{
|
||
XDrawingLib dwb(sDwbFile);
|
||
dwb.GetAll(lstEntry);
|
||
int len=lstEntry.Length();
|
||
for(int curSelection=0; curSelection<len; curSelection++) {
|
||
XString sDwgFile;
|
||
sDwgFile << parser.m_sDrive << parser.m_sDir << lstEntry[curSelection] << _T(".DWG");
|
||
dwb.Copy(curSelection, sDwgFile);
|
||
}
|
||
}
|
||
|
||
lstEntry.Reset();
|
||
XString sSlbFile;
|
||
sSlbFile << parser.m_sDrive << parser.m_sDir << parser.m_sFileName << _T(".SLB");
|
||
if (FindFile(sSlbFile)) {
|
||
XSlideLib slb(sSlbFile);
|
||
slb.GetAll(lstEntry);
|
||
int len=lstEntry.Length();
|
||
for(int curSelection=0; curSelection<len; curSelection++) {
|
||
XString sSldFile;
|
||
sSldFile << parser.m_sDrive << parser.m_sDir << lstEntry[curSelection] << _T(".SLD");
|
||
slb.Copy(curSelection, sSldFile);
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
void ConvSaniware()
|
||
{
|
||
XString sDbfFile;
|
||
if (GetFileDia(sDbfFile, 0, _T("DBF"), _T("门窗文件"))!=RTNORM)
|
||
return;
|
||
|
||
CodeBase codebase;
|
||
XDbfTable *pTable=codebase.Open(sDbfFile);
|
||
if (pTable) {
|
||
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) {
|
||
// sg modify 100825,解决64位移植后的BUG,强制转换后,数据为空
|
||
// XString sBlock;
|
||
CString sBlock;
|
||
GET_FIELD(pTable, _T("BLOCK"), sBlock);
|
||
if (sBlock.GetLength()>=5)
|
||
{
|
||
for (int n=0; n<5; n++)
|
||
// sBlock[n]=_T('0');
|
||
sBlock.SetAt(n, _T('0'));
|
||
}
|
||
SET_FIELD(pTable, _T("BLOCK"), (const TCHAR*)sBlock);
|
||
}
|
||
}
|
||
|
||
XPathParser parser(sDbfFile);
|
||
XString sSlbFile, sDwbFile;
|
||
sSlbFile << parser.m_sDrive << parser.m_sDir << parser.m_sFileName << _T(".SLB");
|
||
sDwbFile << parser.m_sDrive << parser.m_sDir << parser.m_sFileName << _T(".DWB");
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
|
||
XStringList lstDwg, lstSld;
|
||
dwb.GetAll(lstDwg);
|
||
slb.GetAll(lstSld);
|
||
|
||
for(int i=0; i<lstDwg.Length(); i++) {
|
||
XString sBlock;
|
||
sBlock=lstDwg[i];
|
||
if (sBlock.Length()>=5) {
|
||
for(int n=0; n<5; n++)
|
||
sBlock[n]=_T('0');
|
||
}
|
||
dwb.Rename(i, sBlock);
|
||
}
|
||
|
||
for(i=0; i<lstSld.Length(); i++) {
|
||
XString sBlock;
|
||
sBlock=lstSld[i];
|
||
if (sBlock.Length()>=5) {
|
||
for(int n=0; n<5; n++)
|
||
sBlock[n]=_T('0');
|
||
}
|
||
slb.Rename(i, sBlock);
|
||
}
|
||
}
|
||
|
||
void ConvertTgLib()
|
||
{
|
||
const TCHAR *pszDir=_T("d:\\tangent\\tch5\\图库转换\\");
|
||
XString sLibFile(256), sDwbFile(256), sSlbFile(256);
|
||
const TCHAR *szLibFile=_T("上华图库");
|
||
sLibFile << pszDir << szLibFile << _T(".tk");
|
||
sDwbFile << pszDir << szLibFile << _T(".DWB");
|
||
sSlbFile << pszDir << szLibFile << _T(".SLB");
|
||
|
||
CodeBase db;
|
||
if (!FindFile(sLibFile)) {
|
||
FieldInfo fields[4];
|
||
fields[0] = FieldInfo(_T("kind"), _T('C'), 200);
|
||
fields[1] = FieldInfo(_T("item"), _T('C'), 64);
|
||
fields[2] = FieldInfo(_T("drawing"), _T('C'), 32);
|
||
// Zyu modify on 100721,传入列数
|
||
// XDbfTable *pTable = db.Create(sLibFile, fields);
|
||
XDbfTable *pTable = db.Create(sLibFile, fields, 4);
|
||
pTable->Close();
|
||
}
|
||
XStringList lstFiles;
|
||
FindFiles(pszDir, _T("*.dwg"), lstFiles, TRUE);
|
||
|
||
XDbfTable *pTable=db.Open(sLibFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
ASSERT(pTable);
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
|
||
for(int i=0;i<lstFiles.Length();i++) {
|
||
XString sDwgPath, sSldPath, sDrawing;
|
||
if (GetNextItem(sDwbFile, sDrawing)!=RTNORM)
|
||
return;
|
||
XPathParser parser(lstFiles[i]);
|
||
sDwgPath << pszDir << parser.m_sDir << parser.m_sFileName << _T(".dwg");
|
||
sSldPath << pszDir << parser.m_sDir << parser.m_sFileName << _T(".sld");
|
||
dwb.Append(sDwgPath, sDrawing);
|
||
if (FindFile(sSldPath))
|
||
slb.Append(sSldPath, sDrawing);
|
||
XString sKind;
|
||
sKind=parser.m_sDir;
|
||
// Zyu modify on 100723,消除64位编译警告
|
||
//int nChNum=_tcslen(sKind);
|
||
int nChNum=(int)_tcslen(sKind);
|
||
if(nChNum>0 && sKind[nChNum-1]==_T('\\'))
|
||
sKind[nChNum-1]=EOS;
|
||
pTable->AppendBegin();
|
||
SET_FIELD(pTable, _T("kind"), sKind);
|
||
SET_FIELD(pTable, _T("item"), parser.m_sFileName);
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
pTable->AppendEnd();
|
||
}
|
||
}
|
||
|
||
void ConvertOpLib3d(BOOL bWin)
|
||
{
|
||
const TCHAR *pszDir=_T("d:\\tangent\\tch5\\系统图库\\3d\\");
|
||
XString sLibFile(256), sDwbFile(256), sSlbFile(256);
|
||
const TCHAR *szLibFile=_T("WDLib3D");
|
||
sLibFile << pszDir << szLibFile << _T(".tk");
|
||
sDwbFile << pszDir << szLibFile << _T(".DWB");
|
||
sSlbFile << pszDir << szLibFile << _T(".SLB");
|
||
|
||
CodeBase db;
|
||
if (!FindFile(sLibFile)) {
|
||
FieldInfo fields[4];
|
||
fields[0] = FieldInfo(_T("kind"), _T('C'), 200);
|
||
fields[1] = FieldInfo(_T("item"), _T('C'), 64);
|
||
fields[2] = FieldInfo(_T("drawing"), _T('C'), 32);
|
||
// Zyu modify on 100721,传入列数
|
||
// XDbfTable *pTable = db.Create(sLibFile, fields);
|
||
XDbfTable *pTable = db.Create(sLibFile, fields, 4);
|
||
pTable->Close();
|
||
}
|
||
XStringList lstFiles;
|
||
FindFiles(pszDir, _T("*.dwg"), lstFiles, FALSE);
|
||
|
||
XDbfTable *pTable=db.Open(sLibFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
ASSERT(pTable);
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
|
||
for(int i=0;i<lstFiles.Length();i++) {
|
||
XString sDwgPath, sSldPath, sDrawing;
|
||
if (GetNextItem(sDwbFile, sDrawing)!=RTNORM)
|
||
return;
|
||
XPathParser parser(lstFiles[i]);
|
||
sDwgPath << pszDir << parser.m_sFileName << _T(".dwg");
|
||
sSldPath << pszDir << parser.m_sFileName << _T(".sld");
|
||
dwb.Append(sDwgPath, sDrawing);
|
||
if (FindFile(sSldPath))
|
||
slb.Append(sSldPath, sDrawing);
|
||
|
||
/*
|
||
if (pTable->MoveTo(_T("drawing"), sDrawing, CMP_INSENSITIVE)) {
|
||
SET_FIELD(pTable, _T("kind"), bWin? _T("窗") : _T("门"));
|
||
SET_FIELD(pTable, _T("item"), _T("新样式"));
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
} else {*/
|
||
pTable->AppendBegin();
|
||
SET_FIELD(pTable, _T("kind"), bWin? _T("窗") : _T("门"));
|
||
SET_FIELD(pTable, _T("item"), _T("新样式"));
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
pTable->AppendEnd();
|
||
//}
|
||
}
|
||
}
|
||
|
||
void ConvDoor3d()
|
||
{
|
||
ConvertOpLib3d(FALSE);
|
||
}
|
||
|
||
void ConvWin3d()
|
||
{
|
||
ConvertOpLib3d(TRUE);
|
||
}
|
||
|
||
|
||
// Test Command
|
||
void ConvertOpLib2d(BOOL bWin)
|
||
{
|
||
XString sFileIndex;
|
||
if (GetFileDia(sFileIndex, 0, _T("txt"), _T("门窗文件"))!=RTNORM)
|
||
return;
|
||
|
||
XPathParser parser(sFileIndex);
|
||
XString sLibFile(256), sDwbFile(256), sSlbFile(256);
|
||
const TCHAR *szLibFile=bWin? _T("WinLib2D") : _T("DorLib2D");
|
||
|
||
sLibFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".tk");
|
||
sDwbFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".DWB");
|
||
sSlbFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".SLB");
|
||
|
||
|
||
CodeBase db;
|
||
if (!FindFile(sLibFile)) {
|
||
FieldInfo fields[4];
|
||
fields[0] = FieldInfo(_T("kind"), _T('C'), 200);
|
||
fields[1] = FieldInfo(_T("item"), _T('C'), 64);
|
||
fields[2] = FieldInfo(_T("drawing"), _T('C'), 32);
|
||
// Zyu modify on 100721,传入列数
|
||
// XDbfTable *pTable = db.Create(sLibFile, fields);
|
||
XDbfTable *pTable = db.Create(sLibFile, fields, 4);
|
||
pTable->Close();
|
||
}
|
||
|
||
XDbfTable *pTable=db.Open(sLibFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
ASSERT(pTable);
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
|
||
|
||
FILE *fp=_tfopen(sFileIndex, _T("r"));
|
||
while(!feof(fp)) {
|
||
TCHAR sBuf[256]=_T(""), sDwg[256]=_T(""), sDesc[256]=_T("");
|
||
_fgetts(sBuf, 255, fp);
|
||
if (sBuf[0]) {
|
||
_stscanf(sBuf, _T("%s%s"), sDwg, sDesc);
|
||
if (sDwg[0] && sDesc[0]) {
|
||
XString sDrawing=Int2Char8((unsigned)_ttoi(sDwg));
|
||
XString sDwgPath, sSldPath;
|
||
sDwgPath << parser.m_sDrive << parser.m_sDir << sDwg << _T(".dwg");
|
||
sSldPath << parser.m_sDrive << parser.m_sDir << sDwg << _T(".sld");
|
||
dwb.Append(sDwgPath, sDrawing);
|
||
slb.Append(sSldPath, sDrawing);
|
||
if (pTable->MoveTo(_T("drawing"), sDrawing, CMP_INSENSITIVE)) {
|
||
SET_FIELD(pTable, _T("item"), sDesc);
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
} else {
|
||
pTable->AppendBegin();
|
||
SET_FIELD(pTable, _T("item"), sDesc);
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
pTable->AppendEnd();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
|
||
void ConvDoor2d()
|
||
{
|
||
ConvertOpLib2d(FALSE);
|
||
}
|
||
|
||
void ConvWin2d()
|
||
{
|
||
ConvertOpLib2d(TRUE);
|
||
}
|
||
|
||
// 分解DWB文件
|
||
// nFlag:
|
||
// 0--None
|
||
// 1--3D -> 3T, _T("_HOLE")->LAY_BOUNDARY
|
||
void ExplDwbArg(int nFlag)
|
||
{
|
||
XString sDwbFile;
|
||
if (GetFileDia(sDwbFile, 0, _T("dwb"), _T("DWB文件"))!=RTNORM)
|
||
return;
|
||
|
||
XDrawingLib dwb(sDwbFile);
|
||
XStringList lstEntry;
|
||
dwb.GetAll(lstEntry);
|
||
XPathParser parser(sDwbFile);
|
||
int len=lstEntry.Length();
|
||
for(int curSelection=0; curSelection<len; curSelection++) {
|
||
XString sDwgFile;
|
||
sDwgFile << parser.m_sDrive << parser.m_sDir << lstEntry[curSelection] << _T(".DWG");
|
||
dwb.Copy(curSelection, sDwgFile);
|
||
if (nFlag==1) {
|
||
AcDbDatabase db(false, true);
|
||
#if ADS < 21
|
||
if (db.readDwgFile(sDwgFile, _SH_DENYNO, false)==Acad::eOk)
|
||
#else
|
||
if (db.readDwgFile(sDwgFile, AcDbDatabase::kForReadAndAllShare, false)==Acad::eOk)
|
||
#endif
|
||
{
|
||
AcDbLayerTable *pLayTab=NULL;
|
||
VERIFY(db.getSymbolTable(pLayTab, AcDb::kForRead)==Acad::eOk);
|
||
AcDbLayerTableIterator *pIter=NULL;
|
||
VERIFY(pLayTab->newIterator(pIter)==Acad::eOk);
|
||
pLayTab->close();
|
||
for(pIter->start(); !pIter->done(); pIter->step()) {
|
||
AcDbLayerTableRecord *pRec=NULL;
|
||
if (pIter->getRecord(pRec, AcDb::kForWrite)==Acad::eOk) {
|
||
const TCHAR *szName=NULL;
|
||
VERIFY(pRec->getName(szName)==Acad::eOk);
|
||
if (_tcsicmp(szName, _T("_HOLE"))==0) {
|
||
pRec->setName(LAY_BOUNDARY);
|
||
} else if (_tcslen(szName)>2 && szName[0]==_T('3') && szName[1]==_T('D')) {
|
||
XString sName;
|
||
sName << _T("3T");
|
||
if (szName[2]!=_T('_'))
|
||
sName << _T("_");
|
||
sName << &szName[2];
|
||
pRec->setName(sName);
|
||
}
|
||
pRec->close();
|
||
}
|
||
}
|
||
delete pIter;
|
||
db.saveAs(sDwgFile);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void ExplDwb()
|
||
{
|
||
ExplDwbArg(0);
|
||
}
|
||
|
||
void ExplWD3d()
|
||
{
|
||
ExplDwbArg(1);
|
||
}
|
||
|
||
|
||
// UpdateDwb
|
||
void UpdateDwb()
|
||
{
|
||
XString sDwbFile;
|
||
if (GetFileDia(sDwbFile, 0, _T("DWB"), _T("Select Dwb"))!=RTNORM)
|
||
return;
|
||
|
||
const TCHAR *pszFilter = _T("DWG Files (*.dwg)|*.dwg||");
|
||
CFileDialog dlg(TRUE, _T("DWG"), NULL, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY, pszFilter,
|
||
acedGetAcadFrame());
|
||
TCHAR strFileName[4056] = _T("");
|
||
|
||
TCHAR szDlgTitle[] = _T("选择需入库的DWG文件");
|
||
// Zyu modify on 100722,支持64位
|
||
//int maxChar = 4055, nCode;
|
||
int maxChar = 4055;
|
||
INT_PTR nCode = IDOK;
|
||
dlg.m_ofn.lpstrFile = strFileName;
|
||
dlg.m_ofn.nMaxFile = maxChar;
|
||
dlg.m_ofn.lpstrTitle = szDlgTitle;
|
||
//dlg.m_ofn.lpstrInitialDir = g_szDirName;
|
||
|
||
if ((nCode=dlg.DoModal())==IDOK) {
|
||
POSITION pos = dlg.GetStartPosition();
|
||
XDrawingLib dwb(sDwbFile);
|
||
while(pos!=NULL) {
|
||
CString csPath=dlg.GetNextPathName(pos);
|
||
// Add DWB
|
||
dwb.Append(csPath);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Test Command
|
||
void ConvertSysLib()
|
||
{
|
||
XString sFileIndex;
|
||
if (GetFileDia(sFileIndex, 0, _T("txt"), _T("系统图库文件"))!=RTNORM)
|
||
return;
|
||
|
||
XPathParser parser(sFileIndex);
|
||
XString sLibFile(256), sDwbFile(256), sSlbFile(256);
|
||
const TCHAR *szLibFile=_T("TchSys");
|
||
|
||
sLibFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".tk");
|
||
sDwbFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".DWB");
|
||
sSlbFile << parser.m_sDrive << parser.m_sDir << szLibFile << _T(".SLB");
|
||
|
||
|
||
CodeBase db;
|
||
if (!FindFile(sLibFile)) {
|
||
FieldInfo fields[4];
|
||
fields[0] = FieldInfo(_T("kind"), _T('C'), 200);
|
||
fields[1] = FieldInfo(_T("item"), _T('C'), 64);
|
||
fields[2] = FieldInfo(_T("drawing"), _T('C'), 32);
|
||
// Zyu modify on 100721,传入列数
|
||
// XDbfTable *pTable = db.Create(sLibFile, fields);
|
||
XDbfTable *pTable = db.Create(sLibFile, fields, 4);
|
||
pTable->Close();
|
||
}
|
||
|
||
XDbfTable *pTable=db.Open(sLibFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
ASSERT(pTable);
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
|
||
FILE *fp=_tfopen(sFileIndex, _T("r"));
|
||
while(!feof(fp)) {
|
||
TCHAR sBuf[256]=_T(""), sDwg[256]=_T(""), sDwbDwg[256]=_T(""), sDesc[256]=_T("");
|
||
_fgetts(sBuf, 255, fp);
|
||
if (sBuf[0]) {
|
||
_stscanf(sBuf, _T("%s%s%s"), sDwg, sDwbDwg, sDesc);
|
||
if (sDwg[0] && sDwbDwg[0]) {
|
||
XString sDwgPath, sSldPath, sDwbPath, sSlbPath, sDwbName, sDwgName;
|
||
if (!SplitLibraryPath(sDwbDwg, sDwbName, sDwgName))
|
||
continue;
|
||
sDwbPath << parser.m_sDrive << parser.m_sDir << sDwbName << _T(".dwb");
|
||
sSlbPath << parser.m_sDrive << parser.m_sDir << sDwbName << _T(".slb");
|
||
|
||
XDrawingLib dwb1(sDwbPath, _ios::in|_ios::binary);
|
||
XSlideLib slb1(sSlbPath, _ios::in|_ios::binary);
|
||
int nIndex=0;
|
||
if (dwb1.IsExist(sDwgName, &nIndex)) {
|
||
XString sTempDwg=GetTempFileName(_T(".dwg"));
|
||
if (dwb1.Copy(nIndex, sTempDwg)) {
|
||
dwb.Append(sTempDwg, sDwg);
|
||
}
|
||
}
|
||
if (slb1.IsExist(sDwgName, &nIndex)) {
|
||
XString sTempSld=GetTempFileName(_T(".sld"));
|
||
if (slb1.Copy(nIndex, sTempSld)) {
|
||
slb.Append(sTempSld, sDwg);
|
||
}
|
||
}
|
||
if (pTable->MoveTo(_T("drawing"), sDwg, CMP_INSENSITIVE)) {
|
||
SET_FIELD(pTable, _T("item"), sDesc);
|
||
SET_FIELD(pTable, _T("drawing"), sDwg);
|
||
} else {
|
||
pTable->AppendBegin();
|
||
SET_FIELD(pTable, _T("item"), sDesc);
|
||
SET_FIELD(pTable, _T("drawing"), sDwg);
|
||
pTable->AppendEnd();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
|
||
// [2010-3-16 10:46 wubo] 移植到新Geo库
|
||
// extern GEOAPI int ConnectPolygon(const XPolygonEx &poly1, const XPolygonEx &poly2, XPolygonEx &res);
|
||
|
||
void TestSub()
|
||
{
|
||
Entity ent1;
|
||
PickSet ss2(SS_FREE);
|
||
RBList mask(RTDXF0, _T("LWPOLYLINE"), 70, 1, NULL);
|
||
if (ent1.FilterSelect(_T("\nPoly1:"), mask)==RTNORM &&
|
||
SelectEntities(_T("\nPoly2:"), ss2, mask)==RTNORM) {
|
||
XPoly2D poly1(ent1);
|
||
if (poly1.PathArea()>0.0)
|
||
poly1.Reverse();
|
||
|
||
|
||
XPoly p1;
|
||
poly1.MapToPolygon1(p1, _AS_SYS_UNIT(g_nCirDeviation));
|
||
XPolygonEx q1(p1);
|
||
long len=ss2.Length();
|
||
for(long i=0L; i<len; i++) {
|
||
Entity ent2=ss2[i];
|
||
XPoly2D poly2(ent2);
|
||
if (poly2.PathArea()<0.0)
|
||
poly2.Reverse();
|
||
|
||
XPoly p2;
|
||
poly2.MapToPolygon1(p2, _AS_SYS_UNIT(g_nCirDeviation));
|
||
XPolygonEx q2(p2), q3;
|
||
ConnectPolygon(q1, q2, q3);
|
||
|
||
q1=q3;
|
||
}
|
||
for(i=0; i<q1.Length(); i++) {
|
||
XLine(q1.GetVertex(i), q1.GetVertex(i+1)).Make(q1.IsVisible(i)? _T("2") : _T("1"));
|
||
}
|
||
XTrianglePface lstTris;
|
||
if (q1.Trianglize(lstTris, TRUE)==RTNORM) {
|
||
lstTris.MakePolyface();
|
||
adsout << _T("\n成功的转成面!");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
void TestUnion()
|
||
{
|
||
Entity ent1, ent2;
|
||
RBList mask(RTDXF0, _T("LWPOLYLINE"), 70, 1, NULL);
|
||
if (ent1.FilterSelect(_T("\nPoly1:"), mask)==RTNORM &&
|
||
ent2.FilterSelect(_T("\nPoly2:"), mask)==RTNORM) {
|
||
XPoly2D poly1(ent1), poly2(ent2);
|
||
if (poly1.PathArea()>0.0)
|
||
poly1.Reverse();
|
||
if (poly2.PathArea()>0.0)
|
||
poly2.Reverse();
|
||
|
||
XPoly p1, p2;
|
||
poly1.MapToPolygon1(p1, _AS_SYS_UNIT(g_nCirDeviation));
|
||
poly2.MapToPolygon1(p2, _AS_SYS_UNIT(g_nCirDeviation));
|
||
XPolygonEx q1(p1), q2(p2), q3;
|
||
ConnectPolygon(q1, q2, q3);
|
||
|
||
XTrianglePface lstTris;
|
||
if (q3.Trianglize(lstTris, TRUE)==RTNORM) {
|
||
lstTris.MakePolyface();
|
||
adsout << _T("\n成功的转成面!");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
void ConvertExtra()
|
||
{
|
||
const TCHAR *pszDir=_T("g:\\图库\\");
|
||
XString sLibFile(256), sDwbFile(256), sSlbFile(256);
|
||
const TCHAR *szLibFile=_T("附加图库");
|
||
sLibFile << pszDir << szLibFile << _T(".tk");
|
||
sDwbFile << pszDir << szLibFile << _T(".DWB");
|
||
sSlbFile << pszDir << szLibFile << _T(".SLB");
|
||
|
||
CodeBase db;
|
||
if (!FindFile(sLibFile)) {
|
||
FieldInfo fields[4];
|
||
fields[0] = FieldInfo(_T("kind"), _T('C'), 200);
|
||
fields[1] = FieldInfo(_T("item"), _T('C'), 64);
|
||
fields[2] = FieldInfo(_T("drawing"), _T('C'), 32);
|
||
// Zyu modify on 100721,传入列数
|
||
// XDbfTable *pTable = db.Create(sLibFile, fields);
|
||
XDbfTable *pTable = db.Create(sLibFile, fields, 4);
|
||
pTable->Close();
|
||
}
|
||
XStringList lstFiles;
|
||
FindFiles(pszDir, _T("*.dwg"), lstFiles, TRUE);
|
||
|
||
XDbfTable *pTable=db.Open(sLibFile);
|
||
if (!pTable)
|
||
{
|
||
return;
|
||
}
|
||
ASSERT(pTable);
|
||
XDrawingLib dwb(sDwbFile);
|
||
XSlideLib slb(sSlbFile);
|
||
acedSetStatusBarProgressMeter(_T("正在制作,按ESC中断"), 0, lstFiles.Length());
|
||
|
||
for(int i=0;i<lstFiles.Length();i++) {
|
||
XString sDwgPath, sSldPath, sDrawing;
|
||
if (GetNextItem(sDwbFile, sDrawing)!=RTNORM)
|
||
break;
|
||
if (ads_usrbrk())
|
||
break;
|
||
if (!(i%5))
|
||
acedSetStatusBarProgressMeterPos(i);
|
||
XPathParser parser(lstFiles[i]);
|
||
sDwgPath << pszDir << parser.m_sDir << parser.m_sFileName << _T(".dwg");
|
||
sSldPath << pszDir << parser.m_sDir << parser.m_sFileName << _T(".sld");
|
||
dwb.Append(sDwgPath, sDrawing);
|
||
if (FindFile(sSldPath)) {
|
||
slb.Append(sSldPath, sDrawing);
|
||
} else {
|
||
ads_command(RTSTR, _T(".INSERT"), RTSTR, (const TCHAR *)sDwgPath, RTSTR, _T("0,0,0"),
|
||
RTREAL, 1.0, RTREAL, 1.0, RTREAL, 0.0, RTNONE);
|
||
ads_command(RTSTR, _T(".ZOOM"),RTSTR, _T("extent"), RTNONE);
|
||
ads_command(RTSTR, _T("HIDE"), RTNONE);
|
||
XString xsTempSld=GetTempFileName(_T(".SLD"));
|
||
ads_command(RTSTR, _T("MSLIDE"), RTSTR, (const TCHAR *)xsTempSld, RTNONE);
|
||
slb.Append(xsTempSld, sDrawing);
|
||
Entity ent;
|
||
ent.GetLast();
|
||
ent.Delete();
|
||
_tremove(xsTempSld);
|
||
}
|
||
XString sKind;
|
||
sKind=parser.m_sDir;
|
||
// Zyu modify on 100723,消除64位编译警告
|
||
//int nChNum=_tcslen(sKind);
|
||
int nChNum=(int)_tcslen(sKind);
|
||
if(nChNum>0 && sKind[nChNum-1]==_T('\\'))
|
||
sKind[nChNum-1]=EOS;
|
||
pTable->AppendBegin();
|
||
SET_FIELD(pTable, _T("kind"), sKind);
|
||
SET_FIELD(pTable, _T("item"), parser.m_sFileName);
|
||
SET_FIELD(pTable, _T("drawing"), sDrawing);
|
||
pTable->AppendEnd();
|
||
}
|
||
acedRestoreStatusBar();
|
||
}
|
||
|
||
|
||
void OnWhichWall()
|
||
{
|
||
RBList mask(RTDXF0, _T("TCH_OPENING"), NULL);
|
||
Entity ent;
|
||
if (SelectEntity(_T("\n选择门窗:"), ent, mask)==RTNORM) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pWin);
|
||
if (pWin) {
|
||
AcDbObjectId idWall=pWin->GetWallId();
|
||
if (!idWall) {
|
||
adsout << _T("NONE");
|
||
} else {
|
||
Entity ent;
|
||
acdbGetAdsName(ent.name, idWall);
|
||
TCHAR szHandle[256]=_T("");
|
||
ent.GetData(5, szHandle);
|
||
adsout << szHandle;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
void HitLine()
|
||
{
|
||
Entity entLine;
|
||
XPoint pt;
|
||
RBList rbMask=ads_buildlist(RTDXF0, _T("LINE"), NULL);
|
||
if (entLine.FilterSelect(_T("\nSelect a line:"), rbMask)==RTNORM &&
|
||
ads_getpoint(NULL, _T("\nPick a point:"), pt)==RTNORM) {
|
||
XLine ln(entLine);
|
||
pt=Ucs2Wcs(pt);
|
||
adsout << _T("\nHit Flag=") << ln.HitTest2d(pt);
|
||
}
|
||
}
|
||
|
||
|
||
void HitTriangle()
|
||
{
|
||
Entity entLine;
|
||
XPoint pt;
|
||
RBList rbMask=ads_buildlist(RTDXF0, _T("POLYLINE,LWPOLYLINE"), NULL);
|
||
if (entLine.FilterSelect(_T("\nSelect a triangle:"), rbMask)==RTNORM &&
|
||
ads_getpoint(NULL, _T("\nPick a point:"), pt)==RTNORM) {
|
||
XPoly2D poly(entLine);
|
||
if (poly.Length()!=3)
|
||
return;
|
||
pt=Ucs2Wcs(pt);
|
||
XTriangle tri(*poly[0], *poly[1], *poly[2]);
|
||
adsout << _T("\nHit Flag=") << tri.HitTest2d(pt);
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////
|
||
void FlatBlockRecord(AcDbObjectId id);
|
||
static void SetElev(AcDbEntity *pEnt)
|
||
{
|
||
if (pEnt->isKindOf(AcDbLine::desc())) {
|
||
AcDbLine *pLine=(AcDbLine *)pEnt;
|
||
AcGePoint3d ptStart=pLine->startPoint();
|
||
AcGePoint3d ptEnd=pLine->endPoint();
|
||
ptStart.z=ptEnd.z=0.0;
|
||
pLine->setStartPoint(ptStart);
|
||
pLine->setEndPoint(ptEnd);
|
||
} else if (pEnt->isKindOf(AcDbArc::desc())) {
|
||
AcDbArc *pArc=(AcDbArc *)pEnt;
|
||
AcGePoint3d ptCen=pArc->center();
|
||
ptCen.z=0;
|
||
pArc->setCenter(ptCen);
|
||
} else if (pEnt->isKindOf(AcDbCircle::desc())) {
|
||
AcDbCircle *pCir=(AcDbCircle *)pEnt;
|
||
AcGePoint3d ptCen=pCir->center();
|
||
ptCen.z=0;
|
||
pCir->setCenter(ptCen);
|
||
} else if (pEnt->isKindOf(AcDbPolyline::desc())) {
|
||
AcDbPolyline *pPolyline=(AcDbPolyline *)pEnt;
|
||
pPolyline->setElevation(0.0);
|
||
} else if (pEnt->isKindOf(AcDbHatch::desc())) {
|
||
AcDbHatch *pHatch=(AcDbHatch *)pEnt;
|
||
pHatch->setElevation(0.0);
|
||
} else if (pEnt->isKindOf(AcDbBlockReference::desc())) {
|
||
//AcDbObjectId id=((AcDbBlockReference*)pEnt)->blockTableRecord();
|
||
//FlatBlockRecord(id);
|
||
AcDbBlockReference *pInsert=AcDbBlockReference::cast(pEnt);
|
||
AcGePoint3d pt=pInsert->position();
|
||
pt.z=0;
|
||
pInsert->setPosition(pt);
|
||
}
|
||
}
|
||
|
||
void FlatBlockRecord(AcDbObjectId id)
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbBlockTableRecord, pMspace);
|
||
if (pMspace) {
|
||
AcDbBlockTableRecordIterator *pIter=NULL;
|
||
VERIFY(pMspace->newIterator(pIter)==Acad::eOk);
|
||
for(pIter->start(); !pIter->done(); pIter->step()) {
|
||
AcDbEntity *pEnt=NULL;
|
||
VERIFY(pIter->getEntity(pEnt, AcDb::kForWrite)==Acad::eOk);
|
||
SetElev(pEnt);
|
||
pEnt->close();
|
||
}
|
||
delete pIter;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
// 邪门,导致图形发生意想不到的变化
|
||
// Append导致index发生变化造成。
|
||
void FlatBlock()
|
||
{
|
||
XString sDwbFile, sTempPath(256);
|
||
if (GetFileDia(sDwbFile, 0, _T("DWB"), _T("选择图块包文件"))!=RTNORM)
|
||
return;
|
||
|
||
XDrawingLib dwb(sDwbFile);
|
||
GetTempPath(255, sTempPath);
|
||
TCHAR cTail=sTempPath[int(_tcslen(sTempPath)-1)];
|
||
if (cTail!=_T('\\'))
|
||
sTempPath << _T("\\");
|
||
|
||
sTempPath << _T("FLATDWB\\");
|
||
MakeDir(sTempPath);
|
||
|
||
XStringList lstDwg;
|
||
dwb.GetAll(lstDwg);
|
||
for(int i=0; i<lstDwg.Length(); i++) {
|
||
XString sFile;
|
||
sFile << sTempPath << lstDwg[i];
|
||
dwb.Copy(i, sFile);
|
||
sFile << _T(".dwg");
|
||
|
||
BOOL bUpdate=FALSE;
|
||
{
|
||
AcDbDatabase db(false, true);
|
||
if (db.readDwgFile(sFile)==Acad::eOk) {
|
||
AcDbObjectId idMspace=GetMSpaceId(&db);
|
||
FlatBlockRecord(idMspace);
|
||
if (db.saveAs(sFile)==Acad::eOk) {
|
||
bUpdate=TRUE;
|
||
}
|
||
}
|
||
}
|
||
if (bUpdate) {
|
||
dwb.Append(sFile);
|
||
}
|
||
_tremove(sFile);
|
||
}
|
||
}
|
||
|
||
|
||
void SplitCurve()
|
||
{
|
||
RBList mask=ads_buildlist(RTDXF0, _T("LWPOLYLINE"), NULL);
|
||
Entity ent;
|
||
if (SelectEntity(_T("\nSelect polyline:"), ent, mask)!=RTNORM)
|
||
return;
|
||
XPoint pt1, pt2;
|
||
if (ads_getpoint(NULL, _T("\nPoint1: "), pt1)!=RTNORM ||
|
||
ads_getpoint(NULL, _T("\nPoint2: "), pt2)!=RTNORM)
|
||
return;
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbPolyline, pLine);
|
||
if (pLine) {
|
||
AcGePoint3dArray points;
|
||
points.append(pt1);
|
||
points.append(pt2);
|
||
AcDbVoidPtrArray entSet;
|
||
if (pLine->getSplitCurves(points, entSet)==Acad::eOk) {
|
||
pLine->erase();
|
||
for(int i=0; i<entSet.length(); i++) {
|
||
AcDbEntity *pEnt=(AcDbEntity *)entSet[i];
|
||
pEnt->setColorIndex(i+1);
|
||
AddToModelSpace(pEnt, Adesk::kTrue);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
|
||
void TransMvInsert()
|
||
{
|
||
Entity ent;
|
||
RBList mask=ads_buildlist(RTDXF0, _T("TCH_MVINSERT"), NULL);
|
||
if (ent.FilterSelect(_T("\nSelect MV insert: "), mask)==RTNORM) {
|
||
AcDbObjectId id2d, id3d;
|
||
AcGeMatrix3d mat;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbMultiViewInsert, pInsert);
|
||
id2d=pInsert->GetBlockId(FALSE);
|
||
id3d=pInsert->GetBlockId(TRUE);
|
||
AcDbBlockReference *pInsert2d=pInsert->NewBlock(FALSE);
|
||
AcDbBlockReference *pInsert3d=pInsert->NewBlock(TRUE);
|
||
pInsert2d->setScaleFactors(AcGeScale3d(1,1,1));
|
||
pInsert3d->setScaleFactors(AcGeScale3d(1,1,1));
|
||
pInsert2d->setRotation(0);
|
||
pInsert3d->setRotation(0);
|
||
TBlockGeomInfo geom2d, geom3d;
|
||
geom2d.SetFromInsert(pInsert2d);
|
||
geom3d.SetFromInsert(pInsert3d);
|
||
geom2d.m_ptCen.z=geom3d.m_ptCen.z=0;
|
||
ads_matrix mat1;
|
||
geom2d.m_ptCen.GetMoveMatrix(geom3d.m_ptCen, mat1);
|
||
mat=AsAcGeMatrix3d(mat1);
|
||
delete pInsert2d;
|
||
delete pInsert3d;
|
||
OPENOBJ_END();
|
||
|
||
OPENOBJ_BEGIN(id2d, AcDb::kForRead, AcDbBlockTableRecord, pRec);
|
||
AcDbBlockTableRecordIterator *pIter=NULL;
|
||
if (pRec->newIterator(pIter)==Acad::eOk && pIter) {
|
||
for(pIter->start(); !pIter->done(); pIter->step()) {
|
||
AcDbEntity *pEnt=NULL;
|
||
VERIFY(pIter->getEntity(pEnt, AcDb::kForWrite)==Acad::eOk);
|
||
ASSERT(pEnt);
|
||
pEnt->transformBy(mat);
|
||
pEnt->close();
|
||
}
|
||
delete pIter;
|
||
}
|
||
OPENOBJ_END();
|
||
ent.Update();
|
||
}
|
||
}
|
||
|
||
void UpdateMvLib()
|
||
{
|
||
TCHAR dir[256]=_T(""), lib3d[256]=_T("");
|
||
_tcscpy(dir, g_sAppPath);
|
||
|
||
TCHAR *p=&dir[_tcslen(dir)-2];
|
||
|
||
while(*p!=_T('\\') && p!=dir) p--;
|
||
if (*p==_T('\\')) *(p+1)=0;
|
||
_tcscpy(lib3d, dir);
|
||
_tcscat(lib3d, _T("LIB3D\\"));
|
||
|
||
Entity ent;
|
||
RBList mask=ads_buildlist(RTDXF0, _T("TCH_MVINSERT"), NULL);
|
||
if (ent.FilterSelect(_T("\nSelect MV insert: "), mask)==RTNORM) {
|
||
AcDbObjectId id2d, id3d;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbMultiViewInsert, pInsert);
|
||
id2d=pInsert->GetBlockId(FALSE);
|
||
id3d=pInsert->GetBlockId(TRUE);
|
||
OPENOBJ_END();
|
||
int iFlag=1;
|
||
adsout << _T("\n输入更新内容(0x01-更新二维,0x02-更新三维)<") << iFlag << _T(">: ");
|
||
if (ads_getint(_T(""), &iFlag)!=RTCAN) {
|
||
XString sBlock2d, sBlock3d;
|
||
ent.GetData(1, (TCHAR *)sBlock2d);
|
||
ent.GetData(2, (TCHAR *)sBlock3d);
|
||
if (iFlag&0x01) {
|
||
XString sDwb, sDwg;
|
||
if (SplitBlockName(sBlock2d, sDwb, sDwg)==Acad::eOk) {
|
||
XString sDwbPath, sDwgPath;
|
||
sDwbPath << lib3d << sDwb << _T(".dwb");
|
||
sDwgPath << lib3d << sDwg << _T(".dwg");
|
||
AcDbDatabase *db=NULL;
|
||
if (acdbCurDwg()->wblock(db, id2d)==Acad::eOk) {
|
||
_tremove(sDwgPath);
|
||
db->saveAs(sDwgPath);
|
||
delete db;
|
||
XDrawingLib dwb(sDwbPath);
|
||
dwb.Append(sDwgPath);
|
||
_tremove(sDwgPath);
|
||
}
|
||
}
|
||
}
|
||
if (iFlag&0x02) {
|
||
XString sDwb, sDwg;
|
||
if (SplitBlockName(sBlock3d, sDwb, sDwg)==Acad::eOk) {
|
||
XString sDwbPath, sDwgPath;
|
||
sDwbPath << lib3d << sDwb << _T(".dwb");
|
||
sDwgPath << lib3d << sDwg << _T(".dwg");
|
||
AcDbDatabase *db=NULL;
|
||
if (acdbCurDwg()->wblock(db, id3d)==Acad::eOk) {
|
||
_tremove(sDwgPath);
|
||
db->saveAs(sDwgPath);
|
||
delete db;
|
||
XDrawingLib dwb(sDwbPath);
|
||
dwb.Append(sDwgPath);
|
||
_tremove(sDwgPath);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 移除acad.exe的有害资源
|
||
/*
|
||
bool RemoveRT_MANIFEST(const TCHAR* fullPath=_T("acad.exe"),int resId=1)//for ACAD.exe,set resId to 1
|
||
{
|
||
HANDLE hUpdateRes = BeginUpdateResource(fullPath,FALSE);
|
||
if (hUpdateRes == NULL)
|
||
return false;
|
||
if (!UpdateResource(hUpdateRes,RT_MANIFEST,MAKEINTRESOURCE(resId),
|
||
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),NULL,NULL))
|
||
return false;
|
||
if (!EndUpdateResource(hUpdateRes, FALSE))
|
||
return false;
|
||
return true;
|
||
}
|
||
*/
|
||
|
||
extern BOOL MakeOUTWALL(PickSet &ssWalls, CString slayname,CString sLineType, double dThickness, int ntypetri, int nBaltype);
|
||
extern int DragInputPoly(XPoint ptStart, XPoly2D &poly2dRet, CString strLayer);
|
||
extern BOOL GetPLLeftDownPoint(AcDbPolyline *pLwPoly, XPoint &ptLoc);
|
||
//建筑轮廓
|
||
void BuildOutLine()
|
||
{
|
||
CBuildOutLineDlg *pDlg = new CBuildOutLineDlg(acedGetAcadFrame());
|
||
pDlg->Create(IDD_DIALOG_BUILDOUTLINE);
|
||
pDlg->ShowWindow(SW_SHOW);
|
||
acedGetAcadDwgView()->SetFocus();
|
||
bool bExit = false;
|
||
while(1)
|
||
{
|
||
pDlg->m_bUseEsc = true;
|
||
//自动搜索上华墙、柱等实体
|
||
if (CBuildOutLineDlg::kSearchAuto ==pDlg->GetDrawType())
|
||
{
|
||
PickSet ssWalls(SS_FREE);
|
||
g_ssPickFirst.Free();
|
||
int iRet = SelectEntities(_T("\n请选择构成一完整建筑平面的所有墙柱、门窗(该命令仅限于世界坐标系运行):"), ssWalls,RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL,TCH_OPENING,TCH_BALCONY"), NULL));
|
||
if ( iRet == RTNORM)
|
||
{
|
||
MakeOUTWALL(ssWalls, pDlg->GetLayerName(), pDlg->GetLineType(), pDlg->GetLineWidth(), pDlg->IsFlagTri(), pDlg->IsDrawBalcony());
|
||
}
|
||
else if (pDlg->m_bUseEsc)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
//任意绘制
|
||
else if (CBuildOutLineDlg::kAnyDraw ==pDlg->GetDrawType())
|
||
{
|
||
XPoint ptStart;
|
||
int nRet = ads_getpoint(NULL, _T("\n请点取建筑轮廓线起点<退出>:"), ptStart);
|
||
XPoly2D poly2dRet;
|
||
if (nRet == RTNORM)
|
||
{
|
||
ptStart = Ucs2Wcs(ptStart);
|
||
XPoly2D polyLine;
|
||
polyLine.AppendNode(ptStart);
|
||
if (RTNORM == DragInputPoly(ptStart, polyLine, pDlg->GetLayerName()))
|
||
{
|
||
AcDbPolyline *pPLine = new AcDbPolyline;
|
||
AssureLayer(pDlg->GetLayerName(), LAYSTAT_UNLOCK);
|
||
pPLine->setLayer(pDlg->GetLayerName());
|
||
PolyConvert(polyLine, *pPLine);
|
||
pPLine->setClosed(Adesk::kTrue);
|
||
pPLine->setConstantWidth(pDlg->GetLineWidth());
|
||
AcDbObjectId idLineType = InitLineType(pDlg->GetLineType());
|
||
pPLine->setLinetype(idLineType);
|
||
AcDbObjectId polyId = AddToModelSpace(pPLine, Adesk::kTrue);
|
||
ASSERT(!!polyId);
|
||
OPENOBJ_BEGIN(polyId, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt)
|
||
pEnt->draw();
|
||
OPENOBJ_END();
|
||
CPoint ptCursor;
|
||
XPoint ptLoc;//获取当前基点
|
||
GetPLLeftDownPoint(pPLine, ptLoc);
|
||
ASSERT(!!polyId);
|
||
OPENOBJ_BEGIN(polyId, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt)
|
||
pEnt->draw();
|
||
OPENOBJ_END();
|
||
int iRet = 0;
|
||
PickSet ss(SS_FREE);
|
||
ss += polyId;
|
||
ss.IncludeEnd();
|
||
iRet = DragPickSet(ss,ptLoc);
|
||
if (iRet!=RTNORM)
|
||
{
|
||
if (iRet == RTCAN )
|
||
{
|
||
ss.Redraw(1);
|
||
ss.Delete();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
else if (pDlg->m_bUseEsc)
|
||
break;
|
||
}
|
||
//拾取参数
|
||
else if (CBuildOutLineDlg::kPickData == pDlg->GetDrawType())
|
||
{
|
||
double dWidth(0);
|
||
CString sLayer(_T("")), sLineType(_T(""));
|
||
RBList rbMask1(RTDXF0, _T("LINE,ARC,CIRCLE,POLYLINE,LWPOLYLINE,TCH_*"), NULL);
|
||
Entity ent1;
|
||
if (SelectEntity(_T("\n请拾取参考对象<返回>:"), ent1, rbMask1) == RTNORM)
|
||
{
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt==NULL)
|
||
break;
|
||
if (pEnt->isKindOf(AcDbPolyline::desc()))
|
||
{
|
||
AcDbPolyline *pline = AcDbPolyline::cast(pEnt);
|
||
pline->getConstantWidth(dWidth);
|
||
}
|
||
sLayer = pEnt->layer();
|
||
sLineType = pEnt->linetype();
|
||
OPENOBJ_END()
|
||
pDlg->SetLayerName(sLayer);
|
||
pDlg->SetLineType(sLineType);
|
||
pDlg->SetLineWidth(dWidth);
|
||
}
|
||
pDlg->m_bPickMode = FALSE;
|
||
pDlg->UpdateData(FALSE);
|
||
}
|
||
}
|
||
if (pDlg)
|
||
{
|
||
pDlg->DestroyWindow();
|
||
delete pDlg;
|
||
}
|
||
} |