5226 lines
139 KiB
C++
5226 lines
139 KiB
C++
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "SetWall.h" //设置墙体参数的对话框
|
|
#include "WallDlg.h"
|
|
#include "actrans.h"
|
|
#include "InsertOpeningDlg.h"
|
|
//add by lgy 20120112 墙体分段对话框
|
|
#include "WallPartDlg.h"
|
|
#include "utility.h"
|
|
|
|
|
|
#define EXP_NONE 0
|
|
#define EXP_TCH 1
|
|
|
|
#include "wall_xdata_key.h"
|
|
|
|
extern TARCH_IMPEXP void TogWallBase();
|
|
|
|
|
|
// 捕捉顺序: 墙基线端点,轴线交点,墙基线最近点,轴线最近点
|
|
// ptWcs -- I/O
|
|
int AutoSnapWall(XPoint &ptWcs);
|
|
|
|
int OsGetPointWall(double *ptFrom, const TCHAR *prompt, XPoint &pt, const TCHAR *kword=NULL, int *kwordId=NULL, BOOL *bDiscontinue=NULL);
|
|
int OsGetCornerWall(double *ptFrom, const TCHAR *prompt, XPoint &pt, const TCHAR *kword=NULL, int *kwordId=NULL);
|
|
|
|
// 拖曳画线性墙
|
|
int DragDrawLine(CDrawWallDlg *pDlg, XPoint &ptStart, const TCHAR *prompt, XPoint &ptEnd,
|
|
const TCHAR *kword=NULL, int *kwordId=NULL, BOOL *bDiscontinue=NULL);
|
|
|
|
// 给定起点, 终点进行拖动半径绘制弧
|
|
int DragDrawArc_SER(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptEnd,
|
|
const TCHAR *prompt, double *nRadius, const TCHAR *kword=NULL, int *kwordId=NULL);
|
|
|
|
// 给定起点, 弧上一点, 进行终点拖动绘制弧
|
|
int DragDrawArc_SPE(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptAny,
|
|
const TCHAR *prompt, XPoint &ptEnd, const TCHAR *kword=NULL, int *kwordId=NULL);
|
|
|
|
// 给定起点, 终点进行弧上一点拖动绘制弧
|
|
int DragDrawArc_SEP(CDrawWallDlg *pDlg, const XPoint &ptStart, const XPoint &ptEnd,
|
|
const TCHAR *prompt, XPoint &ptAny, const TCHAR *kword=NULL, int *kwordId=NULL);
|
|
|
|
|
|
// int InsertColumn(AcDbObjectId idStyle, const TAecCompStyle &mater, const XPoint &ptLoc, double nX, double nY, double nRot, double nHeight);
|
|
//void GetAllColumnBoundry(DList<XPoly2D> &lstClipBoundry);
|
|
BOOL IsInsideColumn(const XPoint &pt2);
|
|
//void AddToModelSpace(AcDbEntity *pEntity, Adesk::Boolean bDoneClose);
|
|
int DoubleWall(XCurveSegment curve, double nHeight, double nElev,TWallData::UsageFlag nUsage,
|
|
TWallData::TWallStyle style, CString sT20Mat, TDbWall::Catalog nCatalog,BOOL bRev=FALSE);
|
|
|
|
|
|
|
|
int g_nOsnapOnWall=OS_NON; //绘制双线墙时的捕捉方式
|
|
int g_nOsnapOnAxis=OS_NON;
|
|
|
|
// modify by xly on 110411 修改支持设置墙体图层
|
|
//extern bool Wall2Curtain(Entity entWall);
|
|
// add by xly on 101029 墙体编辑命令和墙体分段中将墙体材料修改为“玻璃幕墙”与单线变墙中Wall2Curtain功能一致,引入Wall2Curtain函数
|
|
extern bool Wall2Curtain(Entity entWall,CString csLyer=_T(""));
|
|
|
|
//add by lgy 20120116 墙体分段中可以将玻璃幕墙转换成为普通墙,所以引入Curtain2Wall函数
|
|
extern AcDbObjectId Curtain2Wall(Entity entWall,CString csLyer=_T(""));
|
|
|
|
static int ComparePoint(const XPoint *pt1, const void *pt2)
|
|
{
|
|
return !(*pt1==*(const XPoint *)pt2);
|
|
}
|
|
extern TARCH_IMPEXP BOOL g_bRevWallFlag;
|
|
|
|
|
|
// 判断门窗编号是否是顺序编号,true:按顺序,false:按尺寸
|
|
bool CheckDoorWinLabel(CString strName)
|
|
{
|
|
if (strName.GetLength() == 0)
|
|
return false;// 空编号
|
|
if (strName.GetLength() < 5)
|
|
return true; // 不够5个长度肯定不是尺寸编号,
|
|
|
|
CString strSize = strName.Right(4);
|
|
CString strWid = strSize.Left(2);
|
|
CString strHei = strSize.Right(2);
|
|
|
|
if (_ttoi(strHei) > 0 && _ttoi(strWid) > 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 从编号中获取当前的顺序
|
|
int GetSequenceNum(CString strlabel)
|
|
{
|
|
CString strNum = _T("");
|
|
for (int i = strlabel.GetLength() - 1; i > -1; i--)
|
|
{
|
|
TCHAR ch = strlabel.GetAt(i);
|
|
if (ch >= _T('0') && ch <= _T('9'))
|
|
strNum = ch + strNum;
|
|
else
|
|
break;
|
|
}
|
|
|
|
if (strNum.IsEmpty())
|
|
return 0;
|
|
else
|
|
return _ttoi(strNum);
|
|
}
|
|
|
|
|
|
// 从编号中获取当前的顺序
|
|
CString GetSequenceHead(CString strlabel)
|
|
{
|
|
int iHeadLen = 0;
|
|
for (iHeadLen = strlabel.GetLength() - 1; iHeadLen > -1; iHeadLen--)
|
|
{
|
|
TCHAR ch = strlabel.GetAt(iHeadLen);
|
|
if (!(ch >= _T('0') && ch <= _T('9')))
|
|
break;
|
|
}
|
|
|
|
if (strlabel.GetAt(iHeadLen) == _T('-'))
|
|
{
|
|
return strlabel.Left(iHeadLen);
|
|
}
|
|
else
|
|
{
|
|
return strlabel.Left(iHeadLen + 1);
|
|
}
|
|
}
|
|
|
|
// 每种类型都需要有一个函数来判断是否应该采用同名的编号
|
|
bool TestCanSameLabel(TDbBandWin *pBandWin, double dWid, double dHei)
|
|
{
|
|
if (pBandWin == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// sg modify 120514,根据9.0需求,带形窗宽度的测量改用中心线
|
|
//double dWidOld = pBandWin->GetWidth();
|
|
double dWidOld = pBandWin->GetGeomCenterWidth();
|
|
double dHeiOld = pBandWin->GetHeight();
|
|
|
|
if (fabs(dWidOld - dWid) < 1e-6 && fabs(dHeiOld - dHei) < 1e-6)
|
|
return true;
|
|
else return false;
|
|
}
|
|
|
|
|
|
|
|
int DrawWall(CDrawWallDlg *pDlg)
|
|
{
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
int nOldOsMode=nOsMode;
|
|
nOsMode |= 0x4000;
|
|
if (pDlg)
|
|
{
|
|
if (pDlg->g_bAutoSnap)
|
|
xg_setvar(_T("OSMODE"), nOsMode);
|
|
pDlg->EnableSendChar(FALSE);
|
|
}
|
|
else
|
|
xg_setvar(_T("OSMODE"), nOsMode);
|
|
|
|
XPoint ptStart;
|
|
int nStCode;
|
|
int nWallShape=0;
|
|
|
|
CString sT20Mat;//t20 材料
|
|
TDbWall::Catalog nCatalog;//t20 墙用途
|
|
//add by xlc on 100520 优化算法
|
|
BeginModelRecordZone();
|
|
while(1)
|
|
{
|
|
// Zyu modify on 100621
|
|
int iIndex = 0;
|
|
// 增加一个“`”关键字
|
|
//nStCode=OsGetPointWall(NULL, _T("\n起点或 [参考点(R)]<退出>: "), ptStart, _T("R"));
|
|
nStCode=OsGetPointWall(NULL, _T("\n起点或 [参考点(R)]<退出>: "), ptStart, _T("` R"), &iIndex);
|
|
if (nStCode!=RTNORM && nStCode!=RTKWORD)
|
|
break;
|
|
if (nStCode==RTKWORD)
|
|
{
|
|
// Zyu modify on 100621
|
|
// 增加对“`”关键字的判断
|
|
// Begin
|
|
/*
|
|
XPoint ptRef;
|
|
if(ads_getpoint(NULL, _T("\n参考点<退出>:"), ptRef)!=RTNORM ||
|
|
ads_getpoint(ptRef, _T("\n起点<退出>:"), ptStart)!=RTNORM)
|
|
break;
|
|
ptStart=Ucs2Wcs(ptStart);
|
|
*/
|
|
switch (iIndex)
|
|
{
|
|
case 1:
|
|
{
|
|
pDlg->PickToUpdate();
|
|
continue;
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
int iRetCode = RTNORM;
|
|
XPoint ptRef;
|
|
do
|
|
{
|
|
INITGET_BEG(0, _T("` "));
|
|
iRetCode = ads_getpoint(NULL, _T("\n参考点<退出>:"), ptRef);
|
|
INITGET_END();
|
|
|
|
if (RTKWORD == iRetCode)
|
|
{
|
|
pDlg->PickToUpdate();
|
|
}
|
|
} while (RTKWORD == iRetCode);
|
|
|
|
if (RTNORM != iRetCode)
|
|
{
|
|
break;
|
|
}
|
|
|
|
do
|
|
{
|
|
INITGET_BEG(0, _T("` "));
|
|
iRetCode = ads_getpoint(ptRef, _T("\n起点<退出>:"), ptStart);
|
|
INITGET_END();
|
|
|
|
if (RTKWORD == iRetCode)
|
|
{
|
|
pDlg->PickToUpdate();
|
|
}
|
|
} while (RTKWORD == iRetCode);
|
|
|
|
if (RTNORM != iRetCode)
|
|
{
|
|
break;
|
|
}
|
|
|
|
ptStart=Ucs2Wcs(ptStart);
|
|
}
|
|
break;
|
|
}
|
|
// End
|
|
}
|
|
|
|
BOOL bDiscontinue=FALSE;
|
|
XPointList aStack;
|
|
aStack.Append(new XPoint(ptStart));
|
|
while(!bDiscontinue)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->UpdateData(TRUE);
|
|
DocSetLWallWidth(pDlg->GetLeftWidth());
|
|
DocSetRWallWidth(pDlg->GetRightWidth());
|
|
nWallShape=pDlg->g_nWallShape;
|
|
}
|
|
|
|
double nElev=ptStart.z;
|
|
if (nWallShape==0)
|
|
{ //直墙
|
|
// 连续绘制, 单线墙或者基线定位的双线墙
|
|
ptStart.z = nElev;
|
|
XPoint pt2;
|
|
// Zyu modify on 100624
|
|
// 增加一个“`”关键字
|
|
//const TCHAR *szKeywords=_T("A R C U");
|
|
const TCHAR *szKeywords=_T("A R C U `");
|
|
XPoint &ptFrom=*aStack.Tail();
|
|
int nKwordIndex=0;
|
|
int rc=0;
|
|
if (pDlg)
|
|
pDlg->EnableSendChar(TRUE); //可以发送热键
|
|
rc=DragDrawLine(pDlg, ptFrom, _T("\n直墙下一点或 [弧墙(A)/矩形画墙(R)/闭合(C)/回退(U)]<另一段>: "), pt2, szKeywords, &nKwordIndex, &bDiscontinue);
|
|
if (pDlg) {
|
|
pDlg->UpdateData(TRUE);
|
|
pDlg->SaveSettings();
|
|
DocSetLWallWidth(pDlg->GetLeftWidth());
|
|
DocSetRWallWidth(pDlg->GetRightWidth());
|
|
}
|
|
|
|
if (rc!=RTKWORD && rc!=RTNORM) break;
|
|
if (rc==RTNORM)
|
|
{
|
|
pt2.z = ptStart.z;
|
|
XCurveSegment cv(*aStack.Tail(), pt2, 0.0, LS_FINITE);
|
|
if (cv.GetLength()>_DIST_SNAP) {
|
|
ads_command(RTSTR, _T("UNDO"), RTSTR, _T("MARK"), RTNONE);
|
|
if (DoubleWall(cv, pDlg? pDlg->GetHeight():DocGetLHeight(),pDlg?pDlg->GetElev():0,
|
|
pDlg?pDlg->GetUsage(nCatalog):TWallData::kNormal,
|
|
pDlg?pDlg->GetStyle(sT20Mat):TWallData::kBrick, sT20Mat,nCatalog)==RTNORM)
|
|
{
|
|
// Remove 2 line in order to improve speed
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
aStack.Append(new XPoint(pt2));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nKwordIndex==1)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=1;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=1;
|
|
continue;
|
|
}
|
|
else if (nKwordIndex==2)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=2;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=2;
|
|
if (aStack.Length()>1)
|
|
break;
|
|
else
|
|
continue;
|
|
}
|
|
else if (nKwordIndex==3 && *aStack.Tail()!=ptStart)
|
|
{
|
|
XCurveSegment cv(*aStack.Tail(), ptStart, 0.0, LS_FINITE);
|
|
if (cv.GetLength()>_DIST_SNAP && DoubleWall(cv, pDlg?pDlg->GetHeight() : DocGetLHeight(), pDlg?pDlg->GetElev():0,
|
|
pDlg?pDlg->GetUsage(nCatalog):TWallData::kNormal,
|
|
pDlg?pDlg->GetStyle(sT20Mat):TWallData::kBrick, sT20Mat,nCatalog)==RTNORM)
|
|
{
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
break;
|
|
}
|
|
}
|
|
else if (nKwordIndex==4)
|
|
{
|
|
if (*aStack.Tail() != ptStart)
|
|
{// Not on first state
|
|
ads_command(RTSTR, _T("UNDO"), RTSTR, _T("BACK"), RTNONE);
|
|
aStack.Remove(aStack.Length()-1);
|
|
}
|
|
}
|
|
// Zyu add on 100624
|
|
// 增加一个“`”关键字的判断
|
|
else if (nKwordIndex == 5)
|
|
{
|
|
pDlg->PickToUpdate();
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
else if (nWallShape==1)
|
|
{ //弧墙
|
|
XPoint ptEnd;
|
|
|
|
//modifu by xlc on 080926
|
|
if (pDlg)
|
|
pDlg->EnableSendChar(TRUE); //可以发送热键
|
|
// Zyu modify on 100624
|
|
// 增加一个“`”关键字
|
|
//const TCHAR *szKeywords=_T("L R");
|
|
const TCHAR *szKeywords=_T("L R `");
|
|
int nKwordIndex=0;
|
|
|
|
int rc=OsGetPointWall(*aStack.Tail(), _T("\n弧墙终点或[直墙(L)/矩形画墙(R)]<取消>:"), ptEnd, szKeywords, &nKwordIndex, &bDiscontinue);
|
|
ptEnd.z=ptStart.z;
|
|
|
|
//if (rc!=RTNORM) break;
|
|
if (rc!=RTNORM && rc!=RTKWORD)
|
|
break;
|
|
else if (rc==RTKWORD)
|
|
{
|
|
if (nKwordIndex==1)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=0;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=0;
|
|
continue;
|
|
}
|
|
else if (nKwordIndex==2)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=2;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=2;
|
|
if (aStack.Length()>1)
|
|
break;
|
|
else
|
|
continue;
|
|
}
|
|
// Zyu add on 100624
|
|
// 增加一个“`”关键字的判断
|
|
else if (nKwordIndex == 3)
|
|
{
|
|
pDlg->PickToUpdate();
|
|
continue;
|
|
}
|
|
}
|
|
|
|
XPushVar<int> orthomode(_T("ORTHOMODE"), 0);
|
|
|
|
if (pDlg)
|
|
pDlg->EnableSendChar(FALSE); //不可以发送热键
|
|
|
|
BOOL bOldRevFlag=g_bRevWallFlag;
|
|
g_bRevWallFlag=FALSE;
|
|
const TCHAR *szPromptAny=_T("\n点取弧上任意点或 [半径(R)]<取消>:");
|
|
XPoint ptAny;
|
|
int nIdxKeyword, nRetCode;
|
|
nRetCode=DragDrawArc_SEP(pDlg, *aStack.Tail(), ptEnd, szPromptAny, ptAny, _T("R"), &nIdxKeyword);
|
|
if (nRetCode!=RTNORM && nRetCode!=RTKWORD)
|
|
break;
|
|
|
|
XCurveSegment cv;
|
|
if (nRetCode==RTKWORD)
|
|
{ //两点半径
|
|
static double nRadius=5000.0;
|
|
nRetCode=DragDrawArc_SER(pDlg, *aStack.Tail(), ptEnd, XString(_T("\n半径<%.f>:"), nRadius), &nRadius, NULL, NULL);
|
|
if (nRetCode!=RTCAN)
|
|
{
|
|
double nChordLen=ads_distance(*aStack.Tail(), ptEnd);
|
|
if (nChordLen<2.0*nRadius+1.0E-6)
|
|
{
|
|
double bulge=2.0*asin(nChordLen/2.0/nRadius);
|
|
cv=XCurveSegment(*aStack.Tail(), ptEnd, bulge, LS_FINITE);
|
|
nRetCode=RTNORM;
|
|
}
|
|
else
|
|
{
|
|
adsout << _T("半径值太小!");
|
|
nRetCode=RTERROR;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{ //三点
|
|
cv=XArc(*aStack.Tail(), ptAny, ptEnd);
|
|
if (cv.EndPoint().Distance2d(ptEnd)>_DIST_SNAP)
|
|
g_bRevWallFlag=TRUE;
|
|
}
|
|
if (nRetCode==RTNORM || nRetCode==RTKWORD)
|
|
{
|
|
if (pDlg) {
|
|
pDlg->UpdateData(TRUE);
|
|
pDlg->SaveSettings();
|
|
DocSetLWallWidth(pDlg->GetLeftWidth());
|
|
DocSetRWallWidth(pDlg->GetRightWidth());
|
|
}
|
|
ads_command(RTSTR, _T("UNDO"), RTSTR, _T("MARK"), RTNONE);
|
|
DoubleWall(cv, pDlg? pDlg->GetHeight():DocGetLHeight(),pDlg?pDlg->GetElev():0,
|
|
pDlg?pDlg->GetUsage(nCatalog):TWallData::kNormal,
|
|
pDlg?pDlg->GetStyle(sT20Mat):TWallData::kBrick,sT20Mat,nCatalog,
|
|
g_bRevWallFlag);
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
aStack.Append(new XPoint(ptEnd));
|
|
g_bRevWallFlag=bOldRevFlag;
|
|
}
|
|
else
|
|
{
|
|
g_bRevWallFlag=bOldRevFlag;
|
|
break;
|
|
}
|
|
if (pDlg)
|
|
{
|
|
//pDlg->g_nWallShape=0;// [4/1/2008 nsh]
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
{
|
|
nWallShape=0;
|
|
}
|
|
|
|
}
|
|
else if (nWallShape==2)
|
|
{ //矩形墙
|
|
XPoint ptEnd;
|
|
// Zyu modify on 100624
|
|
// 增加一个“`”关键字
|
|
//const TCHAR *szKeywords=_T("L A");
|
|
const TCHAR *szKeywords=_T("L A `");
|
|
int nKwordIndex=0, rc=0;
|
|
if (pDlg)
|
|
pDlg->EnableSendChar(TRUE); //可以发送热键
|
|
|
|
rc=OsGetCornerWall(ptStart, _T("\n另一个角点或 [直墙(L)/弧墙(A)]<取消>:"), ptEnd, szKeywords, &nKwordIndex);
|
|
ptEnd.z=ptStart.z;
|
|
|
|
if (rc!=RTNORM && rc!=RTKWORD)
|
|
return rc;
|
|
if (rc==RTNORM)
|
|
{
|
|
XRectAngle box(Wcs2Ucs(ptStart), Wcs2Ucs(ptEnd));
|
|
if (pDlg)
|
|
{
|
|
pDlg->UpdateData(TRUE);
|
|
pDlg->SaveSettings();
|
|
DocSetLWallWidth(pDlg->GetLeftWidth());
|
|
DocSetRWallWidth(pDlg->GetRightWidth());
|
|
}
|
|
|
|
TWallData::UsageFlag nUsage=pDlg?pDlg->GetUsage(nCatalog):TWallData::kNormal;
|
|
double nHeight=pDlg? pDlg->GetHeight() : DocGetLHeight();
|
|
double nElev=pDlg?pDlg->GetElev():0;
|
|
TWallData::TWallStyle st=pDlg? (TWallData::TWallStyle)pDlg->GetStyle(sT20Mat) : TWallData::kBrick;
|
|
DoubleWall(XCurveSegment(Ucs2Wcs(box.GetLowLeft()), Ucs2Wcs(box.GetLowRight()), 0.0, LS_FINITE),
|
|
nHeight,nElev,nUsage, st, sT20Mat,nCatalog);
|
|
DoubleWall(XCurveSegment(Ucs2Wcs(box.GetLowRight()), Ucs2Wcs(box.GetUpRight()), 0.0, LS_FINITE),
|
|
nHeight,nElev,nUsage, st, sT20Mat,nCatalog);
|
|
DoubleWall(XCurveSegment(Ucs2Wcs(box.GetUpRight()), Ucs2Wcs(box.GetUpLeft()), 0.0, LS_FINITE),
|
|
nHeight,nElev,nUsage, st, sT20Mat,nCatalog);
|
|
DoubleWall(XCurveSegment(Ucs2Wcs(box.GetUpLeft()), Ucs2Wcs(box.GetLowLeft()), 0.0, LS_FINITE),
|
|
nHeight,nElev,nUsage, st, sT20Mat,nCatalog);
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
bDiscontinue=TRUE;
|
|
}
|
|
else if (nKwordIndex==1)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=0;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=0;
|
|
continue;
|
|
}
|
|
else if (nKwordIndex==2)
|
|
{
|
|
if (pDlg)
|
|
{
|
|
pDlg->g_nWallShape=1;
|
|
pDlg->UpdateData(FALSE);
|
|
}
|
|
else
|
|
nWallShape=1;
|
|
continue;
|
|
}
|
|
// Zyu add on 100624
|
|
// 增加一个“`”关键字的判断
|
|
else if (nKwordIndex == 3)
|
|
{
|
|
pDlg->PickToUpdate();
|
|
continue;
|
|
}
|
|
|
|
}
|
|
}
|
|
if (pDlg)
|
|
pDlg->EnableSendChar(FALSE); //不可以发送热键
|
|
}
|
|
//add by xlc on 100520 优化算法
|
|
EndModelRecordZone();
|
|
acedPostCommandPrompt();
|
|
|
|
xg_setvar(_T("OSMODE"), nOldOsMode);
|
|
ads_command(RTSTR, _T(".REDRAW"), RTNONE);
|
|
return RTNORM;
|
|
}
|
|
|
|
////////////////////////////////////////////////////
|
|
// Command: 双线直墙
|
|
// 靶区半径为较宽的的当前墙厚
|
|
// 捕捉顺序: 墙心线端点,轴线交点,墙心线最近点,轴线最近点
|
|
// 必须在WCS下
|
|
void DrWall()
|
|
{
|
|
XPushVar<int> cmdecho(_T("CMDECHO"), 0);
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDrawWallDlg dlg(pWnd);
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
dlg.Create(dlg.IDD, pWnd);
|
|
}
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
int nOldOsnap=g_nOsnapType;
|
|
DocSetWallOsnapType(0);
|
|
DrawWall(&dlg);
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
if (::IsWindow(dlg.m_hWnd))
|
|
dlg.DestroyWindow();
|
|
|
|
TArchCmdReactor::ResetAll();
|
|
}
|
|
/////////////////////////////////////////////
|
|
// Command: 显示外墙
|
|
void HLExtWall()
|
|
{
|
|
XScreenDc dc(1, 1);
|
|
PickSet ss(SS_FREE);
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
if (ss.Get(_T("X"), NULL, NULL, mask)==RTNORM) {
|
|
long lCount=ss.Length();
|
|
for (long i=0L; i<lCount; i++) {
|
|
Entity ent=ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
if (pWall) {
|
|
XCurveSegment cvLeft, cvRight;
|
|
if (pWall->IsExternal(OFFSET_LEFT)) {
|
|
pWall->GetSideCurve(cvLeft, cvRight);
|
|
cvLeft.StartPoint()=Wcs2Ucs(cvLeft.StartPoint());
|
|
cvLeft.EndPoint()=Wcs2Ucs(cvLeft.EndPoint());
|
|
dc << cvLeft;
|
|
} else if (pWall->IsExternal(OFFSET_RIGHT)) {
|
|
pWall->GetSideCurve(cvLeft, cvRight);
|
|
cvRight.StartPoint()=Wcs2Ucs(cvRight.StartPoint());
|
|
cvRight.EndPoint()=Wcs2Ucs(cvRight.EndPoint());
|
|
dc << cvRight;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////
|
|
// command: 改外墙厚
|
|
void ChExtWallThick()
|
|
{
|
|
PickSet ss(SS_FREE);
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), 73, 1, NULL);
|
|
if (SelectEntities(_T("\n请选择外墙:"), ss, mask)!=RTNORM)
|
|
return;
|
|
|
|
static ads_real nExtWidth=240;
|
|
static ads_real nIntWidth=120;
|
|
int nRet1, nRet2;
|
|
|
|
//modify by xlc on 070514
|
|
//允许输入 负值和0
|
|
//if (((nRet1=GetReal(_T("\n内侧宽"), nIntWidth, RSG_NONEG|RSG_NOZERO))!=RTCAN)
|
|
//&& ((nRet2=GetReal(_T("\n外侧宽"), nExtWidth, RSG_NONEG|RSG_NOZERO))!=RTCAN) ) {
|
|
if (((nRet1=GetReal(_T("\n内侧宽"), nIntWidth/*, RSG_NONEG|RSG_NOZERO*/))!=RTCAN)
|
|
&& ((nRet2=GetReal(_T("\n外侧宽"), nExtWidth/*, RSG_NONEG|RSG_NOZERO*/))!=RTCAN) ) {
|
|
|
|
long lCount=ss.Length();
|
|
for (long n=0L;n<lCount; n++) {
|
|
Entity ent=ss[n];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pDbWall);
|
|
if (pDbWall) {
|
|
pDbWall->assertWriteEnabled();
|
|
BOOL bLeftExt=pDbWall->IsExternal(OFFSET_LEFT);
|
|
pDbWall->SetWidth(0, bLeftExt? nExtWidth:nIntWidth);
|
|
pDbWall->SetWidth(1, bLeftExt? nIntWidth:nExtWidth);
|
|
pDbWall->RelocateOpening();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
// Command: 改墙柱子高
|
|
// 修改历史:
|
|
// 1998.3.9 Falchion 无条件改高度,更新墙体
|
|
// 必须在WCS下
|
|
void ChHeight()
|
|
{
|
|
//AsureWCS();
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL,TCH_COLUMN,TCH_WALL_PATCH"), NULL);
|
|
int nRetCode=SelectEntities(_T("\n请选择墙体、柱子或墙体造型:"), ssWalls, rbMask);
|
|
if (nRetCode==RTNORM && ssWalls.Length()>0) {
|
|
ads_real nHeight=CFG_LHeight;
|
|
ads_real nElev=0.0;
|
|
{ //取缺省高度和标高
|
|
Entity entWall=ssWalls[0L];
|
|
XDbObject obj(entWall, AcDb::kForRead);
|
|
ASSERT(!!obj);
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
TDbColumn *pColu = TDbColumn::cast(obj.m_pObject);
|
|
TDbWallPatch *pPatch=TDbWallPatch::cast(obj.m_pObject);
|
|
if (pWall) {
|
|
nHeight=pWall->GetHeight();
|
|
nElev=pWall->GetElevation();
|
|
} else if (pColu) {
|
|
nHeight=pColu->GetHeight();
|
|
nElev=pColu->GetElevation();
|
|
} else if (pPatch) {
|
|
nHeight=pPatch->GetHeight();
|
|
nElev=pPatch->GetElevation();
|
|
}
|
|
}
|
|
if (GetDist(_T("\n新的高度"), nHeight, RSG_NONEG|RSG_NOZERO)==RTCAN)
|
|
return ;
|
|
if (GetDist(_T("\n新的标高"), nElev, 0)==RTCAN)
|
|
return ;
|
|
|
|
PickSet ssWallOnly(SS_FREE);
|
|
ssWallOnly += ssWalls;
|
|
ssWallOnly.BaseFilter(RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL));
|
|
int nAnswer=Q_NO;
|
|
if (ssWallOnly.Length()>0) {
|
|
nAnswer=YesNoQuestion(_T("\n是否维持窗墙底部间距不变"), nAnswer);
|
|
if (nAnswer==RTCAN)
|
|
return;
|
|
}
|
|
|
|
long nLen=ssWalls.Length();
|
|
for (long n=0; n<nLen; n++) {
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
TDbColumn *pColu = TDbColumn::cast(obj.m_pObject);
|
|
TDbWallPatch *pPatch=TDbWallPatch::cast(obj.m_pObject);
|
|
if (pWall) {
|
|
pWall->assertWriteEnabled();
|
|
pWall->ChangeElevation(nElev, nAnswer==Q_YES);
|
|
pWall->SetHeight(nHeight);
|
|
} else if (pColu) {
|
|
pColu->assertWriteEnabled();
|
|
pColu->SetElevation(nElev);
|
|
pColu->SetHeight(nHeight);
|
|
}else if (pPatch) {
|
|
pPatch->assertWriteEnabled();
|
|
pPatch->SetElevation(nElev);
|
|
pPatch->SetHeight(nHeight);
|
|
}
|
|
}
|
|
}
|
|
TArchCmdReactor::ResetAll(); //加快处理速度
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////
|
|
// Command: 改墙厚
|
|
// 修改历史:
|
|
// 1998.3.9 Falchion 无条件改高度,更新墙体
|
|
// 必须在WCS下
|
|
void ChWallThick()
|
|
{
|
|
//AsureWCS();
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
|
|
if (SelectEntities(_T("\n选择墙体: "), ssWalls, rbMask)==RTNORM) {
|
|
ads_real nWidth=240;
|
|
{ //取缺省宽度
|
|
Entity entWall=ssWalls[0L];
|
|
XDbObject obj(entWall, AcDb::kForRead);
|
|
assert(!!obj);
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
assert(pWall);
|
|
nWidth=pWall->GetWidth();
|
|
}
|
|
if (GetDist(_T("\n新的墙宽"), nWidth, RSG_NONEG|RSG_NOZERO)==RTCAN)
|
|
return ;
|
|
long nLen=ssWalls.Length();
|
|
for (long n=0; n<nLen; n++) {
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
assert(pWall);
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetWidth(0, nWidth/2.0);
|
|
pWall->SetWidth(1, nWidth/2.0);
|
|
pWall->RelocateOpening();
|
|
}
|
|
}
|
|
TArchCmdReactor::UpdateCorners();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// 取得墙体打断的合适位置(搜索轴线交点)
|
|
int GetWallBreakPoint(const XCurveSegment &segWall, const XPoint &ptLow, const XPoint &ptUp, XPoint &ptRes)
|
|
{
|
|
RBList rbMask=ads_buildlist(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, LAY_AXIS, NULL);
|
|
PickSet ssAxis(SS_FREE);
|
|
if (ssAxis.Get(_T("C"), ptLow, ptUp, rbMask)==RTNORM) {
|
|
long len=ssAxis.Length();
|
|
if (len==1) {
|
|
Entity eAxis=ssAxis[0L];
|
|
XCurveSegment cv(eAxis, LS_FINITE);
|
|
XCurveSegment cvWall=segWall;
|
|
cvWall.SetLineFlag(LS_FINITE);
|
|
int nIntNum = cvWall.Intersection(cv, ptRes, XPoint());
|
|
if (nIntNum>=1)
|
|
return RTNORM;
|
|
} else if (len>1){
|
|
Entity eAxis1=ssAxis[0L];
|
|
Entity eAxis2=ssAxis[1L];
|
|
XCurveSegment cv1(eAxis1, LS_FINITE), cv2(eAxis2, LS_FINITE);
|
|
int nIntNum = cv1.Intersection(cv2, ptRes, XPoint());
|
|
if (nIntNum>=1)
|
|
return RTNORM;
|
|
}
|
|
}
|
|
return RTERROR;
|
|
}
|
|
|
|
|
|
// 以一曲线画双线墙
|
|
// nwk--墙体类型
|
|
// 中途经过的墙体将被截断,经过柱子时自己将被裁断
|
|
// Edit 1999.1.4 加入窗口过滤
|
|
// Update New: 1999.1.22 对柱子断墙进行判断
|
|
int DoubleWall(XCurveSegment curve, double nHeight, double nElev,TWallData::UsageFlag nUsage, TWallData::TWallStyle style,CString sT20Mat,TDbWall::Catalog nCatalog, BOOL bRev)
|
|
{
|
|
curve.SetElevation(nElev);
|
|
if (curve.GetLength()<g_nMinLenWall)
|
|
return RTERROR;
|
|
ASSERT(curve.GetLength()>_DIST_SNAP);
|
|
|
|
|
|
XPoint ptMin, ptMax;
|
|
curve.GetExtend(ptMin, ptMax);
|
|
ptMin.x -= _AS_SYS_UNIT(g_nDistPrec); ptMin.y -= _AS_SYS_UNIT(g_nDistPrec);
|
|
ptMax.x += _AS_SYS_UNIT(g_nDistPrec); ptMax.y += _AS_SYS_UNIT(g_nDistPrec);
|
|
double topElev=curve.StartPoint().z+nHeight;
|
|
double botElev=curve.StartPoint().z;
|
|
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
PickSet ssCrossWalls(SS_FREE|SS_CREATE), ssAllWalls(SS_FREE);
|
|
XSortedVertexList lstVertexes(curve.StartPoint(), curve.EndPoint(), curve.GetBulge());
|
|
// 判断穿过的柱子
|
|
PickSet ssColu(SS_FREE);
|
|
GetSafeSelection(ssColu, 1, ptMin, ptMax, _T("TCH_COLUMN"));
|
|
|
|
if (GetSafeSelection(ssAllWalls, 1, ptMin, ptMax, _T("TCH_WALL,TCH_CURTAIN_WALL"))==Acad::eOk)
|
|
{
|
|
long ssLen=ssAllWalls.Length();
|
|
//事先判断能否穿越墙体
|
|
|
|
TGGePoly2D tmpPoly;
|
|
XCurveSegment tmpCurve(curve);
|
|
tmpCurve.SetElevation(.0);
|
|
TADSGePoint3d ptS = tmpCurve.GetStartPoint(), ptE = tmpCurve.GetEndPoint();
|
|
TADSGePointDir2d ptMid;
|
|
tmpCurve.Polar(tmpCurve.GetLength()*.5, ptMid);
|
|
|
|
for (long i=0; i<ssLen; i++)
|
|
{
|
|
Entity ent=ssAllWalls[i];
|
|
XDbObject obj(ent, AcDb::kForRead);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (!pWall) continue;
|
|
|
|
// pWall->GetOutlinePoly1(ptS.z, tmpPoly, TRUE);
|
|
// if ((ptS&tmpPoly) == PR_INSIDE && (ptE&tmpPoly) == PR_INSIDE && (ptMid&tmpPoly) == PR_INSIDE)
|
|
// {
|
|
// double topElev1=pWall->GetElevation()+pWall->GetHeight();
|
|
// double botElev1=pWall->GetElevation();
|
|
// // 判断点是否在曲线内的方法,无法判断Z值,所以,在这里判断一下标高。
|
|
// // 即Z轴上不重合的两个墙,可以绘制。
|
|
// if ((botElev-topElev1)>-1E-6|| (topElev-botElev1)<1E-6 ) { }
|
|
// else
|
|
// {
|
|
// // 标高重合,两点还在已有墙内,则为重合墙。
|
|
// adsout << _T("\n不能与已有墙重叠!");
|
|
// return RTERROR;
|
|
// }
|
|
// }
|
|
|
|
int nPos=pWall->PosRelationWith(curve);
|
|
if (nPos==1) //相交不穿越门窗
|
|
ssCrossWalls += ent;
|
|
else if (nPos==2)
|
|
{//穿越门窗
|
|
adsout << _T("\n墙体不能穿越已经存在的门窗!");
|
|
return RTERROR;
|
|
}
|
|
else if (nPos==3)
|
|
{ //重合
|
|
double topElev1=pWall->GetElevation()+pWall->GetHeight();
|
|
double botElev1=pWall->GetElevation();
|
|
if ((botElev-topElev1)>-1E-6||
|
|
(topElev-botElev1)<1E-6||
|
|
(botElev-topElev1)>-1E-6||
|
|
(topElev-botElev1)<1E-6)
|
|
continue;
|
|
else
|
|
{
|
|
adsout << _T("\n不能与已有墙重叠!");
|
|
return RTERROR;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 截断墙体
|
|
ssLen = ssCrossWalls.Length();
|
|
for (i=0L; i<ssLen; i++) {
|
|
Entity ent=ssCrossWalls[i];
|
|
XDbObject obj(ent, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (!pWall) continue;
|
|
|
|
// 把已有的墙体截断
|
|
XPoint ptInters[2];
|
|
int nInterNum=pWall->Divide(curve, ptInters[0], ptInters[1], ssColu);
|
|
for (int n=0; n<nInterNum; n++) {
|
|
int nPrFlag=(ptInters[n]&curve);
|
|
if (nPrFlag==PR_INSIDE) {
|
|
XPoint ptTerm=ptInters[n];
|
|
ptTerm.z = curve.StartPoint().z;
|
|
lstVertexes.Insert(ptTerm);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
long lCount = ssColu.Length();
|
|
for (long i=0; i<lCount; i++) {
|
|
Entity ent=ssColu[i];
|
|
XDbObject obj(ent, AcDb::kForRead);
|
|
if (!obj) continue;
|
|
TDbColumn *pColu=TDbColumn::cast(obj.m_pObject);
|
|
if (!pColu) continue;
|
|
XPoint ptTemp=pColu->m_ptLocation;
|
|
XPoint ptLow, ptUp;
|
|
pColu->GetExtents2d(ptLow, ptUp);
|
|
XPoly2D polyColu(1);
|
|
pColu->GetOutline(polyColu);
|
|
obj.Close();
|
|
|
|
// 必须两端点都在柱子外, 才可以裁剪
|
|
if ((curve.StartPoint()&polyColu)!=PR_OUTSIDE ||
|
|
(curve.EndPoint()&polyColu)!=PR_OUTSIDE )
|
|
continue;
|
|
|
|
GetWallBreakPoint(curve, ptLow, ptUp, ptTemp); //找耙区内的轴线交点
|
|
XPoint ptOnCurve;
|
|
if (curve.ProjectToMe(ptTemp, ptOnCurve)!=RTNORM)
|
|
continue;
|
|
ptTemp.z=ptOnCurve.z;
|
|
if (ads_distance(ptOnCurve, ptTemp) > max((ptUp.x-ptLow.x), (ptUp.y-ptLow.y)))
|
|
continue;
|
|
if ((ptOnCurve & curve) == PR_INSIDE)
|
|
lstVertexes.Insert(ptOnCurve);
|
|
}
|
|
}
|
|
|
|
|
|
//if (esZoom==Acad::eOk)
|
|
// arxZoom(lowViewCorner, upViewCorner); //Restore view
|
|
|
|
|
|
XPoly2D poly(0);
|
|
lstVertexes.AsPoly2D(poly);
|
|
for (int j=0; j<poly.TotalSegments(); j++) {
|
|
XCurveSegment cv;
|
|
poly.Nth(j, cv);
|
|
if (!cv || cv.GetLength()<g_nMinLenWall) continue;
|
|
|
|
//TDbWall *pWall = new TDbWall(cv.StartPoint(), cv.EndPoint(), cv.GetBulge());
|
|
TDbWall *pWall=NULL;
|
|
pWall=style!=TWallData::kCurtain?(TDbWall *)TDbWall::desc()->create():(TDbWall*)TDbCurtainWall::desc()->create();
|
|
if (pWall==NULL)
|
|
continue;
|
|
|
|
(XCurveSegment &)(*pWall) = cv;
|
|
pWall->SetUsageFlag(nUsage);
|
|
pWall->SetCatalog(nCatalog);
|
|
|
|
pWall->SetStyle(style);
|
|
pWall->SetT20WallMat(sT20Mat);
|
|
|
|
pWall->SetHeight(nHeight);
|
|
pWall->SetLayerHatch2d(InitLayer(LAY_HATCH, FALSE));
|
|
|
|
if (pWall->isKindOf(TDbCurtainWall::desc()))
|
|
{
|
|
TDbCurtainWall* pCWall=(TDbCurtainWall*)pWall;
|
|
pCWall->SetLayerGlass3d(InitLayer(LAY_3DGLASS));
|
|
pCWall->SetLayerCol3d(InitLayer(LAY_3DFRAME));
|
|
pCWall->SetLayerRow3d(InitLayer(LAY_3DFRAME));
|
|
|
|
// add by xly on 101103 绘制的墙体是玻璃幕墙的时候记录玻璃幕墙的竖挺界面为墙体的左宽和右宽之和
|
|
double dColV = g_lWallWidth+g_rWallWidth;
|
|
pCWall->SetColV(dColV);
|
|
|
|
}
|
|
|
|
if (nUsage==TWallData::kVirtual)
|
|
{
|
|
pWall->SetWidth(0, 0.0);
|
|
pWall->SetWidth(1, 0.0);
|
|
} else
|
|
{
|
|
pWall->SetWidth(bRev? 1 : 0, g_lWallWidth);
|
|
pWall->SetWidth(bRev? 0 : 1, g_rWallWidth);
|
|
}
|
|
pWall->AddToMSpace(Adesk::kTrue);
|
|
}
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
// Command: 定制墙的形状
|
|
void ShapeWall()
|
|
{
|
|
RBList maskPoly(RTDXF0, _T("POLYLINE,LWPOLYLINE"), 70, 0, NULL);
|
|
Entity entPoly;
|
|
g_ssPickFirst.Free();
|
|
if (SelectEntity(_T("\n选择定制墙立面的形状的不闭合多段线<退出>: "),
|
|
entPoly, XPoint(), maskPoly)!=RTNORM)
|
|
return;
|
|
XPoly2D polySrc(entPoly);
|
|
if (polySrc.IsClosed()) {
|
|
return;
|
|
}
|
|
polySrc.XPointList::TransUCS((resbuf *)&Groups(entPoly), (resbuf *)&Groups(0));
|
|
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList mask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
if (SelectEntities(_T("\n选择墙体:"), ssWalls, mask)==RTNORM) {
|
|
long lCount=ssWalls.Length();
|
|
for (long i=0; i<lCount; i++) {
|
|
Entity ent=ssWalls[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall && pWall->Is(CURVE_LINE)) {
|
|
ads_matrix matTo2d;
|
|
pWall->GetPlanarMatrix(matTo2d);
|
|
XPoly2D polyShape(1);
|
|
polyShape=polySrc;
|
|
polyShape.XPointList::TransUCS(matTo2d);
|
|
XVector3D vtNormal, vtRightSide;
|
|
entPoly.GetData(210, &vtNormal);
|
|
XPoint pt3=pWall->StartPoint();
|
|
pt3.z += 1000;
|
|
if (CT_vector_plan3p(pWall->StartPoint(), pWall->EndPoint(), pt3, vtRightSide)) {
|
|
if (vtNormal.AsAcGeVector3d().angleTo(vtRightSide)>_angSnap) {
|
|
for (int n=0; n<polyShape.Length(); n++) {
|
|
// [2010-3-16 10:13 wubo] 移植到新Geo库
|
|
// polyShape.bulges[n] *= -1.0;
|
|
polyShape.SetBulge(n, polyShape.GetBulge(n) * -1.0);
|
|
}
|
|
}
|
|
}
|
|
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetPolyShape(polyShape);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Command: 取消墙体的立面定制形状
|
|
void DelWallShape()
|
|
{
|
|
RBList mask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
PickSet ss(SS_FREE);
|
|
if (SelectEntities(_T("\n选择墙体: "), ss, mask)==RTNORM) {
|
|
long lCount=ss.Length();
|
|
for (long i=0L; i<lCount; i++) {
|
|
Entity ent=ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetPolyShape(XPoly2D());
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////
|
|
// 加保温或取消保温
|
|
void AddOrRemoveInsulate(BOOL bTrue)
|
|
{
|
|
//AsureWCS();
|
|
static double nInsThick=80.0;
|
|
while(1) {
|
|
Entity entWall;
|
|
XPoint ptPick;
|
|
adsout << _T("\n指定墙体保温的一侧或 {外墙内侧[I]/外墙外侧[E]/保温层厚(当前=")
|
|
<< AS_INT(nInsThick) << _T(")[T]}<退出>:");
|
|
int nRetCode=RTNORM;
|
|
INITGET_BEG(0, _T("I E T"));
|
|
nRetCode=entWall.FilterSelect1(100.0, _T(""), RBList(RTDXF0, _T("TCH_WALL"), NULL), ptPick);
|
|
INITGET_END();
|
|
if (nRetCode!=RTNORM && nRetCode!=RTKWORD)
|
|
return;
|
|
|
|
if (nRetCode==RTKWORD) {
|
|
XString sInput;
|
|
ads_getinput(sInput);
|
|
if (!sInput)
|
|
return;
|
|
if (sInput[0]==_T('T')) {
|
|
if (GetReal(_T("\n保温层厚"), nInsThick, RSG_NONEG|RSG_NOZERO)==RTCAN)
|
|
return;
|
|
continue;
|
|
}
|
|
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList wallMask(RTDXF0, _T("TCH_WALL"), 73, 1, NULL);
|
|
g_ssPickFirst.Free();
|
|
//\n选择构成一独立建筑物的所有墙体!;
|
|
if (SelectEntities(_T("\n选择外墙:"), ssWalls, wallMask)!=RTNORM)
|
|
return;
|
|
long nWallNum=ssWalls.Length();
|
|
for (long n=0L; n<nWallNum; n++) {
|
|
Entity e=ssWalls[n];
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWall, pDbWall);
|
|
if (pDbWall) {
|
|
AcDbObjectId idSurf=pDbWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pDbWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
if (pDbWall->IsExternal(OFFSET_LEFT)) {
|
|
pDbWall->assertWriteEnabled();
|
|
pDbWall->SetInsulateThick(nInsThick);
|
|
pDbWall->SetInsulateOnSide(sInput==_T("I")? OFFSET_RIGHT:OFFSET_LEFT, bTrue);
|
|
pDbWall->RelocateOpening();
|
|
} else if (pDbWall->IsExternal(OFFSET_RIGHT)) {
|
|
pDbWall->assertWriteEnabled();
|
|
pDbWall->SetInsulateThick(nInsThick);
|
|
pDbWall->SetInsulateOnSide(sInput==_T("I")? OFFSET_LEFT:OFFSET_RIGHT, bTrue);
|
|
pDbWall->RelocateOpening();
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
break;
|
|
|
|
} else {
|
|
ptPick=Ucs2Wcs(ptPick);
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
XCurveSegment seg=pWall->OffsetGeomCenter();
|
|
int nSide=seg.OnWhichSide(ptPick);
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetInsulateThick(nInsThick);
|
|
pWall->SetInsulateOnSide(nSide, bTrue);
|
|
pWall->RelocateOpening();
|
|
pWall->close();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
//// Command: 加保温
|
|
//void AddInsulate()
|
|
//{
|
|
// AddOrRemoveInsulate(TRUE);
|
|
//}
|
|
// Modify by lcf on 20050728
|
|
// Command: 加保温或取消保温
|
|
void AddInsulate()
|
|
{
|
|
extern TARCH_IMPEXP double g_nInsulateThick;
|
|
static double nInsThick = (int)g_nInsulateThick;
|
|
|
|
// sg add 100715,根据8.5需求,该命令改为“墙柱保温”,支持选择“墙体造型”和“柱子”
|
|
RBList entSelMask(RTDXF0, _T("TCH_WALL,TCH_COLUMN,TCH_WALL_PATCH"), NULL);
|
|
|
|
while(1)
|
|
{
|
|
Entity entWall;
|
|
XPoint ptPick;
|
|
// Zyu Modify on 100430,增加柱子保温,修改原来的提示
|
|
// adsout << _T("\n指定墙体保温的一侧或 [外墙内侧(I)/外墙外侧(E)/消保温层(D)/保温层厚(当前=")
|
|
adsout << _T("\n指定墙、柱、墙体造型保温一侧或 [内保温(I)/外保温(E)/消保温层(D)/保温层厚(当前=")
|
|
<< AS_INT(nInsThick) << _T(")(T)]<退出>:");
|
|
|
|
int nRetCode = RTNORM;
|
|
INITGET_BEG(0, _T("D I E T"));
|
|
// sg modify 100715,根据8.5需求,该命令改为“墙柱保温”,支持选择“墙体造型”和“柱子”
|
|
// nRetCode = entWall.FilterSelect1(100.0, _T(""), RBList(RTDXF0, _T("TCH_WALL"), NULL), ptPick);
|
|
nRetCode = entWall.FilterSelect1(100.0, _T(""), entSelMask, ptPick);
|
|
INITGET_END();
|
|
if (nRetCode != RTNORM && nRetCode != RTKWORD)
|
|
return;
|
|
|
|
if (nRetCode == RTKWORD) // 出现关键字
|
|
{
|
|
XString sInput;
|
|
ads_getinput(sInput);
|
|
if (!sInput)
|
|
return;
|
|
|
|
if (sInput[0] == _T('T')) // 保温层厚
|
|
{
|
|
// sg add 110623,临时调整数据,主要为了显示正确
|
|
//nInsThick /= 1.001;
|
|
if (GetReal(_T("\n保温层厚"), nInsThick, RSG_NONEG|RSG_NOZERO) == RTCAN)
|
|
return;
|
|
|
|
// sg add 110623,临时调整数据,主要为了显示正确
|
|
//nInsThick *= 1.001;
|
|
continue;
|
|
}
|
|
else if (sInput[0] == _T('D')) // Add by lcf on 20050728,消保温层
|
|
{
|
|
// RBList wallMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
|
|
PickSet ssWalls(SS_FREE);
|
|
// sg modify 100715,根据8.5需求,该命令改为“墙柱保温”,支持选择“墙体造型”和“柱子”
|
|
// if (SelectEntities(_T("\n选择墙体:"), ssWalls, wallMask) != RTNORM)
|
|
if (SelectEntities(_T("\n选择墙、柱、墙体造型:"), ssWalls, entSelMask) != RTNORM)
|
|
return;
|
|
|
|
long nWallNum = ssWalls.Length();
|
|
for (long n=0L; n<nWallNum; n++)
|
|
{
|
|
Entity e = ssWalls[n];
|
|
// sg modify 100715,根据8.5需求,该命令改为“墙柱保温”,支持选择“墙体造型”和“柱子”
|
|
if (e.Is(_T("TCH_WALL"))) // 墙体
|
|
{
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall != NULL)
|
|
{
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetInsulateOnSide(OFFSET_LEFT, FALSE);
|
|
pWall->SetInsulateOnSide(OFFSET_RIGHT, FALSE);
|
|
pWall->RelocateOpening();
|
|
pWall->close();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
else if (e.Is(_T("TCH_COLUMN"))) // 柱子
|
|
{
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbColumn, pColumn);
|
|
if (pColumn != NULL)
|
|
{
|
|
pColumn->assertWriteEnabled();
|
|
pColumn->SetInsulateOnColumn(false);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
else if (e.Is(_T("TCH_WALL_PATCH"))) // 墙体造型
|
|
{
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWallPatch, pWallPatch);
|
|
if (pWallPatch != NULL)
|
|
{
|
|
pWallPatch->assertWriteEnabled();
|
|
pWallPatch->SetInsulate(FALSE);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
else // 内保温、外保温
|
|
{
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList wallMask(RTDXF0, _T("TCH_WALL"), 73, 1, NULL);
|
|
g_ssPickFirst.Free();
|
|
// \n选择构成一独立建筑物的所有墙体!;
|
|
if (SelectEntities(_T("\n选择外墙:"), ssWalls, wallMask)!=RTNORM)
|
|
return;
|
|
|
|
// sg add 110128,获得与外墙相连接的柱子以及墙体造型的ID
|
|
AcDbObjectIdArray aryColumn, aryWallPatch;
|
|
|
|
long nWallNum = ssWalls.Length();
|
|
for (long n=0L; n<nWallNum; n++)
|
|
{
|
|
Entity e = ssWalls[n];
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWall, pDbWall);
|
|
if (pDbWall != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pDbWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pDbWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
int nSide = OFFSET_LEFT; // 判断墙体需要加保温的侧
|
|
if (pDbWall->IsExternal(OFFSET_LEFT))
|
|
{
|
|
pDbWall->assertWriteEnabled();
|
|
|
|
// sg modify 100714,分侧设置保温层厚度
|
|
nSide = sInput==_T("I")? OFFSET_RIGHT:OFFSET_LEFT;
|
|
// pDbWall->SetInsulateThick(nInsThick);
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pDbWall->SetInsulateThick(nInsThick, nSide);
|
|
pDbWall->SetInsulateThick(AS_INT(nInsThick), nSide);
|
|
|
|
pDbWall->SetInsulateOnSide(sInput==_T("I")? OFFSET_RIGHT:OFFSET_LEFT, TRUE);
|
|
pDbWall->RelocateOpening();
|
|
}
|
|
else if (pDbWall->IsExternal(OFFSET_RIGHT))
|
|
{
|
|
pDbWall->assertWriteEnabled();
|
|
|
|
// sg modify 100714,分侧设置保温层厚度
|
|
nSide = sInput==_T("I")? OFFSET_LEFT:OFFSET_RIGHT;
|
|
// pDbWall->SetInsulateThick(nInsThick);
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pDbWall->SetInsulateThick(nInsThick, nSide);
|
|
pDbWall->SetInsulateThick(AS_INT(nInsThick), nSide);
|
|
|
|
pDbWall->SetInsulateOnSide(sInput==_T("I")? OFFSET_LEFT:OFFSET_RIGHT, TRUE);
|
|
pDbWall->RelocateOpening();
|
|
}
|
|
|
|
// 获得需要给墙体哪一侧加保温
|
|
TGGeCurveSegment segLWall, segRWall;
|
|
pDbWall->GetSideCurve(segLWall, segRWall);
|
|
if (nSide == OFFSET_RIGHT)
|
|
{
|
|
segLWall = segRWall; // 节省代码,固定使用segLWall与墙体造型进行布尔运算
|
|
}
|
|
|
|
// 获取墙体起、点终点位置的柱子ID
|
|
AcDbObjectId idStart = pDbWall->GetStartColumnId(),
|
|
idEnd = pDbWall->GetEndColumnId();
|
|
int nResult = 0; // 标记是否已经在数组中存在该ID
|
|
if (aryColumn.find(idStart, nResult, 0) != Adesk::kTrue)
|
|
{
|
|
aryColumn.append(idStart);
|
|
}
|
|
if (aryColumn.find(idEnd, nResult, 0) != Adesk::kTrue)
|
|
{
|
|
aryColumn.append(idEnd);
|
|
}
|
|
|
|
|
|
// 获得墙体连接的墙体造型的ID
|
|
const TDPtrList<AcDbSoftPointerId> &lstPatch = pDbWall->GetPatchIdList();
|
|
for (int j = 0; j < lstPatch.Length(); j++)
|
|
{
|
|
const AcDbObjectId &idPatch = lstPatch[j];
|
|
OPENOBJ_BEGIN(idPatch, AcDb::kForRead, TDbWallPatch, pPatch);
|
|
if (pPatch == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TGGePoly2D polyPatch;
|
|
pPatch->GetOutlinePoly(polyPatch, false);
|
|
|
|
if ((segLWall & polyPatch) != PR_INTERS) // 判断墙体造型轮廓线是否与墙体内侧或外侧墙线相交
|
|
{
|
|
continue;
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (aryWallPatch.find(idPatch, nResult, 0) != Adesk::kTrue)
|
|
{
|
|
aryWallPatch.append(idPatch);
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
|
|
// sg add 110128,给与外墙相连接的柱子和墙体造型设置保温厚
|
|
int nInsulateFlag = sInput==_T("I")?1:0; // 获得要添加的柱子保温侧,内为1,外为0
|
|
int nColumnsNum = aryColumn.length();
|
|
for (int k=0; k<nColumnsNum; k++)
|
|
{
|
|
OPENOBJ_BEGIN(aryColumn[k], AcDb::kForWrite, TDbColumn, pColumn);
|
|
if (pColumn != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pColumn->GetInsulateLayerId();
|
|
if (!idSurf.isValid())
|
|
pColumn->SetInsulateLayerId(InitLayer(LAY_SURFACE)); // 设置保温图层
|
|
|
|
// sg add 110727,解决使用内保温、外保温时,保温层厚度是默认值的问题,把当前设置传进去
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pColumn->SetInsulateThick(nInsThick);
|
|
pColumn->SetInsulateThick(AS_INT(nInsThick));
|
|
pColumn->DrawInsulateInExt(nInsulateFlag);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
int nPatchsNum = aryWallPatch.length();
|
|
for (k=0; k<nPatchsNum; k++)
|
|
{
|
|
OPENOBJ_BEGIN(aryWallPatch[k], AcDb::kForWrite, TDbWallPatch, pPatch);
|
|
if (pPatch != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pPatch->GetLayerInsulateId();
|
|
if (!idSurf.isValid())
|
|
pPatch->SetLayerInsulateId(InitLayer(LAY_SURFACE)); // 设置保温图层
|
|
|
|
pPatch->SetInsulate(TRUE);
|
|
// sg add 110727,解决使用内保温、外保温时,保温层厚度是默认值的问题,把当前设置传进去
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pPatch->SetInsulateThick(nInsThick);
|
|
pPatch->SetInsulateThick(AS_INT(nInsThick));
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
else // 正常选择的情况
|
|
{
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
|
|
// sg modify 100715,根据8.5需求,该命令改为“墙柱保温”,支持选择“墙体造型”和“柱子”
|
|
if (entWall.Is(_T("TCH_WALL"))) // 墙体
|
|
{
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
XCurveSegment seg = pWall->OffsetGeomCenter();
|
|
int nSide = seg.OnWhichSide(ptPick);
|
|
pWall->assertWriteEnabled();
|
|
|
|
// sg modify 100714,分侧设置保温层厚度
|
|
// pWall->SetInsulateThick(nInsThick);
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pWall->SetInsulateThick(nInsThick, nSide);
|
|
pWall->SetInsulateThick(AS_INT(nInsThick), nSide);
|
|
pWall->SetInsulateOnSide(nSide, TRUE);
|
|
pWall->RelocateOpening();
|
|
pWall->close();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
else if (entWall.Is(_T("TCH_COLUMN"))) // 柱子
|
|
{
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForWrite, TDbColumn, pColumn);
|
|
if (pColumn != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pColumn->GetInsulateLayerId();
|
|
if (!idSurf.isValid())
|
|
pColumn->SetInsulateLayerId(InitLayer(LAY_SURFACE));
|
|
|
|
pColumn->assertWriteEnabled();
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pColumn->SetInsulateThick(nInsThick);
|
|
pColumn->SetInsulateThick(AS_INT(nInsThick));
|
|
pColumn->SetInsulateOnColumn(true);
|
|
|
|
TADSGePoint3d ptColumnLocation = pColumn->GetLocation(); // 柱子位置点
|
|
AcGeVector3d vtDir = ptPick.AsAcGePoint3d() - ptColumnLocation.AsAcGePoint3d();
|
|
pColumn->AppendInsulateDir(vtDir);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
else if (entWall.Is(_T("TCH_WALL_PATCH"))) // 墙体造型
|
|
{
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForWrite, TDbWallPatch, pWallPatch);
|
|
if (pWallPatch != NULL)
|
|
{
|
|
AcDbObjectId idSurf = pWallPatch->GetLayerInsulateId();
|
|
if (!idSurf.isValid())
|
|
pWallPatch->SetLayerInsulateId(InitLayer(LAY_SURFACE));
|
|
|
|
pWallPatch->assertWriteEnabled();
|
|
pWallPatch->SetInsulate(TRUE);
|
|
// sg modify 110907,将数据取整,否则容易产生精确度问题
|
|
// pWallPatch->SetInsulateThick(nInsThick);
|
|
pWallPatch->SetInsulateThick(AS_INT(nInsThick));
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Command: 取消保温
|
|
void DelInsulate()
|
|
{
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList wallMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
if (SelectEntities(_T("\n选择墙体:"), ssWalls, wallMask)!=RTNORM)
|
|
return;
|
|
long nWallNum=ssWalls.Length();
|
|
for (long n=0L; n<nWallNum; n++) {
|
|
Entity e=ssWalls[n];
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetInsulateOnSide(OFFSET_LEFT, FALSE);
|
|
pWall->SetInsulateOnSide(OFFSET_RIGHT, FALSE);
|
|
pWall->RelocateOpening();
|
|
pWall->close();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
BOOL GetPLLeftDownPoint(AcDbPolyline *pLwPoly, XPoint &ptLoc)
|
|
{
|
|
if (!pLwPoly)
|
|
return FALSE;
|
|
int iNum = pLwPoly->numVerts();
|
|
AcGePoint3d ptTemp;
|
|
pLwPoly->getPointAt(0, ptTemp);
|
|
double dMinX = ptTemp.x;
|
|
double dMinY = ptTemp.y;
|
|
for (int i = 1 ; i < iNum; ++i)
|
|
{
|
|
pLwPoly->getPointAt(i, ptTemp);
|
|
if (ptTemp.x < dMinX)
|
|
dMinX = ptTemp.x;
|
|
if (ptTemp.y < dMinY)
|
|
dMinY = ptTemp.y;
|
|
}
|
|
ptLoc.x = dMinX;
|
|
ptLoc.y = dMinY;
|
|
ptLoc.z = 0;
|
|
}
|
|
|
|
/////////////////////////////////
|
|
// Command: 生成建筑外轮廓wlw16.07.07
|
|
// 必须在WCS下
|
|
//int ntypetri = 1;//是否外门处生成小三角
|
|
//int nBaltype = 1;//是否处理阳台轮廓
|
|
extern void MakeWallSet(PickSet &ssWalls);
|
|
BOOL MakeOUTWALL(PickSet &ssWalls, CString slayname,CString sLineType, double dThickness, int ntypetri, int nBaltype)
|
|
{
|
|
double dtridis = 6 * utility::GetPScale();//三角距离轮廓线距离
|
|
double dtriLen = 3 * utility::GetPScale();//三角长度
|
|
AcDbObjectIdArray idarrs;//记录所有生成对象,编组用
|
|
BOOL bTOOMUCH = FALSE;
|
|
PickSet ss(SS_FREE);
|
|
ss.IncludeBegin();
|
|
PickSet ssOpenings;
|
|
ssOpenings += ssWalls;
|
|
RBList maskOpening(RTDXF0,_T("TCH_OPENING"),NULL);
|
|
ssOpenings.BaseFilter(maskOpening);
|
|
//过滤门窗
|
|
MakeWallSet(ssWalls);
|
|
|
|
PickSet ssBalcony;
|
|
ssBalcony += ssWalls;
|
|
RBList maskBalcony(RTDXF0,_T("TCH_BALCONY"),NULL);
|
|
ssBalcony.BaseFilter(maskBalcony);
|
|
//过滤阳台
|
|
ssWalls -= ssBalcony;
|
|
|
|
|
|
DList<AcDbObjectId> lstColu;
|
|
GetEntFromBlockByDxf(lstColu, _T("TCH_COLUMN"));
|
|
XSearchSpaceFromWall aSearch;
|
|
try {
|
|
aSearch.InitStart(ssWalls, lstColu);
|
|
} catch(...) {
|
|
adsout << /*UMSG*/_T("\n发生例外情况!");
|
|
return FALSE;
|
|
}
|
|
|
|
XAecSpaceCell * extCell=aSearch.SearchSpaces();
|
|
if (extCell)
|
|
{
|
|
aSearch.UpdateWallFlags();
|
|
XPoly2D poly(1);
|
|
extCell->InternalPoly2D(poly, 2, 2);
|
|
|
|
|
|
// 获得所有房间对象,判断是否选了构成多个外轮廓的墙体
|
|
int nLenSpaces = aSearch.spaces.Length(); // 房间对象的个数
|
|
for (int n = 0; n<nLenSpaces; n++)
|
|
{
|
|
XAecSpaceCell *pSpace = aSearch.spaces[n]; // 得到房间
|
|
if (pSpace == extCell) // 判断是否是当前得到的外轮廓,是,则返回
|
|
continue;
|
|
|
|
// 获得房间的轮廓
|
|
XPoly2D polySpace(1);
|
|
pSpace->CenterPoly2D(polySpace);
|
|
|
|
// 外轮廓与房间的轮廓做布尔交集运算,结果保存在lstPolyRest中
|
|
TDPtrList<TGGePoly2D> lstPolyRest;
|
|
TchSubExport::Intersect(poly, polySpace, lstPolyRest);
|
|
|
|
// 判断lstPolyRest的长度,如果长度为零,不存在交集属于两个轮廓
|
|
int nRetLen = lstPolyRest.Length();
|
|
if (nRetLen < 1) // 没有交集
|
|
{
|
|
bTOOMUCH = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bTOOMUCH)
|
|
{
|
|
printf(_T("\n无法生成建筑轮廓线,请重新选择!"));
|
|
return FALSE;
|
|
}
|
|
|
|
TArchCmdReactor::ResetAll();
|
|
poly.TransUCS(Groups(0), Groups(1));
|
|
|
|
int nLen = poly.Length();
|
|
if (nLen <= 1)
|
|
{
|
|
return FALSE;
|
|
}
|
|
AcDbPolyline *pLwPoly = new AcDbPolyline(nLen);
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
double dBuge = tan(*(poly.m_ardbulges[i]) / 4.0);
|
|
pLwPoly->addVertexAt(i, poly[i]->AsAcGePoint2d(), dBuge);
|
|
}
|
|
|
|
if (!slayname.IsEmpty())
|
|
{
|
|
AssureLayer(slayname, LAYSTAT_UNLOCK);
|
|
pLwPoly->setLayer(slayname);
|
|
}
|
|
|
|
pLwPoly->setClosed(Adesk::kTrue);
|
|
pLwPoly->setConstantWidth(dThickness);
|
|
AcDbObjectId idLineType = InitLineType(sLineType);
|
|
pLwPoly->setLinetype(idLineType);
|
|
idarrs.append(AddToModelSpace(pLwPoly, Adesk::kTrue));
|
|
|
|
//处理外门生成小三角
|
|
if (ntypetri)
|
|
{
|
|
AcGePoint3dArray pts;
|
|
long l = ssOpenings.Length();
|
|
XPoint pt1,pt2, ptMid;
|
|
AcGePoint3d ptge1,ptge2;
|
|
for (long i = 0; i < l; i++)
|
|
{//找到外墙上的所有门
|
|
OPENOBJ_BEGIN(ssOpenings[i], AcDb::kForRead, TDbOpening, pWin)
|
|
if (pWin == NULL)
|
|
continue;
|
|
if (pWin->GetKind() == TDbOpening::OP_DOOR || pWin->GetKind() ==TDbOpening::OP_TWODOOR)
|
|
{
|
|
OPENOBJ_BEGIN(pWin->GetWallId(), AcDb::kForRead, TDbWall, pWall)
|
|
if (pWall)
|
|
{
|
|
if (pWall->IsExternal())
|
|
{
|
|
pWin->GetSidePoints(pt1,pt2);
|
|
XPoint ptTest = pWin->GetLocation();
|
|
Midpoint(pt1, pt2, ptMid);
|
|
pLwPoly->getClosestPointTo(ptMid.AsAcGePoint3d(), ptge1);
|
|
|
|
AcGeVector3d vt = ptge1 - ptMid.AsAcGePoint3d();
|
|
vt = vt.normalize();
|
|
ptge1 += vt * (dtridis - (pWall->GetWidth(0) - pWall->GetWidth(1))*0.5);
|
|
ptge2 = ptge1 + vt* dtriLen;
|
|
pt1 = ptge1;
|
|
pt2 = ptge2;
|
|
|
|
AcDbPolyline *pLwPolyTri = new AcDbPolyline(2);
|
|
pLwPolyTri->addVertexAt(0, pt1.AsAcGePoint2d(),0,0.0,2.0 * dtriLen);
|
|
pLwPolyTri->addVertexAt(1, pt2.AsAcGePoint2d());
|
|
InitLayer(LAY_OTHER_DIM, TRUE);
|
|
pLwPolyTri->setLayer(LAY_OTHER_DIM);
|
|
idarrs.append(AddToModelSpace(pLwPolyTri, Adesk::kTrue));
|
|
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
}
|
|
|
|
//处理阳台轮廓线
|
|
if (nBaltype)
|
|
{
|
|
for (long i = 0; i < ssBalcony.Length(); i++)
|
|
{
|
|
TGGePoly2D polyBal;
|
|
AcGePoint2dArray ptBals;
|
|
TGGeCurveSegment seg;
|
|
OPENOBJ_BEGIN(ssBalcony[i], AcDb::kForRead, TDbBalcony, pBal)
|
|
if (pBal == NULL)
|
|
continue;
|
|
AcGeVector3d normal;
|
|
pBal->GetPathPoly(polyBal, normal);
|
|
int nEdge=pBal->GetEdgeNum();
|
|
BOOL bFlag = FALSE;
|
|
for (int k = 0; k < nEdge; k++)
|
|
{
|
|
if(!pBal->HasRailAt(k))
|
|
continue;
|
|
|
|
polyBal.Nth(k, seg);
|
|
if (bFlag == FALSE)
|
|
{
|
|
ptBals.append(seg.StartPoint().AsAcGePoint2d());
|
|
bFlag = TRUE;
|
|
}
|
|
ptBals.append(seg.EndPoint().AsAcGePoint2d());
|
|
|
|
}
|
|
|
|
OPENOBJ_END()
|
|
|
|
AcDbPolyline *pBalpoly = new AcDbPolyline();
|
|
for (int i = 0; i < ptBals.length(); i++)
|
|
{
|
|
pBalpoly->addVertexAt(i, ptBals[i]);
|
|
|
|
}
|
|
if (!slayname.IsEmpty())
|
|
{
|
|
AssureLayer(slayname, LAYSTAT_UNLOCK);
|
|
pBalpoly->setLayer(slayname);
|
|
}
|
|
|
|
idarrs.append(AddToModelSpace(pBalpoly, Adesk::kTrue));
|
|
}
|
|
}
|
|
|
|
AcDbObjectId id;
|
|
MakeGroup(idarrs, id);
|
|
|
|
CPoint ptCursor;
|
|
XPoint ptLoc;//获取当前基点
|
|
GetPLLeftDownPoint(pLwPoly, ptLoc);
|
|
ASSERT(!!id);
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt);
|
|
if (pEnt)
|
|
pEnt->draw();
|
|
OPENOBJ_END();
|
|
int iRet(0);
|
|
ss.IncludeEnd();
|
|
iRet = DragPickSet(ss,ptLoc);
|
|
if (iRet != RTNORM)
|
|
{
|
|
if (iRet == RTCAN)
|
|
{
|
|
ss.Redraw(1);
|
|
ss.Delete();
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
adsout<<_T("\n无法生成建筑轮廓线,请重新选择!");
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
/////////////////////////////////
|
|
// Command: 标记内外墙
|
|
// 必须在WCS下
|
|
void MarkWall()
|
|
{
|
|
extern void MakeWallSet(PickSet &ssWalls);
|
|
// 找到所有墙
|
|
PickSet ssWalls(SS_FREE);
|
|
|
|
g_ssPickFirst.Free();
|
|
if (SelectEntities(_T("\n请选择一栋建筑物的所有墙体(或门窗):"), ssWalls,RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL,TCH_OPENING"), NULL))!=RTNORM)
|
|
return;
|
|
MakeWallSet(ssWalls);
|
|
DList<AcDbObjectId> lstColu;
|
|
GetEntFromBlockByDxf(lstColu, _T("TCH_COLUMN"));
|
|
|
|
XSearchSpaceFromWall aSearch;
|
|
try {
|
|
aSearch.InitStart(ssWalls, lstColu);
|
|
} catch(...) {
|
|
adsout << /*UMSG*/_T("\n发生例外情况!");
|
|
return ;
|
|
}
|
|
|
|
XAecSpaceCell * extCell=aSearch.SearchSpaces();
|
|
if (extCell)
|
|
{
|
|
aSearch.UpdateWallFlags();
|
|
XPoly2D poly(1);
|
|
extCell->InternalPoly2D(poly, 0, 0);
|
|
TArchCmdReactor::ResetAll();
|
|
XScreenDc dc(1,1);
|
|
poly.TransUCS(Groups(0), Groups(1));
|
|
dc << poly; //red and highlight
|
|
//extCell->Redraw(3);
|
|
adsout << _T("\n识别出的外墙用红色的虚线示意。");
|
|
|
|
//对所有外墙设置内外特征,add by whl
|
|
poly.TransUCS(Groups(1),Groups(0));
|
|
poly.SetElevation(0.0);
|
|
XCurveSegment lCurve,rCurve;
|
|
long len=ssWalls.Length();
|
|
for (long i=0;i<len;i++)
|
|
{
|
|
Entity e=ssWalls[i];
|
|
OPENOBJ_BEGIN(e, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall!=NULL&&pWall->IsExternal())
|
|
{
|
|
pWall->GetSideCurve(lCurve,rCurve,0.0,TRUE);
|
|
XPoint ptMid=lCurve.MidPoint();
|
|
ptMid.z=0;
|
|
int iRet=ptMid&poly;
|
|
if (iRet==PR_EDGE)//左外
|
|
{
|
|
pWall->SetExternal(0,TRUE);
|
|
pWall->SetExternal(1,FALSE);
|
|
}
|
|
else//右外
|
|
{
|
|
pWall->SetExternal(0,FALSE);
|
|
pWall->SetExternal(1,TRUE);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
} else {
|
|
adsout << _T("\n没有判别出内外墙!请使用指定内墙、指定外墙命令手动指定。");
|
|
}
|
|
}
|
|
|
|
|
|
///////////////////////////////
|
|
// 改墙体端头形式
|
|
// 注释:利用PickFirst
|
|
void ChWallTerm()
|
|
{
|
|
PickSet ss(SS_FREE);
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
if (SelectEntities(_T("\n选择墙体: "), ss, mask)==RTNORM) {
|
|
long lCount=ss.Length();
|
|
for (long i=0L; i<lCount; i++) {
|
|
Entity entWall=ss[i];
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
int nFlag=pWall->GetWallFlag();
|
|
if (pWall->IsTermAt(0) || pWall->IsTermAt(1) /*(nFlag&WF_STARTTERM) || (nFlag&WF_ENDTERM)*/) {
|
|
pWall->assertWriteEnabled();
|
|
if (nFlag&WF_SECTTERM) nFlag &= ~WF_SECTTERM;
|
|
else nFlag |= WF_SECTTERM;
|
|
pWall->SetFlagData(nFlag);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////
|
|
// Command: 把UCS定位在墙上
|
|
// 必须在WCS下
|
|
void UcsWall()
|
|
{
|
|
extern TARCH_IMPEXP void ReadVports(DList<TViewportInfo> &vpInfo); //读取视口信息
|
|
Entity ent;
|
|
ads_real nDrt;
|
|
XPoint ptOnSide, pickPt1;
|
|
if (SelectWallSide(ent, ptOnSide, &nDrt)==RTNORM) {
|
|
TWallData wall(ent);
|
|
if (!wall) return ;
|
|
XPoint ptx, pty(ptOnSide.x, ptOnSide.y, ptOnSide.z+1000);
|
|
ads_polar(ptOnSide, nDrt, 1000.0, ptx);
|
|
|
|
DList<TViewportInfo> lstViewp;
|
|
ReadVports(lstViewp);
|
|
if (lstViewp.Length()>=2) {
|
|
XPoint ptPick;
|
|
if (ads_getpoint(NULL, _T("\n点取要设置坐标系的视口<当前>:"), ptPick)==RTCAN)
|
|
return;
|
|
}
|
|
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
|
AsureWCS();
|
|
ads_command(RTSTR, _T(".UCS"), RTSTR, _T("3p"), RT3DPOINT, &ptOnSide,
|
|
RT3DPOINT, &ptx, RT3DPOINT, &pty, RTNONE);
|
|
ads_command(RTSTR, _T(".PLAN"), RTSTR, _T(""), RTNONE);
|
|
}
|
|
}
|
|
|
|
// add by lgh 101202
|
|
// 从一个Array中查找是否存在一个字符串
|
|
// ret: -1:没找到。 其他:目标字符串的位置
|
|
int FindStringInArray(CStringArray &arBanLabel, CString s)
|
|
{
|
|
for (int i = 0; i < arBanLabel.GetSize(); i++)
|
|
{
|
|
if (arBanLabel[i].CompareNoCase(s) == 0)
|
|
return i;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
// add by lgh 101202
|
|
// 字符串排序函数,转发对CString->CompareNoCase的调用
|
|
int StringCompare(const void *_pStr1, const void *_pStr2)
|
|
{
|
|
CString *pS1 = (CString*)_pStr1;
|
|
CString *pS2 = (CString*)_pStr2;
|
|
|
|
return pS1->CompareNoCase(*pS2);
|
|
}
|
|
|
|
// add by lgh 101202
|
|
// 字符串排序,排序函数:StringCompare
|
|
void SortString(CStringArray &arString)
|
|
{
|
|
if (arString.GetSize() > 1)
|
|
{
|
|
CString *pArString = arString.GetData();
|
|
qsort(pArString, arString.GetSize(), sizeof(CString), StringCompare);
|
|
}
|
|
}
|
|
|
|
// Add by lcf on 20050729
|
|
class CBanOpeningDlg : public CModelessDialog
|
|
{
|
|
DECLARE_DYNAMIC(CBanOpeningDlg)//add by fxj 090331
|
|
public:
|
|
// CBanOpeningDlg(CWnd* pParent = NULL): CModelessDialog(CBanOpeningDlg::IDD, pParent)
|
|
// , m_szWinHeight(_T("1500")), m_szStoolHeight(_T("900")){}//modified by fxj 090323
|
|
// modify by lgh。所有的初始化操作都通过静态变量执行。
|
|
CBanOpeningDlg(CWnd* pParent = NULL): CModelessDialog(CBanOpeningDlg::IDD, pParent)
|
|
{}//modified by fxj 090323
|
|
|
|
enum { IDD = IDD_DIALOG_BANOPENING };
|
|
// 不再需要的成员
|
|
// static CString g_szNumber;
|
|
// 默认值
|
|
static CString g_szLabel;
|
|
// modify by lgh 20101201,修改为静态变量
|
|
static CString g_szWinHeight;
|
|
static CString g_szStoolHeight;
|
|
CComboBox m_cmbLabel;
|
|
|
|
// add by lgh.用当前工程中现有的带形窗名称填充编号编辑框。
|
|
void ResetLabelCombox();
|
|
// 自动编号
|
|
static CString GetAutoLabel(TDbBandWin *pBan);
|
|
|
|
// 获取当前的编号
|
|
CString GetLabel(TDbBandWin *pBan);
|
|
CString GetLabelOpBan(TDbOpening *pOp);
|
|
void AfterModelAdded(TDbBandWin *pBanWin);
|
|
protected:
|
|
// 查找当前工程带形窗IDlist
|
|
// dlList,需要保持dlList的开启状态,以供后续继续访问idList(保证id对应的db是打开的);
|
|
// 因为带形窗跟转角窗公用DXF,因此此处获得的是带形窗和转角窗的IDlist合集
|
|
static void GetBanOpeningIdList(DList<AcDbDatabase> &dbList, DList<AcDbObjectId> &idList);
|
|
// 读取带形窗label数组。再打开id时,会判断是否是带形窗。
|
|
static void GetLabelAry(DList<AcDbObjectId> &idList, CStringArray &arBanData);
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
virtual BOOL OnInitDialog();
|
|
virtual void OnOK();
|
|
CString GetRegLocation() const;
|
|
BOOL ReadParamFromRegistry();
|
|
BOOL WriteParamToRegistry() const;
|
|
//-----------------add by fxj 090331---------
|
|
public:
|
|
afx_msg void OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\n"));
|
|
}
|
|
afx_msg void OnSelChangeLabel();
|
|
DECLARE_MESSAGE_MAP()
|
|
//-------------------------------------
|
|
};
|
|
|
|
class CBanOpeningDlgDeler
|
|
{
|
|
public:
|
|
CBanOpeningDlgDeler(CBanOpeningDlg &dlg) : m_dlg(dlg){}
|
|
~CBanOpeningDlgDeler() {if (IsWindow(m_dlg.m_hWnd)) m_dlg.DestroyWindow();}
|
|
private:
|
|
CBanOpeningDlg &m_dlg;
|
|
};
|
|
|
|
//--------add by fxj 090331-----------
|
|
IMPLEMENT_DYNAMIC(CBanOpeningDlg,CModelessDialog)
|
|
BEGIN_MESSAGE_MAP(CBanOpeningDlg, CModelessDialog)
|
|
ON_WM_CREATE()
|
|
ON_WM_CLOSE()
|
|
ON_CBN_SELCHANGE(IDC_CMB_LABEL, OnSelChangeLabel)
|
|
END_MESSAGE_MAP()
|
|
//-------------------------------------
|
|
//CString CBanOpeningDlg::g_szNumber=_T("DC");
|
|
CString CBanOpeningDlg::g_szWinHeight = _T("1500");
|
|
CString CBanOpeningDlg::g_szStoolHeight = _T("900");
|
|
#define S_BAN_AUTOLABEL (_T("自动编号"))
|
|
CString CBanOpeningDlg::g_szLabel = S_BAN_AUTOLABEL;
|
|
const CString sBanType = _T("带形窗");
|
|
|
|
void CBanOpeningDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
// DDX_Text(pDX, IDC_NUMBER, g_szNumber);
|
|
DDX_CBString(pDX, IDC_WINHEIGHT, g_szWinHeight);
|
|
DDX_CBString(pDX, IDC_STOOLHEIGHT, g_szStoolHeight);
|
|
DDX_Control(pDX, IDC_CMB_LABEL, m_cmbLabel);
|
|
|
|
// add by lgh。数据更新的时候,同时更新g_szLabel的值。但是不通过该值赋值
|
|
if (pDX->m_bSaveAndValidate)
|
|
{
|
|
m_cmbLabel.GetWindowText(g_szLabel);
|
|
}
|
|
}
|
|
|
|
BOOL CBanOpeningDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
ResetLabelCombox();
|
|
UpdateData(FALSE); // 显示到屏幕中
|
|
m_cmbLabel.SetWindowText(g_szLabel);
|
|
ReadParamFromRegistry();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// 编辑框中内内容改变时,需要设置默认的数值。
|
|
void CBanOpeningDlg::OnSelChangeLabel()
|
|
{
|
|
// 打开相关文档,然后从中读取数据
|
|
DList<AcDbDatabase> databaseLst;
|
|
DList<AcDbObjectId> idLst;
|
|
GetBanOpeningIdList(databaseLst, idLst);
|
|
|
|
int nCurrSel = m_cmbLabel.GetCurSel();
|
|
if (nCurrSel >= 0 )
|
|
{
|
|
CString sSelLabel;
|
|
m_cmbLabel.GetLBText(nCurrSel, sSelLabel);
|
|
bool bFind = false;
|
|
for (int i = 0; i < idLst.Length(); i++)
|
|
{
|
|
AcDbObjectId &id = *(idLst[i]);
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbBandWin, pBan);
|
|
if (pBan != NULL && sSelLabel.CompareNoCase(pBan->GetLabel()) == 0 )
|
|
{
|
|
g_szWinHeight.Format(_T("%lg"), pBan->GetHeight());
|
|
g_szStoolHeight.Format(_T("%lg"), pBan->GetElevation());
|
|
bFind = true;
|
|
UpdateData(FALSE);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (bFind)
|
|
break;
|
|
}
|
|
|
|
m_cmbLabel.SetWindowText(sSelLabel);
|
|
g_szLabel = sSelLabel;
|
|
}
|
|
}
|
|
|
|
CString CBanOpeningDlg::GetLabel(TDbBandWin *pBan)
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
CString sLabel;
|
|
m_cmbLabel.GetWindowText(sLabel);
|
|
if (sLabel.CompareNoCase(S_BAN_AUTOLABEL) == 0)
|
|
return GetAutoLabel(pBan);
|
|
else
|
|
{
|
|
return sLabel;
|
|
}
|
|
}
|
|
|
|
CString CBanOpeningDlg::GetLabelOpBan(TDbOpening *pOp)
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
CString sLabel;
|
|
m_cmbLabel.GetWindowText(sLabel);
|
|
if (sLabel.CompareNoCase(S_BAN_AUTOLABEL) == 0)
|
|
return CInsertOpeningDlg::CalcAutoLabel(pOp);
|
|
else
|
|
{
|
|
return sLabel;
|
|
}
|
|
}
|
|
|
|
|
|
void CBanOpeningDlg::ResetLabelCombox()
|
|
{
|
|
DList<AcDbDatabase> databaseLst;
|
|
DList<AcDbObjectId> idLst;
|
|
GetBanOpeningIdList(databaseLst, idLst);
|
|
|
|
CStringArray arBanLabelData;
|
|
GetLabelAry(idLst, arBanLabelData);
|
|
|
|
m_cmbLabel.ResetContent();
|
|
m_cmbLabel.AddString(S_BAN_AUTOLABEL);
|
|
SortString(arBanLabelData);
|
|
for (int i = 0; i < arBanLabelData.GetSize(); i++)
|
|
{
|
|
m_cmbLabel.AddString(arBanLabelData[i]);
|
|
}
|
|
}
|
|
|
|
void CBanOpeningDlg::GetBanOpeningIdList(DList<AcDbDatabase> &dbList, DList<AcDbObjectId> &idList)
|
|
{
|
|
XStringList lstFiles;
|
|
::GetFloorFiles(lstFiles);
|
|
CString sCurDwg=curDoc()->fileName();
|
|
for(int i=0; i<lstFiles.Length(); i++)
|
|
{
|
|
CString sDwgDump = lstFiles[i];
|
|
if (_tcsicmp(sCurDwg, sDwgDump)==0)
|
|
continue; // Disalbe CurDwg
|
|
AcDbDatabase *dwgDb=new AcDbDatabase(false, true);
|
|
dbList.Append(dwgDb);
|
|
#if ADS < 21
|
|
if (dwgDb->readDwgFile(sDwgDump, _SH_DENYNO, false)==Acad::eOk)
|
|
#else
|
|
if (dwgDb->readDwgFile(sDwgDump, AcDbDatabase::kForReadAndAllShare, false)==Acad::eOk)
|
|
#endif
|
|
{
|
|
GetEntityFromDatabase(idList, *dwgDb, _T("TCH_CORNER_WINDOW"), 0, ACDB_MODEL_SPACE);
|
|
}
|
|
}
|
|
GetEntFromBlockByDxf(idList, _T("TCH_CORNER_WINDOW"));
|
|
}
|
|
|
|
void CBanOpeningDlg::GetLabelAry(DList<AcDbObjectId> &idList, CStringArray &arBanData)
|
|
{
|
|
arBanData.RemoveAll();
|
|
|
|
for (int i = 0; i < idList.Length(); i++)
|
|
{
|
|
AcDbObjectId &id = *idList[i];
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbBandWin, pBan);
|
|
if (pBan != NULL)
|
|
{
|
|
CString sBan = pBan->GetLabel();
|
|
sBan.TrimLeft();sBan.TrimRight();
|
|
if (sBan.IsEmpty()) continue;
|
|
if (FindStringInArray(arBanData, sBan) == -1)
|
|
{
|
|
arBanData.Add(sBan);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
CString CBanOpeningDlg::GetAutoLabel(TDbBandWin *pBan)
|
|
{
|
|
bool bReName = false;
|
|
|
|
CString strName = pBan->GetAutoLabel(bReName);
|
|
|
|
if (bReName)
|
|
{
|
|
DList<AcDbDatabase> lstDataBase;
|
|
DList<AcDbObjectId> lstId;
|
|
GetBanOpeningIdList(lstDataBase, lstId);
|
|
|
|
int nBigNum = 1;
|
|
for (int i = 0; i < (int)lstId.Length(); i++)
|
|
{
|
|
AcDbObjectId *pId = lstId[i];
|
|
OPENOBJ_BEGIN(*pId, AcDb::kForRead, TDbBandWin, pEnt)
|
|
{
|
|
if (pEnt == NULL)
|
|
continue;
|
|
|
|
CString strLabel = pEnt->GetLabel();
|
|
if (CheckDoorWinLabel(strLabel))
|
|
{
|
|
if (TestCanSameLabel(pEnt, pBan->GetWidth(), pBan->GetHeight()))
|
|
{
|
|
return strLabel;
|
|
}
|
|
else
|
|
{
|
|
int nNum = GetSequenceNum(strLabel) + 1;
|
|
nBigNum = Maximum(int(2), nNum, nBigNum);
|
|
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
strName.Format(_T("%s%d"), strName, nBigNum);
|
|
}
|
|
|
|
return strName;
|
|
}
|
|
|
|
|
|
CString CBanOpeningDlg::GetRegLocation() const
|
|
{
|
|
return _T("BandWin");
|
|
}
|
|
|
|
|
|
// 从注册表读入参数
|
|
BOOL CBanOpeningDlg::ReadParamFromRegistry()
|
|
{
|
|
XString sRegSubLoc = this->GetRegLocation(), sRegLoc(1024);
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings") ;
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
CString csLab;
|
|
if (!regProp.GetValue(_T("Label"), csLab))
|
|
return FALSE;
|
|
|
|
g_szLabel = csLab;
|
|
return TRUE;
|
|
}
|
|
//把最近的参数写入注册表
|
|
BOOL CBanOpeningDlg::WriteParamToRegistry() const
|
|
{
|
|
XString sRegSubLoc = GetRegLocation(), sRegLoc(1024);
|
|
|
|
sRegLoc << ::GetRegLocation() << _T("\\Settings");
|
|
CRegProperty regProp(sRegLoc, sRegSubLoc);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
|
|
regProp.SetValue(_T("Label"), g_szLabel);
|
|
return TRUE;
|
|
}
|
|
|
|
void CBanOpeningDlg::OnOK()
|
|
{
|
|
CModelessDialog::OnOK();
|
|
}
|
|
|
|
void AddStringToCombo(CComboBox &cmb, CString &strText);
|
|
void CBanOpeningDlg::AfterModelAdded(TDbBandWin *pBanWin)
|
|
{
|
|
WriteParamToRegistry();
|
|
if (pBanWin != NULL)
|
|
AddStringToCombo(m_cmbLabel, CString(pBanWin->GetLabel()));
|
|
}
|
|
|
|
|
|
|
|
void BanOpening()
|
|
{
|
|
// removed by lgh.// 初始化,由对话框内的静态成员变量执行。
|
|
// static double nSill=900.0, nHeight=1500.0;//modified by fxj 090331
|
|
CBanOpeningDlg dlg(acedGetAcadFrame());
|
|
CBanOpeningDlgDeler deler(dlg);
|
|
// dlg.m_szWinHeight.Format(_T("%lg"), nHeight);
|
|
// dlg.m_szStoolHeight.Format(_T("%lg"), nSill);
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
if ( !dlg.Create(dlg.IDD, acedGetAcadFrame()) )
|
|
return;
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
XPushVar<int> vOsMode(_T("OSMODE"), OS_END|OS_INT|OS_NEA);
|
|
|
|
extern TARCH_IMPEXP BOOL g_bEnableCornWinWarning;
|
|
XPoint ptStart, ptEnd;
|
|
if (XGetPoint(NULL, _T("\n起始点"), ptStart)!=RTNORM ||
|
|
XGetPoint(NULL, _T("\n终止点"), ptEnd)!=RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ptStart=Ucs2Wcs(ptStart);
|
|
ptEnd=Ucs2Wcs(ptEnd);
|
|
Entity eStart, eEnd;
|
|
|
|
PickSet ssWalls(SS_FREE);
|
|
g_ssPickFirst.Free();
|
|
if (SelectEntities(_T("\n选择带形窗经过的墙:"),ssWalls, RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL))!=RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
dlg.UpdateData();
|
|
double nSill = 0.0, nHeight = 0.0;
|
|
nSill = _tstof(dlg.g_szStoolHeight);
|
|
nHeight = _tstof(dlg.g_szWinHeight);
|
|
// 对话框被挪动到最下边释放,因为还需要计算编号
|
|
//dlg.DestroyWindow();
|
|
|
|
BOOL bHas3D=TRUE;
|
|
DList<AcDbObjectId> idMidWalls;
|
|
AcDbObjectId idStart,idEnd;
|
|
int nWallCount=int(ssWalls.Length());
|
|
for (long i=0; i<nWallCount; i++) {
|
|
Entity idWall=ssWalls[long(i)];
|
|
AcDbObjectId objectId;
|
|
acdbGetObjectId(objectId,idWall);
|
|
|
|
XDbObject objWall(idWall, AcDb::kForRead);
|
|
if (!objWall) continue;
|
|
TDbWall *pWall=TDbWall::cast(objWall.m_pObject);
|
|
XPoly2D poly(1), poly1(1);
|
|
pWall->GetOutlinePoly(ptStart.z, poly);
|
|
if (!pWall->Has3D())
|
|
bHas3D=FALSE;
|
|
|
|
double nDevation= (poly.PathArea()<0.0)? (_DIST_SNAP*2) : -(_DIST_SNAP*2);
|
|
poly.Offset(nDevation, poly1);
|
|
bool bTerm=false;
|
|
if ((ptStart&poly1) != PR_OUTSIDE)
|
|
{
|
|
if (!!eStart) {
|
|
adsout << /*UMSG*/ _T("\n起点处发现不止一段墙, 不能完成带形窗!");
|
|
return;
|
|
}
|
|
eStart=idWall;
|
|
idStart=objectId;
|
|
bTerm=true;
|
|
}
|
|
if ((ptEnd&poly1) != PR_OUTSIDE)
|
|
{
|
|
if (!!eEnd) {
|
|
adsout << /*UMSG*/ _T("\n终点处发现不止一段墙, 不能完成带形窗!");
|
|
return;
|
|
}
|
|
eEnd=idWall;
|
|
idEnd=objectId;
|
|
bTerm=true;
|
|
}
|
|
|
|
if (!bTerm)
|
|
idMidWalls.Append(new AcDbObjectId(objectId));
|
|
}
|
|
|
|
if (!eStart) {
|
|
adsout << /*UMSG*/ _T("\n找不到起点处的墙!");
|
|
return;
|
|
}
|
|
if (!eEnd) {
|
|
adsout << /*UMSG*/ _T("\n找不到终点处的墙!");
|
|
return;
|
|
}
|
|
if (eStart==eEnd)
|
|
{
|
|
XCurveSegment seg, segBase;
|
|
OPENOBJ_BEGIN(eStart, AcDb::kForRead, TDbWall, pWall);
|
|
ASSERT(pWall);
|
|
segBase = *pWall;
|
|
seg=pWall->OffsetGeomCenter(LS_INFINITE, TRUE);
|
|
seg.ProjectToMe(XPoint(ptStart), ptStart);
|
|
seg.ProjectToMe(XPoint(ptEnd), ptEnd);
|
|
seg.SetPoints(ptStart, ptEnd);
|
|
segBase.ProjectToMe(XPoint(ptStart), ptStart);
|
|
segBase.ProjectToMe(XPoint(ptEnd), ptEnd);
|
|
if (!segBase.Is(CURVE_LINE)&&//弧段
|
|
segBase.PathDistance(ptStart)>segBase.PathDistance(ptEnd))
|
|
segBase.SetPoints(ptEnd,ptStart);
|
|
else
|
|
segBase.SetPoints(ptStart,ptEnd);
|
|
OPENOBJ_END();
|
|
|
|
BOOL bWarn=g_bEnableCornWinWarning;
|
|
g_bEnableCornWinWarning=FALSE;
|
|
XPoint ptMid0=segBase.MidPoint();
|
|
XPoint ptMid;
|
|
seg.ProjectToMe(ptMid0, ptMid);
|
|
ptMid.z = bHas3D? nSill : 0.0;
|
|
TDbOpening *pOpening= new TDbOpening;
|
|
pOpening->m_ptLocation = ptMid;
|
|
pOpening->SetWidth(segBase.GetLength());
|
|
pOpening->SetHeight(bHas3D? nHeight : 0.0);
|
|
pOpening->SetKind(TOpeningData::OP_CORNWIN);
|
|
|
|
// 设定编号位置
|
|
ads_polar(ptMid, seg.Direction(ptMid)-PI/2.0, 600.0*_UNIT_SCALE, pOpening->m_ptLabel);
|
|
pOpening->m_ptLabel.z = 0;
|
|
pOpening->InitHardPointerId();
|
|
|
|
// add by xly on 110125 设置门窗对象的转角布局
|
|
pOpening->SetLayoutRotation(Ucs2Wcs(0));
|
|
// add by lgh on 110317
|
|
pOpening->SetLabel(dlg.GetLabelOpBan(pOpening));
|
|
// add by xly on 110316 设置窗户的墙体关系,和门窗编号
|
|
pOpening->SetWallId(idStart);
|
|
pOpening->AddToMSpace(Adesk::kTrue);
|
|
|
|
TArchCmdReactor::UpdateOpenings();
|
|
TArchCmdReactor::ResetAll();
|
|
g_bEnableCornWinWarning=bWarn;
|
|
|
|
//adsout << _T("\n起点和终点都在同一墙段上, 没有转角!");
|
|
return;
|
|
}
|
|
|
|
|
|
TDbBandWin *pWin=new TDbBandWin;
|
|
pWin->SetHeight(nHeight);
|
|
pWin->SetElevation(nSill);
|
|
pWin->SetLayerGlass3d(InitLayer(LAY_3DGLASS, FALSE));
|
|
pWin->SetLayerFrame3d(InitLayer(LAY_3DFRAME, FALSE));
|
|
pWin->SetLayerSlab3d(InitLayer(LAY_WALL, FALSE));
|
|
pWin->SetLayerText(InitLayer(LAY_OPENING_DIM, FALSE));
|
|
pWin->SetTextStyle(InitTextStyle(TS_WINDOW));
|
|
pWin->SetStartPoint(ptStart);
|
|
pWin->SetEndPoint(ptEnd);
|
|
pWin->SetWallId(0,idStart);
|
|
pWin->SetWallId(1,idEnd);
|
|
pWin->SetMidWallIds(idMidWalls);
|
|
// pWin->SetLabel(CBanOpeningDlg::g_szNumber);
|
|
pWin->SetLabelPos(pWin->GetDefaultLabPos());
|
|
if (!pWin->UpdateParameters())
|
|
{
|
|
adsout<<_T("\n未能生成带形窗!");
|
|
delete pWin;
|
|
return;
|
|
}
|
|
pWin->UpdateLabelPos();
|
|
// modified by lgh 101130 .新需求
|
|
pWin->SetLabel(dlg.GetLabel(pWin));
|
|
|
|
// add by xly on 110125 设置门窗对象的转角布局,必须在UpdateLabelPos函数之前设置,保证文字转角的正确
|
|
pWin->SetLayoutRotation(Ucs2Wcs(0));
|
|
|
|
pWin->UpdateLabelPos();
|
|
|
|
AcDbObjectId idWin=pWin->AddToMSpace(Adesk::kTrue);
|
|
dlg.AfterModelAdded(pWin);
|
|
for (i=0;i<ssWalls.Length();i++)
|
|
{
|
|
Entity ent=ssWalls[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall)
|
|
pWall->AddOpeningId(idWin);
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
//void BanOpening()
|
|
//{
|
|
// XPoint ptStart, ptEnd;
|
|
// if (XGetPoint(NULL, _T("\n起始点"), ptStart)!=RTNORM ||
|
|
// XGetPoint(NULL, _T("\n终止点"), ptEnd)!=RTNORM)
|
|
// return;
|
|
//
|
|
//
|
|
// PickSet ssWalls(SS_FREE);
|
|
// if (SelectEntities(_T("\n选择带形窗经过的墙:"),ssWalls, RBList(RTDXF0, _T("TCH_WALL"), NULL))!=RTNORM)
|
|
// return;
|
|
//
|
|
// XPoly2D poly;
|
|
// SearchWallSide(ptStart,ptEnd,ssWalls,poly);
|
|
// poly.Make();
|
|
//}
|
|
|
|
// 指定墙外侧
|
|
//void MarkExtWall()
|
|
//{
|
|
// Entity ent;
|
|
// XPoint ptLoc;
|
|
// double drt;
|
|
// XScreenDc dc(1,1);
|
|
// while(SelectWallSide(ent, ptLoc, &drt)==RTNORM) {
|
|
// XCurveSegment segHighlight;
|
|
// OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
// if (pWall) {
|
|
// XCurveSegment segCenter=pWall->OffsetGeomCenter();
|
|
// int nSide=segCenter.OnWhichSide(ptLoc);
|
|
// int nFlag=pWall->GetWallFlag();
|
|
// nFlag |= WF_EXTERNAL;
|
|
// XCurveSegment lCurve, rCurve;
|
|
// pWall->GetSideCurve(lCurve, rCurve);
|
|
// if (nSide==OFFSET_LEFT) {
|
|
// nFlag |= WF_LEFTEXT;
|
|
// segHighlight=lCurve;
|
|
// } else {
|
|
// nFlag &= ~WF_LEFTEXT;
|
|
// segHighlight=rCurve;
|
|
// }
|
|
// pWall->assertWriteEnabled();
|
|
// pWall->SetWallFlag(nFlag);
|
|
// }
|
|
// OPENOBJ_END();
|
|
// segHighlight.StartPoint()=Wcs2Ucs(segHighlight.StartPoint());
|
|
// segHighlight.EndPoint()=Wcs2Ucs(segHighlight.EndPoint());
|
|
// if (!!segHighlight)
|
|
// dc << segHighlight;
|
|
// }
|
|
//}
|
|
//modified by whl
|
|
int SelectWallSide1(Entity &entWall, XPoint & loc, ads_real *drt)
|
|
{
|
|
int nOldOsnap=g_nOsnapType;
|
|
DocSetWallOsnapType(1);
|
|
Entity ent;
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
XPoint ptPick;
|
|
int nRetCode=RTNORM;
|
|
if ((nRetCode=SelectEntity1(_T("\n请点取墙体外皮<退出>: "), ent, ptPick, mask))!=RTNORM) {
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
return nRetCode;
|
|
}
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
ptPick=Ucs2Wcs(ptPick);
|
|
|
|
XDbObject obj(ent, AcDb::kForWrite);
|
|
if (!obj) return RTERROR;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (!pWall)
|
|
return RTERROR;
|
|
|
|
TDbWall &wall = *pWall;
|
|
|
|
XCurveSegment lCurve, rCurve, selCurve;
|
|
wall.GetSideCurve(lCurve, rCurve);
|
|
XPoint ptLeft, ptRight; //在左右两侧的投影
|
|
if (lCurve.ProjectToMe(ptPick, ptLeft)!=RTNORM ||
|
|
rCurve.ProjectToMe(ptPick, ptRight)!=RTNORM)
|
|
return RTERROR;
|
|
|
|
if (ptPick.Distance(ptLeft)<ptPick.Distance(ptRight))
|
|
selCurve=lCurve;
|
|
else selCurve=rCurve;
|
|
|
|
XCurveSegment segCen=wall.OffsetGeomCenter();
|
|
XPoint ptOnCen, ptOnSide;
|
|
if (segCen.ProjectToMe(ptPick, ptOnCen)!=RTNORM ||
|
|
selCurve.ProjectToMe(ptPick, ptOnSide)!=RTNORM) {
|
|
adsout << _T("\n请正确点取!");
|
|
return RTERROR;
|
|
}
|
|
ads_real nOrthDrt=ads_angle(ptOnCen, ptOnSide);
|
|
*drt=CT_std_angle(nOrthDrt+PI/2.0);
|
|
loc = ptOnSide;
|
|
entWall = ent;
|
|
return RTNORM;
|
|
}
|
|
void MarkExtWall()
|
|
{
|
|
Entity ent;
|
|
XPoint ptLoc;
|
|
double drt;
|
|
XScreenDc dc(1,1);
|
|
while(SelectWallSide1(ent, ptLoc, &drt)==RTNORM) {
|
|
XCurveSegment segHighlight;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
XCurveSegment segCenter=pWall->OffsetGeomCenter();
|
|
int nSide=segCenter.OnWhichSide(ptLoc);
|
|
XCurveSegment lCurve, rCurve;
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetExternal(TRUE);
|
|
if (nSide==OFFSET_LEFT)
|
|
{
|
|
pWall->SetExternal(0,true);
|
|
pWall->SetExternal(1,false);
|
|
segHighlight=lCurve;
|
|
}
|
|
else
|
|
{
|
|
pWall->SetExternal(1,true);
|
|
pWall->SetExternal(0,false);
|
|
segHighlight=rCurve;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
segHighlight.StartPoint()=Wcs2Ucs(segHighlight.StartPoint());
|
|
segHighlight.EndPoint()=Wcs2Ucs(segHighlight.EndPoint());
|
|
if (!!segHighlight)
|
|
dc << segHighlight;
|
|
}
|
|
}
|
|
|
|
|
|
// 指定墙内侧
|
|
void MarkIntWall()
|
|
{
|
|
PickSet ss(SS_FREE);
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
if (SelectEntities(_T("\n选择墙体: "), ss, mask)==RTNORM) {
|
|
long lCount=ss.Length();
|
|
for (long i=0L; i<lCount; i++) {
|
|
Entity ent=ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbWall, pWall);
|
|
if (pWall) {
|
|
int nFlag=pWall->GetWallFlag();
|
|
nFlag &= ~WF_EXTERNAL;
|
|
nFlag &= ~WF_LEFTEXT;
|
|
nFlag &= ~WF_RIGHTEXT;//add by whl
|
|
pWall->assertWriteEnabled();
|
|
pWall->SetWallFlag(nFlag);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
extern int SendAcadCommand(const TCHAR *pszCmd);
|
|
|
|
|
|
/////////////////////////////////////
|
|
// 编辑墙体
|
|
//int EditWall(AcDbObjectId idWall)
|
|
//{
|
|
// OPENOBJ_BEGIN(idWall, AcDb::kForRead, TDbWall, pWall);
|
|
// if (!pWall)
|
|
// return RTERROR;
|
|
//
|
|
// int nLeftColor=3, nRightColor=6;
|
|
// XScreenDc dc(nLeftColor);
|
|
// XCurveSegment lCurve0, rCurve0;
|
|
// pWall->GetSideCurve(lCurve0, rCurve0);
|
|
// lCurve0.StartPoint() = Wcs2Ucs(lCurve0.StartPoint());
|
|
// lCurve0.EndPoint() = Wcs2Ucs(lCurve0.EndPoint());
|
|
// rCurve0.StartPoint() = Wcs2Ucs(rCurve0.StartPoint());
|
|
// rCurve0.EndPoint() = Wcs2Ucs(rCurve0.EndPoint());
|
|
//
|
|
// dc << lCurve0;
|
|
// dc.m_nFrontColor = nRightColor;
|
|
// dc << rCurve0;
|
|
// acedUpdateDisplay();
|
|
//
|
|
//
|
|
// CAcModuleResourceOverride vTemp;
|
|
// CWallDlg dlg(*pWall, CWnd::FromHandle(adsw_acadMainWnd()));
|
|
// if (dlg.DoModal()==IDOK) {
|
|
// if (pWall->upgradeOpen()!=Acad::eOk)
|
|
// return RTERROR;
|
|
//
|
|
// pWall->assertWriteEnabled();
|
|
// if (pWall->Is(CURVE_ARC)) { //改变半径
|
|
// double nChordLen=pWall->XLine::Length();
|
|
// if (nChordLen<2.0*_tstof(dlg.m_csRadius)-1.0E-6) {
|
|
// BOOL bOverPi=(pWall->GetBulge()>PI);
|
|
// double nAng=2.0*asin(nChordLen/2.0/_tstof(dlg.m_csRadius));
|
|
// if (!bOverPi) pWall->GetBulge()=nAng;
|
|
// else pWall->GetBulge()=2*PI-nAng;
|
|
// }
|
|
// }
|
|
//
|
|
// pWall->ChangeElevation(_tstof(dlg.m_csElevation), FALSE);
|
|
// pWall->SetHeight(_tstof(dlg.m_csWallHeight));
|
|
// pWall->SetWidth(0, _tstof(dlg.m_csLeftWidth));
|
|
// pWall->SetWidth(1, _tstof(dlg.m_csRightWidth));
|
|
//
|
|
// TWallData::TWallStyle st=pWall->GetStyle();
|
|
// switch(dlg.m_nStyle) {
|
|
// case 0: st=TWallData::kDivider; break;
|
|
// case 1: st=TWallData::kCurtain; break;
|
|
// case 2: st=TWallData::kFill; break;
|
|
// case 3: st=TWallData::kBrick; break;
|
|
// case 4: st=TWallData::kRocket; break;
|
|
// case 5: st=TWallData::kConcrete; break;
|
|
// }
|
|
//
|
|
// pWall->SetStyle(st);
|
|
// pWall->RelocateOpening();
|
|
//
|
|
// VERIFY(pWall->downgradeOpen()==Acad::eOk);
|
|
// }
|
|
//
|
|
// ads_redraw(NULL, 0);
|
|
// OPENOBJ_END();
|
|
// return RTNORM;
|
|
//}
|
|
|
|
// modified by fxj
|
|
int EditWall(AcDbObjectId idWall)
|
|
{
|
|
// 20090610 zzg 选择示意幕墙时候直接用幕墙对象替换掉墙对象
|
|
int nRet = RTNORM;
|
|
AcDbEntity *pEnt = NULL;
|
|
Acad::ErrorStatus es;
|
|
es = acdbOpenAcDbEntity(pEnt,idWall,AcDb::kForWrite);
|
|
if (es == Acad::eOk)
|
|
{
|
|
BOOL bErase = FALSE;
|
|
TDbWall *pWall = TDbWall::cast(pEnt);
|
|
if (pWall)//是墙体
|
|
{
|
|
// add by xly on 110410 判断墙体是否在默认图层
|
|
CString csLayer = pWall->layer();
|
|
bool bIsSameLayer(true);
|
|
|
|
if (csLayer != pWall->GetDefaultLayer())
|
|
{
|
|
bIsSameLayer = false;
|
|
}
|
|
|
|
int nLeftColor=3, nRightColor=6;
|
|
XScreenDc dc(nLeftColor);
|
|
XCurveSegment lCurve0, rCurve0;
|
|
pWall->GetSideCurve(lCurve0, rCurve0);
|
|
lCurve0.StartPoint() = Wcs2Ucs(lCurve0.StartPoint());
|
|
lCurve0.EndPoint() = Wcs2Ucs(lCurve0.EndPoint());
|
|
rCurve0.StartPoint() = Wcs2Ucs(rCurve0.StartPoint());
|
|
rCurve0.EndPoint() = Wcs2Ucs(rCurve0.EndPoint());
|
|
dc << lCurve0;
|
|
dc.m_nFrontColor = nRightColor;
|
|
dc << rCurve0;
|
|
acedUpdateDisplay();
|
|
|
|
CWallDlg dlg(*pWall,acedGetAcadFrame());
|
|
CAcModuleResourceOverride vTemp;
|
|
BOOL bOldShowBase=DocGetShowBase();
|
|
DocSetShowBase(TRUE);//add by fxj
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
pWall->assertWriteEnabled();
|
|
AcDbObjectId idSurf = pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
// [2010-3-24 wubo] 移除“示意幕墙”选项
|
|
// if (dlg.m_nStyle == 8)
|
|
if (dlg.m_nStyle == 10)
|
|
{
|
|
// modify by xly on 101029 墙体编辑命令中将墙体材料修改为“玻璃幕墙”本段代码与单线变墙中Wall2Curtain功能一致替换掉
|
|
//// 幕墙
|
|
//TDbWall *pCWall = NULL;
|
|
//AcDbCurve *pCv = pWall->GetAcDbCurve(0);
|
|
//if (pCv)
|
|
//{
|
|
// pCWall = (TDbWall*)TDbCurtainWall::desc()->create();
|
|
// if (pCWall)
|
|
// {
|
|
// DList<AcDbSoftPointerId> listBindWinid,idlist;
|
|
|
|
// // delete by xly on 101013 没有用到
|
|
// //int n = pWall->GetPatchIdList().Length();
|
|
// //int n1 = pWall->GetOpeningIdList().Length();
|
|
|
|
// pCWall->SetFromCurve((*pCv));
|
|
// pCWall->copyFrom(pWall);
|
|
// int i=0;
|
|
// for (i=0;i<pWall->GetOpeningIdList().Length();i++)
|
|
// {
|
|
// AcDbSoftPointerId id = pWall->GetOpeningIdList()[i];
|
|
// AcDbEntity *pent = NULL;
|
|
// Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForRead);
|
|
// if (pent)
|
|
// {
|
|
// if (pent->isKindOf(TDbBandWin::desc()))
|
|
// {
|
|
// TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
// if (pBandWin)
|
|
// {
|
|
// long nNum = pBandWin->GetWallNum();
|
|
// int j=0;
|
|
// for (j=0;j<nNum;j++)
|
|
// {
|
|
// AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
// if (idTem == pWall->objectId())
|
|
// {
|
|
// //pBandWin->SetWallId(j,0);
|
|
// pWall->RemoveReferenceOpening(id);
|
|
// i--;
|
|
// }
|
|
// }
|
|
// }
|
|
// listBindWinid.Append(&id);
|
|
// }
|
|
// pent->close();
|
|
// }
|
|
// }
|
|
// pWall->MoveOpeningTo(*pCWall);
|
|
// pWall->MovePatchTo(*pCWall);
|
|
// dlg.Dlg2Obj(pCWall);
|
|
// TDbCurtainWall *pCurtinWall = (TDbCurtainWall*)pCWall;
|
|
// pCurtinWall->SetLayerGlass3d(InitLayer(LAY_3DGLASS));
|
|
// pCurtinWall->SetLayerCol3d(InitLayer(LAY_3DFRAME));
|
|
// pCurtinWall->SetLayerRow3d(InitLayer(LAY_3DFRAME));
|
|
// AcDbObjectId idNew,idOld;
|
|
// idOld = pWall->objectId();
|
|
|
|
// // add by xly on 101013修改当有普通墙体通过对象编辑转化为玻璃膜墙的时候,玻璃幕墙外观变为示意幕墙
|
|
// pCurtinWall->SetSimple2D(TRUE);
|
|
|
|
// idNew = pCurtinWall->AddToMSpace(Adesk::kTrue);
|
|
// for (i=0;i<listBindWinid.Length();i++)
|
|
// {
|
|
// AcDbSoftPointerId id = *listBindWinid[i];
|
|
// AcDbEntity *pent = NULL;
|
|
// Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForWrite);
|
|
// if (pent)
|
|
// {
|
|
// TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
// if (pBandWin)
|
|
// {
|
|
// long nNum = pBandWin->GetWallNum();
|
|
// int j=0;
|
|
// for (j=0;j<nNum;j++)
|
|
// {
|
|
// AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
// if (idTem == idOld)
|
|
// {
|
|
// pBandWin->SetWallId(j,idNew);
|
|
// }
|
|
// }
|
|
// }
|
|
// pent->close();
|
|
// }
|
|
// }
|
|
// bErase = TRUE;
|
|
// }
|
|
//}
|
|
pEnt->close();
|
|
PickSet ss(SS_FREE);
|
|
if (idWall.isValid())
|
|
{
|
|
ss+= idWall;
|
|
Entity ent = ss[(long)0];
|
|
|
|
// modify by xly on 110410 修改墙体属性时,判断墙体的图层是否在默认图层
|
|
//// 将普通墙体转化为玻璃幕墙
|
|
//Wall2Curtain(ent);
|
|
if (!bIsSameLayer)
|
|
{
|
|
Wall2Curtain(ent,csLayer);
|
|
}
|
|
else
|
|
{
|
|
Wall2Curtain(ent);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else // 普通墙
|
|
{
|
|
dlg.Dlg2Obj(pWall);
|
|
|
|
// sg add 100514,根据8.5需求,修改材料后,修改图层
|
|
pWall->setLayer(InitLayer(pWall->GetDefaultLayer()));
|
|
}
|
|
|
|
if (bErase)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
}
|
|
else
|
|
{
|
|
pWall->RelocateOpening();
|
|
}
|
|
// add by xly on 110410 修改墙体属性时,判断墙体的图层是否在默认图层
|
|
if (!bIsSameLayer)
|
|
{
|
|
if (dlg.m_nStyle != 10)
|
|
{
|
|
pWall->setLayer(csLayer);
|
|
}
|
|
}
|
|
}
|
|
DocSetShowBase(bOldShowBase);
|
|
ads_redraw(NULL, 0);
|
|
}
|
|
else
|
|
{
|
|
nRet = RTERROR;
|
|
}
|
|
|
|
if (!bErase)
|
|
{
|
|
pEnt->close();
|
|
}
|
|
}
|
|
return nRet;
|
|
|
|
/*
|
|
OPENOBJ_BEGIN(idWall, AcDb::kForRead, TDbWall, pWall);
|
|
if (!pWall)
|
|
return RTERROR;
|
|
int nLeftColor=3, nRightColor=6;
|
|
XScreenDc dc(nLeftColor);
|
|
XCurveSegment lCurve0, rCurve0;
|
|
pWall->GetSideCurve(lCurve0, rCurve0);
|
|
lCurve0.startPoint = Wcs2Ucs(lCurve0.startPoint);
|
|
lCurve0.EndPoint() = Wcs2Ucs(lCurve0.EndPoint());
|
|
rCurve0.startPoint = Wcs2Ucs(rCurve0.startPoint);
|
|
rCurve0.EndPoint() = Wcs2Ucs(rCurve0.EndPoint());
|
|
dc << lCurve0;
|
|
dc.m_nFrontColor = nRightColor;
|
|
dc << rCurve0;
|
|
acedUpdateDisplay();
|
|
CWallDlg dlg(*pWall,acedGetAcadFrame());
|
|
CAcModuleResourceOverride vTemp;
|
|
BOOL bOldShowBase=DocGetShowBase();
|
|
DocSetShowBase(TRUE);//add by fxj
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
|
|
if (pWall->upgradeOpen()!=Acad::eOk)
|
|
return RTERROR;
|
|
pWall->assertWriteEnabled();
|
|
AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
dlg.Dlg2Obj(pWall);
|
|
pWall->downgradeOpen();
|
|
pWall->RelocateOpening();
|
|
pWall->close();
|
|
}
|
|
DocSetShowBase(bOldShowBase);
|
|
ads_redraw(NULL, 0);
|
|
OPENOBJ_END();
|
|
return RTNORM;
|
|
*/
|
|
}
|
|
|
|
|
|
// void PartWall()//by fxj 080825
|
|
// {
|
|
// Entity ent;
|
|
// RBList rb(RTDXF0, _T("TCH_WALL"), NULL);
|
|
// while(ent.FilterSelect(_T("\n请选择一段墙 <退出>:"), rb) == RTNORM)
|
|
// {
|
|
// BOOL bContinue=FALSE;
|
|
//
|
|
// OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
//
|
|
//
|
|
// XPoint ptStart, ptEnd;
|
|
// int nOldOsnap = g_nOsnapType;
|
|
// DocSetWallOsnapType(0);
|
|
// int nOsMode=0;
|
|
// xg_getvar(_T("OSMODE"), &nOsMode);
|
|
// nOsMode=0x0001|0x0002|0x0008|0x0020|0x0200;
|
|
// XPushVar<int> osmode(_T("OSMODE"), nOsMode);
|
|
//
|
|
// //临时用不同颜色显示左右墙线 add by fxj 081224
|
|
// int nLeftColor=3, nRightColor=6;
|
|
// XScreenDc dc0(nLeftColor);
|
|
// XCurveSegment lCurve0, rCurve0;
|
|
// pWall->GetSideCurve(lCurve0, rCurve0);
|
|
// AcDbCurve *plCurve0=lCurve0.AsAcDbCurve();
|
|
// plCurve0->setColorIndex(nLeftColor);
|
|
// AcDbCurve *prCurve0=rCurve0.AsAcDbCurve();
|
|
// prCurve0->setColorIndex(nRightColor);
|
|
// AcDbObjectId idlCur0,idrCur0;
|
|
// idlCur0=AddToModelSpace(plCurve0,Adesk::kTrue);
|
|
// idrCur0=AddToModelSpace(prCurve0,Adesk::kTrue);
|
|
// //dc0 << lCurve0;
|
|
// //dc0.m_nFrontColor = nRightColor;
|
|
// //dc0 << rCurve0;
|
|
// // acedUpdateDisplay();
|
|
//
|
|
// // 临时显示基线
|
|
// AcDbCurve *pCurve = pWall->AsAcDbCurve();
|
|
// pCurve->setColorIndex(46);
|
|
// AcDbObjectId idCur;
|
|
// idCur = AddToModelSpace(pCurve, Adesk::kTrue);
|
|
//
|
|
// // 显示分段线
|
|
// XScreenDc dc(1);
|
|
// XCurveSegment lCurve, rCurve;
|
|
// pWall->GetSideCurve(lCurve, rCurve);
|
|
//
|
|
// // 门窗
|
|
// DList<TOpeningData> lstOpenings;
|
|
// pWall->GetOpenings(lstOpenings, 1);
|
|
//
|
|
// double nElev = pWall->GetElevation();
|
|
// double dLeftWidth = fabs(pWall->GetWidth(0));
|
|
// double dRightWidth = fabs(pWall->GetWidth(1));
|
|
// double dOsnapWidth =dLeftWidth+dRightWidth;
|
|
// XPoint ptProject;
|
|
// // 选择起点
|
|
// while(1)
|
|
// {
|
|
// int nRetB=acedGetPoint(NULL, _T("\n选择起点<返回>: "), ptStart);
|
|
// if ( nRetB!= RTNORM)
|
|
// {
|
|
//
|
|
// acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
// pCurve->erase(Adesk::kTrue);
|
|
// pCurve->close();
|
|
//
|
|
// //去掉临时用不同颜色显示的左右墙线 add by fxj 081224
|
|
// acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
// plCurve0->erase(Adesk::kTrue);
|
|
// plCurve0->close();
|
|
// acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
// prCurve0->erase(Adesk::kTrue);
|
|
// prCurve0->close();
|
|
//
|
|
// DocSetWallOsnapType(nOldOsnap);
|
|
//
|
|
// if (nRetB==RTCAN)
|
|
// {
|
|
// return;
|
|
// }
|
|
//
|
|
// bContinue=TRUE;
|
|
// break;
|
|
// }
|
|
// ptStart = Ucs2Wcs(ptStart);
|
|
// ptStart.z = nElev;
|
|
// if (pWall->ProjectToMe(ptStart, ptProject) != RTNORM)
|
|
// {
|
|
// acutPrintf(_T("\n选择点投影超出基线范围,请重新选择起点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在基线延长线上
|
|
// int ret = ptProject & (*pWall);
|
|
// if (ret != 1 && ret != 2 && ret != 3)
|
|
// {
|
|
// acutPrintf(_T("\n选择点投影超出基线范围,请重新选择起点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在基线附近
|
|
// if (ptStart.Distance2d(ptProject) > dOsnapWidth)
|
|
// {
|
|
// acutPrintf(_T("\n选择点距离基线太远,请重新选择起点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在门窗处
|
|
// int len = lstOpenings.Length();
|
|
// if (len == 0) break; // 无门窗
|
|
// for (long i=0; i<len; i++)
|
|
// {
|
|
// XPoly2D poly;
|
|
// XCurveSegment seg;
|
|
// lstOpenings[i]->GetOutlinePoly(nElev, poly);
|
|
// poly.Nth(1, seg);
|
|
// XPoint temPt;
|
|
// seg.ProjectToMe(ptProject, temPt);
|
|
// int iOpen = temPt & seg;
|
|
// if (iOpen == 3)
|
|
// {
|
|
// acutPrintf(_T("\n选择点不能投影在门窗处,请重新选择起点!"));
|
|
// break;
|
|
// }
|
|
// }
|
|
// if (i == len) break; // 选择点未落在门窗上
|
|
// }
|
|
// if (bContinue)
|
|
// continue;
|
|
// ptStart = ptProject;
|
|
// // XPoint ptStartTemp = Wcs2Ucs(ptStart);
|
|
// // acutPrintf(_T("(%s,%s)"), Dist2Str(ptStartTemp.x), Dist2Str(ptStartTemp.y));//delete 090216
|
|
// XPoint ptLStart, ptLEnd;
|
|
// lCurve.ProjectToMe(ptStart, ptLStart);
|
|
// rCurve.ProjectToMe(ptStart, ptLEnd);
|
|
//
|
|
// AcDbLine *plineL = new AcDbLine(ptLStart, ptLEnd);
|
|
// plineL->setColorIndex(1);
|
|
// AcDbObjectId idL;
|
|
// idL = AddToModelSpace(plineL, Adesk::kTrue);
|
|
//
|
|
// // 选择终点
|
|
// while(1)
|
|
// {
|
|
// int nRetE=acedGetPoint(Wcs2Ucs(ptStart), _T("\n选择终点<返回>: "), ptEnd);
|
|
// if ( nRetE!= RTNORM)
|
|
// {
|
|
// acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
// pCurve->erase(Adesk::kTrue);
|
|
// pCurve->close();
|
|
//
|
|
// //去掉临时用不同颜色显示的左右墙线 add by fxj 081224
|
|
// acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
// plCurve0->erase(Adesk::kTrue);
|
|
// plCurve0->close();
|
|
// acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
// prCurve0->erase(Adesk::kTrue);
|
|
// prCurve0->close();
|
|
//
|
|
// acdbOpenObject(plineL, idL, AcDb::kForWrite);
|
|
// plineL->erase(Adesk::kTrue);
|
|
// plineL->close();
|
|
//
|
|
// DocSetWallOsnapType(nOldOsnap);
|
|
//
|
|
// if (nRetE==RTCAN)
|
|
// {
|
|
// return;
|
|
// }
|
|
// bContinue=TRUE;
|
|
// break;
|
|
// }
|
|
// ptEnd = Ucs2Wcs(ptEnd);
|
|
// ptEnd.z = nElev;
|
|
// if (pWall->ProjectToMe(ptEnd, ptProject) != RTNORM)
|
|
// {
|
|
// acutPrintf(_T("\n选择点投影超出基线范围,请重新选择终点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断与开始点距离
|
|
// if (ptStart.Distance2d(ptProject) < 1.0E-6)
|
|
// {
|
|
// acutPrintf(_T("\n选择点与起点距离太小,请重新选择终点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在基线延长线上
|
|
// int ret = ptProject & (*pWall);
|
|
// if (ret != 1 && ret != 2 && ret != 3)
|
|
// {
|
|
// acutPrintf(_T("\n选择点投影超出基线范围,请重新选择终点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在基线附近
|
|
// if (ptEnd.Distance2d(ptProject) > dOsnapWidth)
|
|
// {
|
|
// acutPrintf(_T("\n选择点距离基线太远,请重新选择终点!"));
|
|
// continue;
|
|
// }
|
|
//
|
|
// // 判断点是否在门窗处
|
|
// int len = lstOpenings.Length();
|
|
// if (len == 0) break; // 无门窗
|
|
// for (long i=0; i<lstOpenings.Length(); i++)
|
|
// {
|
|
// XPoly2D poly;
|
|
// XCurveSegment seg;
|
|
// lstOpenings[i]->GetOutlinePoly(nElev, poly);
|
|
// poly.Nth(1, seg);
|
|
// XPoint temPt;
|
|
// seg.ProjectToMe(ptProject, temPt);
|
|
// int iOpen = temPt & seg;
|
|
// if (iOpen == 3)
|
|
// {
|
|
// acutPrintf(_T("\n选择点不能投影在门窗处,请重新选择终点!"));
|
|
// break;
|
|
// }
|
|
// }
|
|
// if (i == len) break; // 选择点未落在门窗上
|
|
// }
|
|
//
|
|
// if (bContinue)
|
|
// continue;
|
|
// ptEnd = ptProject;
|
|
// // XPoint ptEndTemp = Wcs2Ucs(ptEnd);
|
|
// // acutPrintf(_T("(%s,%s)\n"), Dist2Str(ptEndTemp.x), Dist2Str(ptEndTemp.y));
|
|
// XPoint ptRStart, ptREnd;
|
|
// lCurve.ProjectToMe(ptEnd, ptRStart);
|
|
// rCurve.ProjectToMe(ptEnd, ptREnd);
|
|
//
|
|
// AcDbLine *plineR = new AcDbLine(ptRStart, ptREnd);
|
|
// plineR->setColorIndex(1);
|
|
// AcDbObjectId idR;
|
|
// idR = AddToModelSpace(plineR, Adesk::kTrue);
|
|
//
|
|
// //add by fxj 090108强制刷新
|
|
// actrTransactionManager->flushGraphics();
|
|
// acedUpdateDisplay();
|
|
//
|
|
// acedCommand(RTSTR, _T(""), RTSTR, _T(""), RTNONE);
|
|
//
|
|
// // 调整打断点顺序与墙体一致
|
|
// XPoint startPoint = pWall->StartPoint();
|
|
// double disStart = ptStart.Distance(startPoint);
|
|
// double disEnd = ptEnd.Distance(startPoint);
|
|
// XPoint ptStartBreak,ptEndBreak;
|
|
// if (disStart < disEnd)
|
|
// {
|
|
// ptStartBreak = ptStart;
|
|
// ptEndBreak = ptEnd;
|
|
// }
|
|
// else
|
|
// {
|
|
// ptStartBreak = ptEnd;
|
|
// ptEndBreak = ptStart;
|
|
// }
|
|
//
|
|
// //去掉临时用不同颜色显示的左右墙线 add by fxj 081224
|
|
// acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
// plCurve0->erase(Adesk::kTrue);
|
|
// plCurve0->close();
|
|
// acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
// prCurve0->erase(Adesk::kTrue);
|
|
// prCurve0->close();
|
|
//
|
|
// acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
// pCurve->erase(Adesk::kTrue);
|
|
// pCurve->close();
|
|
// acdbOpenObject(plineL, idL, AcDb::kForWrite);
|
|
// plineL->erase(Adesk::kTrue);
|
|
// plineL->close();
|
|
// acdbOpenObject(plineR, idR, AcDb::kForWrite);
|
|
// plineR->erase(Adesk::kTrue);
|
|
// plineR->close();
|
|
//
|
|
// DocSetWallOsnapType(nOldOsnap);
|
|
//
|
|
// ///////////////////////////////////
|
|
//
|
|
// if (pWall->upgradeOpen()!=Acad::eOk)
|
|
// return;
|
|
// pWall->assertWriteEnabled();
|
|
// TDbWall* pNewWall = NULL;
|
|
// // 用第一点打断墙体
|
|
// double disSta = (pWall->StartPoint()).Distance(ptStartBreak);
|
|
// if (disSta > 1.0E-6)
|
|
// {
|
|
// AcDbObjectId idNewWall;
|
|
// if (pWall->BreakAt(ptStartBreak, idNewWall) != Adesk::kTrue)
|
|
// {
|
|
// acutPrintf(_T("\n打断墙体失败!"));
|
|
// pWall->close();
|
|
// continue ;
|
|
// }
|
|
//
|
|
// if (acdbOpenObject(pNewWall, idNewWall, AcDb::kForWrite) != Acad::eOk)
|
|
// {
|
|
// acutPrintf(_T("\n打开新墙体失败!"));
|
|
// continue ;
|
|
// }
|
|
// }
|
|
// else
|
|
// pNewWall = pWall;
|
|
//
|
|
// // 用第二点打断墙体
|
|
// disEnd = (pNewWall->EndPoint()).Distance(ptEndBreak);
|
|
// if (disEnd > 1.0E-6)
|
|
// {
|
|
// if (pNewWall->BreakAt(ptEndBreak, AcDbObjectId()) != Adesk::kTrue)
|
|
// {
|
|
// acutPrintf(_T("\n打断墙体失败!"));
|
|
// pNewWall->close();
|
|
// continue ;
|
|
// }
|
|
// }
|
|
// // 用pWall代替pNewWall
|
|
// if (pNewWall != pWall)
|
|
// {
|
|
// pWall->close();
|
|
// pWall = pNewWall;
|
|
// }
|
|
//
|
|
//
|
|
// //---------add 080908---
|
|
// CWallDlg dlg(*pWall,acedGetAcadFrame());
|
|
// CAcModuleResourceOverride vTemp;
|
|
// BOOL bOldShowBase=DocGetShowBase();
|
|
// DocSetShowBase(TRUE);
|
|
// BOOL bErase = FALSE;
|
|
// if (dlg.DoModal()==IDOK)
|
|
// {
|
|
//
|
|
// pWall->upgradeOpen();
|
|
// pWall->assertWriteEnabled();
|
|
//
|
|
// AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
// if (!idSurf.isValid())
|
|
// pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));//add 090216
|
|
//
|
|
// //add by xlc on 090706 增加转玻璃幕墙
|
|
// // [2010-3-24 wubo] 移除“示意幕墙”选项
|
|
// // if (dlg.m_nStyle == 8)
|
|
// if (dlg.m_nStyle == 7)
|
|
// {
|
|
// // modify by xly on 101029 将墙体材料修改为“玻璃幕墙”本段代码与单线变墙中Wall2Curtain功能一致替换掉
|
|
// ////幕墙
|
|
// //TDbWall *pCWall = NULL;
|
|
// //AcDbCurve *pCv = pWall->GetAcDbCurve(0);
|
|
// //if (pCv)
|
|
// //{
|
|
// // pCWall = (TDbWall*)TDbCurtainWall::desc()->create();
|
|
// // if (pCWall)
|
|
// // {
|
|
// // DList<AcDbSoftPointerId> listBindWinid,idlist;
|
|
// // int n = pWall->GetPatchIdList().Length();
|
|
// // int n1 = pWall->GetOpeningIdList().Length();
|
|
// // pCWall->SetFromCurve((*pCv));
|
|
// // pCWall->copyFrom(pWall);
|
|
// // int i=0;
|
|
// // for (i=0;i<pWall->GetOpeningIdList().Length();i++)
|
|
// // {
|
|
// // AcDbSoftPointerId id = pWall->GetOpeningIdList()[i];
|
|
// // AcDbEntity *pent = NULL;
|
|
// // Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForRead);
|
|
// // if (pent)
|
|
// // {
|
|
// // if (pent->isKindOf(TDbBandWin::desc()))
|
|
// // {
|
|
// // TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
// // if (pBandWin)
|
|
// // {
|
|
// // long nNum = pBandWin->GetWallNum();
|
|
// // int j=0;
|
|
// // for (j=0;j<nNum;j++)
|
|
// // {
|
|
// // AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
// // if (idTem == pWall->objectId())
|
|
// // {
|
|
// // //pBandWin->SetWallId(j,0);
|
|
// // pWall->RemoveReferenceOpening(id);
|
|
// // i--;
|
|
// // }
|
|
// // }
|
|
// // }
|
|
// // listBindWinid.Append(&id);
|
|
// // }
|
|
// // pent->close();
|
|
// // }
|
|
// // }
|
|
// // pWall->MoveOpeningTo(*pCWall);
|
|
// // pWall->MovePatchTo(*pCWall);
|
|
// // dlg.Dlg2Obj(pCWall);
|
|
// // TDbCurtainWall *pCurtinWall = (TDbCurtainWall*)pCWall;
|
|
// // pCurtinWall->SetLayerGlass3d(InitLayer(LAY_3DGLASS));
|
|
// // pCurtinWall->SetLayerCol3d(InitLayer(LAY_3DFRAME));
|
|
// // pCurtinWall->SetLayerRow3d(InitLayer(LAY_3DFRAME));
|
|
// // AcDbObjectId idNew,idOld;
|
|
// // idOld = pWall->objectId();
|
|
//
|
|
// // // add by xly on 101013 墙体分段时,把普通墙体转化为玻璃幕墙时,玻璃幕墙的外观不正确
|
|
// // pCurtinWall->SetSimple2D(TRUE);
|
|
//
|
|
// // idNew = pCurtinWall->AddToMSpace(Adesk::kTrue);
|
|
// // for (i=0;i<listBindWinid.Length();i++)
|
|
// // {
|
|
// // AcDbSoftPointerId id = *listBindWinid[i];
|
|
// // AcDbEntity *pent = NULL;
|
|
// // Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForWrite);
|
|
// // if (pent)
|
|
// // {
|
|
// // TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
// // if (pBandWin)
|
|
// // {
|
|
// // long nNum = pBandWin->GetWallNum();
|
|
// // int j=0;
|
|
// // for (j=0;j<nNum;j++)
|
|
// // {
|
|
// // AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
// // if (idTem == idOld)
|
|
// // {
|
|
// // pBandWin->SetWallId(j,idNew);
|
|
// // }
|
|
// // }
|
|
// // }
|
|
// // pent->close();
|
|
// // }
|
|
// // }
|
|
// // bErase = TRUE;
|
|
// // }
|
|
// //}
|
|
// pWall->close();
|
|
//
|
|
// // modify by xly on 110223 修改墙体分段时材料变为玻璃幕墙不正确
|
|
// // 将墙体材料变为玻璃幕墙
|
|
// //Wall2Curtain(entTemp);
|
|
// AcDbObjectId idWall = pWall->objectId();
|
|
// PickSet ssTemp(SS_FREE);
|
|
// ssTemp += idWall;
|
|
// if (ssTemp.Length()>0)
|
|
// {
|
|
// Entity entTemp = ssTemp[0L];
|
|
// Wall2Curtain(entTemp);
|
|
// }
|
|
//
|
|
// }
|
|
// else
|
|
// {
|
|
// dlg.Dlg2Obj(pWall);
|
|
//
|
|
// // add by xly on 110304,修改用途后,修改图层
|
|
// pWall->setLayer(InitLayer(pWall->GetDefaultLayer()));
|
|
// }
|
|
//
|
|
// if (bErase)
|
|
// {
|
|
// pWall->erase();
|
|
// pWall->close();
|
|
// }
|
|
// else
|
|
// {
|
|
// pWall->downgradeOpen();
|
|
// pWall->RelocateOpening();
|
|
// }
|
|
// }
|
|
// //---------------------
|
|
//
|
|
// if (!bErase)
|
|
// pWall->close();
|
|
//
|
|
// TArchCmdReactor::UpdateCorners();//add 081124 修墙角
|
|
// TArchCmdReactor::ResetAll();//add 081124
|
|
//
|
|
// ads_redraw(NULL, 0);
|
|
// DocSetShowBase(bOldShowBase);
|
|
// OPENOBJ_END();
|
|
// }
|
|
//
|
|
// }
|
|
|
|
//modify by lgy 20120113 墙体分段命令改为非模式对话框
|
|
void PartWall()
|
|
{
|
|
CWallPartDlg dlg; // 交换数据的对话框对象
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
|
|
if(!dlg.Create(dlg.IDD , acedGetAcadFrame()))
|
|
{
|
|
return ;
|
|
}
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
Entity ent;
|
|
RBList rb(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
|
while(ent.FilterSelect(_T("\n请选择一段墙 <退出>:"), rb) == RTNORM)
|
|
{
|
|
BOOL bContinue=FALSE;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
if (!pWall)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
dlg.SetWallPoint(pWall);
|
|
|
|
XPoint ptStart, ptEnd;
|
|
int nOldOsnap = g_nOsnapType;
|
|
DocSetWallOsnapType(0);
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode=0x0001|0x0002|0x0008|0x0020|0x0200;
|
|
XPushVar<int> osmode(_T("OSMODE"), nOsMode);
|
|
|
|
//临时用不同颜色显示左右墙线
|
|
int nLeftColor=3, nRightColor=6;
|
|
XScreenDc dc0(nLeftColor);
|
|
XCurveSegment lCurve0, rCurve0;
|
|
pWall->GetSideCurve(lCurve0, rCurve0);
|
|
AcDbCurve *plCurve0=lCurve0.AsAcDbCurve();
|
|
plCurve0->setColorIndex(nLeftColor);
|
|
AcDbCurve *prCurve0=rCurve0.AsAcDbCurve();
|
|
prCurve0->setColorIndex(nRightColor);
|
|
AcDbObjectId idlCur0,idrCur0;
|
|
idlCur0=AddToModelSpace(plCurve0,Adesk::kTrue);
|
|
idrCur0=AddToModelSpace(prCurve0,Adesk::kTrue);
|
|
|
|
// 临时显示基线
|
|
AcDbCurve *pCurve = pWall->AsAcDbCurve();
|
|
pCurve->setColorIndex(46);
|
|
AcDbObjectId idCur;
|
|
idCur = AddToModelSpace(pCurve, Adesk::kTrue);
|
|
|
|
// 显示分段线
|
|
XScreenDc dc(1);
|
|
XCurveSegment lCurve, rCurve;
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
|
|
// 门窗
|
|
DList<TOpeningData> lstOpenings;
|
|
pWall->GetOpenings(lstOpenings, 1);
|
|
|
|
double nElev = pWall->GetElevation();
|
|
double dLeftWidth = fabs(pWall->GetWidth(0));
|
|
double dRightWidth = fabs(pWall->GetWidth(1));
|
|
double dOsnapWidth =dLeftWidth+dRightWidth;
|
|
XPoint ptProject;
|
|
// 选择起点
|
|
while(1)
|
|
{
|
|
int nRetB=acedGetPoint(NULL, _T("\n选择起点<返回>: "), ptStart);
|
|
if ( nRetB!= RTNORM)
|
|
{
|
|
|
|
acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
pCurve->erase(Adesk::kTrue);
|
|
pCurve->close();
|
|
|
|
//去掉临时用不同颜色显示的左右墙线
|
|
acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
plCurve0->erase(Adesk::kTrue);
|
|
plCurve0->close();
|
|
acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
prCurve0->erase(Adesk::kTrue);
|
|
prCurve0->close();
|
|
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
|
|
if (nRetB==RTCAN)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
bContinue=TRUE;
|
|
break;
|
|
}
|
|
ptStart = Ucs2Wcs(ptStart);
|
|
ptStart.z = nElev;
|
|
if (pWall->ProjectToMe(ptStart, ptProject) != RTNORM)
|
|
{
|
|
acutPrintf(_T("\n选择点投影超出基线范围,请重新选择起点!"));
|
|
continue;
|
|
}
|
|
|
|
// 判断点是否在基线延长线上
|
|
int ret = ptProject & (*pWall);
|
|
if (ret != 1 && ret != 2 && ret != 3)
|
|
{
|
|
acutPrintf(_T("\n选择点投影超出基线范围,请重新选择起点!"));
|
|
continue;
|
|
}
|
|
|
|
// 判断点是否在基线附近
|
|
if (ptStart.Distance2d(ptProject) > dOsnapWidth)
|
|
{
|
|
acutPrintf(_T("\n选择点距离基线太远,请重新选择起点!"));
|
|
continue;
|
|
}
|
|
|
|
// 判断点是否在门窗处
|
|
int len = lstOpenings.Length();
|
|
if (len == 0)
|
|
break; // 无门窗
|
|
for (long i=0; i<len; i++)
|
|
{
|
|
XPoly2D poly;
|
|
XCurveSegment seg;
|
|
lstOpenings[i]->GetOutlinePoly(nElev, poly);
|
|
poly.Nth(1, seg);
|
|
XPoint temPt;
|
|
seg.ProjectToMe(ptProject, temPt);
|
|
int iOpen = temPt & seg;
|
|
if (iOpen == 3)
|
|
{
|
|
acutPrintf(_T("\n选择点不能投影在门窗处,请重新选择起点!"));
|
|
break;
|
|
}
|
|
}
|
|
if (i == len)
|
|
break; // 选择点未落在门窗上
|
|
}
|
|
if (bContinue)
|
|
continue;
|
|
ptStart = ptProject;
|
|
|
|
XPoint ptLStart, ptLEnd;
|
|
lCurve.ProjectToMe(ptStart, ptLStart);
|
|
rCurve.ProjectToMe(ptStart, ptLEnd);
|
|
|
|
AcDbLine *plineL = new AcDbLine(ptLStart, ptLEnd);
|
|
plineL->setColorIndex(1);
|
|
AcDbObjectId idL;
|
|
idL = AddToModelSpace(plineL, Adesk::kTrue);
|
|
|
|
// 选择终点
|
|
while(1)
|
|
{
|
|
int nRetE=acedGetPoint(Wcs2Ucs(ptStart), _T("\n选择终点<返回>: "), ptEnd);
|
|
if ( nRetE!= RTNORM)
|
|
{
|
|
acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
pCurve->erase(Adesk::kTrue);
|
|
pCurve->close();
|
|
|
|
//去掉临时用不同颜色显示的左右墙线
|
|
acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
plCurve0->erase(Adesk::kTrue);
|
|
plCurve0->close();
|
|
acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
prCurve0->erase(Adesk::kTrue);
|
|
prCurve0->close();
|
|
|
|
acdbOpenObject(plineL, idL, AcDb::kForWrite);
|
|
plineL->erase(Adesk::kTrue);
|
|
plineL->close();
|
|
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
|
|
if (nRetE==RTCAN)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
bContinue=TRUE;
|
|
break;
|
|
}
|
|
ptEnd = Ucs2Wcs(ptEnd);
|
|
ptEnd.z = nElev;
|
|
if (pWall->ProjectToMe(ptEnd, ptProject) != RTNORM)
|
|
{
|
|
acutPrintf(_T("\n选择点投影超出基线范围,请重新选择终点!"));
|
|
continue;
|
|
}
|
|
|
|
// 判断与开始点距离
|
|
if (ptStart.Distance2d(ptProject) < 1.0E-6)
|
|
{
|
|
acutPrintf(_T("\n选择点与起点距离太小,请重新选择终点!"));
|
|
continue;
|
|
}
|
|
|
|
// 判断点是否在基线延长线上
|
|
int ret = ptProject & (*pWall);
|
|
if (ret != 1 && ret != 2 && ret != 3)
|
|
{
|
|
TADSGePoint3d ptWallStart, ptWallEnd;
|
|
pWall->GetStartPoint(ptWallStart);
|
|
pWall->GetEndPoint(ptWallEnd);
|
|
|
|
if (ptEnd.Distance2d(ptWallStart) < ptEnd.Distance2d(ptWallEnd))
|
|
{
|
|
ptProject = ptWallStart;
|
|
}
|
|
else
|
|
{
|
|
ptProject = ptWallEnd;
|
|
}
|
|
}
|
|
|
|
// 判断点是否在门窗处
|
|
int len = lstOpenings.Length();
|
|
if (len == 0) break; // 无门窗
|
|
for (long i=0; i<lstOpenings.Length(); i++)
|
|
{
|
|
XPoly2D poly;
|
|
XCurveSegment seg;
|
|
lstOpenings[i]->GetOutlinePoly(nElev, poly);
|
|
poly.Nth(1, seg);
|
|
XPoint temPt;
|
|
seg.ProjectToMe(ptProject, temPt);
|
|
int iOpen = temPt & seg;
|
|
if (iOpen == 3)
|
|
{
|
|
acutPrintf(_T("\n选择点不能投影在门窗处,请重新选择终点!"));
|
|
break;
|
|
}
|
|
}
|
|
if (i == len) break; // 选择点未落在门窗上
|
|
}
|
|
|
|
if (bContinue)
|
|
continue;
|
|
ptEnd = ptProject;
|
|
|
|
XPoint ptRStart, ptREnd;
|
|
lCurve.ProjectToMe(ptEnd, ptRStart);
|
|
rCurve.ProjectToMe(ptEnd, ptREnd);
|
|
|
|
AcDbLine *plineR = new AcDbLine(ptRStart, ptREnd);
|
|
plineR->setColorIndex(1);
|
|
AcDbObjectId idR;
|
|
idR = AddToModelSpace(plineR, Adesk::kTrue);
|
|
|
|
actrTransactionManager->flushGraphics();
|
|
acedUpdateDisplay();
|
|
|
|
acedCommand(RTSTR, _T(""), RTSTR, _T(""), RTNONE);
|
|
|
|
// 调整打断点顺序与墙体一致
|
|
XPoint startPoint = pWall->StartPoint();
|
|
double disStart = ptStart.Distance(startPoint);
|
|
double disEnd = ptEnd.Distance(startPoint);
|
|
XPoint ptStartBreak,ptEndBreak;
|
|
if (disStart < disEnd)
|
|
{
|
|
ptStartBreak = ptStart;
|
|
ptEndBreak = ptEnd;
|
|
}
|
|
else
|
|
{
|
|
ptStartBreak = ptEnd;
|
|
ptEndBreak = ptStart;
|
|
}
|
|
|
|
//去掉临时用不同颜色显示的左右墙线
|
|
acdbOpenObject(plCurve0,idlCur0,AcDb::kForWrite);
|
|
plCurve0->erase(Adesk::kTrue);
|
|
plCurve0->close();
|
|
acdbOpenObject(prCurve0,idrCur0,AcDb::kForWrite);
|
|
prCurve0->erase(Adesk::kTrue);
|
|
prCurve0->close();
|
|
|
|
acdbOpenObject(pCurve, idCur, AcDb::kForWrite);
|
|
pCurve->erase(Adesk::kTrue);
|
|
pCurve->close();
|
|
acdbOpenObject(plineL, idL, AcDb::kForWrite);
|
|
plineL->erase(Adesk::kTrue);
|
|
plineL->close();
|
|
acdbOpenObject(plineR, idR, AcDb::kForWrite);
|
|
plineR->erase(Adesk::kTrue);
|
|
plineR->close();
|
|
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
|
|
///////////////////////////////////
|
|
|
|
if (pWall->upgradeOpen()!=Acad::eOk)
|
|
return;
|
|
|
|
pWall->assertWriteEnabled();
|
|
TDbWall* pNewWall = NULL;
|
|
// 用第一点打断墙体
|
|
double disSta = (pWall->StartPoint()).Distance(ptStartBreak);
|
|
if (disSta > 1.0E-6)
|
|
{
|
|
AcDbObjectId idNewWall;
|
|
if (pWall->BreakAt(ptStartBreak, idNewWall) != Adesk::kTrue)
|
|
{
|
|
acutPrintf(_T("\n打断墙体失败!"));
|
|
pWall->close();
|
|
continue ;
|
|
}
|
|
|
|
if (acdbOpenObject(pNewWall, idNewWall, AcDb::kForWrite) != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\n打开新墙体失败!"));
|
|
continue ;
|
|
}
|
|
}
|
|
else
|
|
pNewWall = pWall;
|
|
|
|
// 用第二点打断墙体
|
|
disEnd = (pNewWall->EndPoint()).Distance(ptEndBreak);
|
|
if (disEnd > 1.0E-6)
|
|
{
|
|
if (pNewWall->BreakAt(ptEndBreak, AcDbObjectId()) != Adesk::kTrue)
|
|
{
|
|
acutPrintf(_T("\n打断墙体失败!"));
|
|
pNewWall->close();
|
|
continue ;
|
|
}
|
|
}
|
|
// 用pWall代替pNewWall
|
|
if (pNewWall != pWall)
|
|
{
|
|
pWall->close();
|
|
pWall = pNewWall;
|
|
}
|
|
|
|
CAcModuleResourceOverride vTemp;
|
|
BOOL bOldShowBase=DocGetShowBase();
|
|
DocSetShowBase(TRUE);
|
|
|
|
{
|
|
pWall->upgradeOpen();
|
|
pWall->assertWriteEnabled();
|
|
|
|
pWall->Close();
|
|
AcDbObjectId idWall = pWall->objectId();
|
|
PickSet ssTemp(SS_FREE);
|
|
ssTemp += idWall;
|
|
AcDbObjectId id;
|
|
if (ssTemp.Length()>0)
|
|
{
|
|
Entity entTemp = ssTemp[0L];
|
|
id = Curtain2Wall(entTemp);
|
|
if (id != AcDbObjectId::kNull)
|
|
{
|
|
entTemp.Erase();
|
|
}
|
|
else
|
|
{
|
|
id = idWall;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
if (acdbOpenObject(pWall, id, AcDb::kForWrite) != Acad::eOk)
|
|
{
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
pWall->ChangeElevation(dlg.GetElevation(), FALSE);
|
|
pWall->SetHeight(dlg.GetHeight());
|
|
pWall->SetWidth(0, dlg.GetLeftWidth());
|
|
pWall->SetWidth(1, dlg.GetRightWidth());
|
|
//移除保温
|
|
pWall->SetInsulateOnSide(OFFSET_LEFT, dlg.GetIsLeft());
|
|
pWall->SetInsulateOnSide(OFFSET_RIGHT, dlg.GetIsRight());
|
|
|
|
pWall->SetInsulateThick(dlg.GetLeftKeep(), OFFSET_LEFT);
|
|
pWall->SetInsulateThick(dlg.GetRightKeep(), OFFSET_RIGHT);
|
|
|
|
//设置是否设置墙端头保温
|
|
pWall->SetInsulateEnd(dlg.GetIsTwoSide());
|
|
if (dlg.m_bChkUsing)
|
|
{
|
|
TWallData::UsageFlag use;
|
|
//use = dlg.GetUsage();
|
|
switch(dlg.m_iUsing)
|
|
{
|
|
case 0:
|
|
{
|
|
use=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kExternal);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
use=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kInternal);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
use=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kDispartOwner);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
use=TWallData::kVirtual;
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
use=TWallData::kParapet;
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
use=TWallData::kApartment;
|
|
break;
|
|
}
|
|
}
|
|
pWall->SetUsageFlag(use);
|
|
|
|
}
|
|
pWall->SetLayerHatch2d(InitLayer(LAY_HATCH));
|
|
CString sT20Mat;
|
|
if (dlg.GetMaterialStyle(sT20Mat) == TWallData::kCurtain)
|
|
{
|
|
pWall->Close();
|
|
PickSet ssTemp(SS_FREE);
|
|
ssTemp += id;
|
|
if (ssTemp.Length()>0)
|
|
{
|
|
Entity entTemp = ssTemp[0L];
|
|
Wall2Curtain(entTemp);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
//if (pWall->Is(CURVE_ARC)) // 改变半径
|
|
//{
|
|
//注释 by lgy 没有处理半径
|
|
// double nChordLen = pWall->XLine::GetLength();
|
|
// if (nChordLen<2.0*_tstof(m_csRadius)-1.0E-6)
|
|
// {
|
|
// BOOL bOverPi = (pWall->GetBulge()>PI);
|
|
// double nAng = 2.0*asin(nChordLen/2.0/_tstof(m_csRadius));
|
|
// if (!bOverPi)
|
|
// pWall->SetBulge(nAng);
|
|
// else
|
|
// pWall->SetBulge(2*PI-nAng);
|
|
// }
|
|
//}
|
|
//if (acdbOpenObject(pWall, id, AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
TWallData::TWallStyle st;
|
|
st = dlg.GetMaterialStyle(sT20Mat);
|
|
pWall->SetStyle(st);
|
|
pWall->SetT20WallMat(sT20Mat);
|
|
#if (ADS > 16)
|
|
std::vector< std::pair<CString, CString> > materialName;
|
|
utility::ReadHatchMaterialConfigFile(_T("墙-墙体材料"), materialName);
|
|
std::vector< std::pair<CString, CString> >::iterator iter = materialName.begin();
|
|
for (;iter!=materialName.end();++iter)
|
|
if(iter->first == sT20Mat)
|
|
{
|
|
pWall->GetSpecialtyData()->SetAt(sKEY_WALL_HATCH_PATTERN, iter->second);
|
|
break;
|
|
}
|
|
#endif
|
|
pWall->setLayer(InitLayer(pWall->GetDefaultLayer()));
|
|
}
|
|
pWall->Close();
|
|
}
|
|
}
|
|
|
|
TArchCmdReactor::UpdateCorners();// 修墙角
|
|
TArchCmdReactor::ResetAll();
|
|
|
|
ads_redraw(NULL, 0);
|
|
DocSetShowBase(bOldShowBase);
|
|
OPENOBJ_END();
|
|
}
|
|
dlg.DestroyWindow();
|
|
}
|
|
|
|
// 处理offset墙体
|
|
int DealOffsetWall( ads_name ename,double &distance,ads_point SidePt);
|
|
|
|
// 对墙体进行offset操作:
|
|
//
|
|
int osWall(double distance);
|
|
void OffsetWall()
|
|
{
|
|
static double distance=4000;
|
|
|
|
// [10/11/2007 nsh]
|
|
int i =GetDist(_T("\n输入偏移距离"),distance, RSG_NONEG|RSG_NOZERO);
|
|
if (i==RTCAN)
|
|
{
|
|
return;
|
|
}
|
|
while(1) {
|
|
if (osWall(distance)!=RTNORM)
|
|
break;
|
|
}
|
|
}
|
|
|
|
// offset墙体:
|
|
//
|
|
int osWall(double distance)
|
|
{
|
|
XPoint SidePt;
|
|
double nDeriveAngle;
|
|
Entity ename;
|
|
if (SelectWallSide(ename, SidePt, &nDeriveAngle)!=RTNORM)
|
|
return RTERROR;
|
|
|
|
if (DealOffsetWall(ename,distance,SidePt)!=RTNORM){
|
|
return RTERROR;
|
|
}
|
|
|
|
//add by xlc on 070827
|
|
//UCS下不能负偏移
|
|
SidePt = Wcs2Ucs(SidePt);
|
|
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
|
// Zyu modify on 100721,支持64位
|
|
//if(ads_command (RTSTR,_T("OFFSET"),RTREAL,distance,RTENAME,(long *)ename,RT3DPOINT,&SidePt, RTSTR, _T(""), RTNONE)!=RTNORM)
|
|
if(ads_command (RTSTR,_T("OFFSET"),RTREAL,distance,RTENAME,(TLong_ptr *)ename,RT3DPOINT,&SidePt, RTSTR, _T(""), RTNONE)!=RTNORM)
|
|
return RTERROR;
|
|
|
|
|
|
return RTNORM;
|
|
}
|
|
// 处理offset墙体
|
|
int DealOffsetWall( ads_name ename,double &distance,ads_point SidePt)
|
|
{
|
|
AcDbObjectId ObjId;
|
|
AcDbEntity* pEntity;
|
|
AcGePoint3d f,StartPt;
|
|
|
|
if (acdbGetObjectId(ObjId, ename)!=Acad::eOk)
|
|
return RTERROR;
|
|
acdbOpenAcDbEntity(pEntity, ObjId, AcDb::kForRead);
|
|
// 如果实体不为空
|
|
if (NULL == pEntity)
|
|
return RTERROR;
|
|
if (!pEntity->isKindOf(TDbWall::desc())){
|
|
pEntity->close();
|
|
return RTERROR;
|
|
}
|
|
TDbWall *pWall = TDbWall::cast(pEntity);
|
|
XCurveSegment seg=pWall->OffsetGeomCenter();
|
|
// [10/12/2007 nsh]
|
|
if (seg.Is(CURVE_ARC))
|
|
{
|
|
XArc xar;
|
|
xar=seg.GetArc();
|
|
if (distance>=xar.GetRadius())
|
|
{
|
|
if (xar.HitTest2d(SidePt)==1)
|
|
{
|
|
AfxMessageBox(_T("选择弧墙内侧时,净距偏移应小于其半径"));
|
|
//osWall(distance);
|
|
pWall->close();
|
|
return RTERROR;
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
// [10/12/2007 nsh]
|
|
int nSide=seg.OnWhichSide(SidePt);
|
|
double nDrt=pWall->OrthoDirection(SidePt);
|
|
if (nSide==OFFSET_LEFT)
|
|
nDrt = CT_std_angle(nDrt+PI);
|
|
ads_polar(XPoint(SidePt), nDrt, 5*pWall->GetWidth(), SidePt);
|
|
|
|
// 得到墙的左右宽度:
|
|
distance += pWall->GetWidth();
|
|
pWall->close();
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
// 由墙边线偏移出线或弧
|
|
void Wall2Curve()
|
|
{
|
|
XPoint SidePt;
|
|
int nOldOsnap=g_nOsnapType;
|
|
DocSetWallOsnapType(1);
|
|
Entity ent;
|
|
RBList mask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL,TCH_COLUMN"), NULL);
|
|
XPoint ptPick;
|
|
int nRetCode=RTNORM;
|
|
if ((nRetCode=SelectEntity1(_T("\n请点取墙边或柱子<退出>: "), ent, ptPick, mask))!=RTNORM) {
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
return;
|
|
}
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
ptPick=Ucs2Wcs(ptPick);
|
|
static double distance=100;
|
|
if (GetDist(_T("\n输入偏移距离"), distance)==RTCAN)
|
|
return;
|
|
|
|
if (ent.Is(_T("TCH_WALL"))||ent.Is(_T("TCH_CURTAIN_WALL"))) {
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
ASSERT(pWall);
|
|
|
|
XCurveSegment lCurve, rCurve, selCurve;
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
//XPoint ptOnSide;
|
|
//selCurve.ProjectToMe(ptPick, ptOnSide);
|
|
XCurveSegment seg=pWall->OffsetGeomCenter();
|
|
int nSide=seg.OnWhichSide(ptPick);
|
|
XCurveSegment cvResult;
|
|
if (nSide==OFFSET_LEFT)
|
|
cvResult=lCurve.Offset(nSide, distance, LS_FINITE);
|
|
else
|
|
cvResult=rCurve.Offset(nSide, distance, LS_FINITE);
|
|
cvResult.SetElevation(0.0);
|
|
if (cvResult.GetLength()>_DIST_SNAP)
|
|
cvResult.Make();
|
|
OPENOBJ_END();
|
|
} else if (ent.Is(_T("TCH_COLUMN"))) {
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pColu);
|
|
ASSERT(pColu);
|
|
XPoly2D polyOut(1), polyOffset(1);
|
|
pColu->GetOutline(polyOut);
|
|
polyOut.SetElevation(0.0);
|
|
if (polyOut.PathArea()>0.0)
|
|
polyOut.Reverse();
|
|
if (polyOut.Offset(distance, polyOffset)==RTNORM)
|
|
polyOffset.Make();
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
//// Command: 等分加墙段
|
|
//void DivideWall()
|
|
//{
|
|
// Entity ent;
|
|
// if (SelectEntity(_T("\n选择等分所参照的墙段<退出>: "), ent, RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL))==RTNORM) {
|
|
// static int nCount=2;
|
|
// ads_initget(RSG_NONEG|RSG_NOZERO, NULL);
|
|
// adsout << _T("\n请输入等分数<") << nCount << _T(">: ");
|
|
// int nRetCode=ads_getint(_T(""), &nCount);
|
|
// if (nRetCode==RTNONE || nRetCode==RTNORM) {
|
|
// if (nCount<2) {
|
|
// adsout << _T("\n请输入一有效的整数!");
|
|
// return;
|
|
// }
|
|
// XCurveSegment segWall;
|
|
// double nThick=240;
|
|
// OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
// if (!pWall)
|
|
// return;
|
|
// segWall = *pWall;
|
|
// nThick=pWall->GetWidth();
|
|
// OPENOBJ_END();
|
|
//
|
|
// if (GetDist(_T("\n请输入墙厚"), nThick, RSG_NONEG|RSG_NOZERO)==RTCAN)
|
|
// return;
|
|
//
|
|
// Entity entOther;
|
|
// if (entOther.FilterSelect(_T("\n选择作为另一边界的墙段<退出>: "), RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL))!=RTNORM)
|
|
// return;
|
|
// if (entOther==ent) {
|
|
// adsout << _T("\n非法选择!");
|
|
// return;
|
|
// }
|
|
// XCurveSegment segOther;
|
|
// OPENOBJ_BEGIN(entOther, AcDb::kForRead, TDbWall, pOther);
|
|
// if (!pOther)
|
|
// return;
|
|
// segOther = *pOther;
|
|
// OPENOBJ_END();
|
|
// segOther.flag=LS_INFINITE;
|
|
//
|
|
// double nTotalDist=segWall.Length();
|
|
// double nUnitDist=nTotalDist/nCount;
|
|
// for (int i=1; i<nCount; i++) {
|
|
// XPointDir2d ptStart;
|
|
// segWall.Polar(i*nUnitDist, ptStart);
|
|
// XLine ln(ptStart, ptStart.nDirection+PI/2.0);
|
|
// XPoint ptInt[2];
|
|
// int nIntNum=segOther.Intersection(ln, ptInt[0], ptInt[1]);
|
|
// if (nIntNum==1) {
|
|
// TDbWall *pWall=(TDbWall *)TDbWall::desc()->create();
|
|
// (XLine &)(*pWall) = XLine(ptStart, ptInt[0]);
|
|
// pWall->SetWidth(0, nThick/2);
|
|
// pWall->SetWidth(1, nThick/2);
|
|
// pWall->SetLayerHatch2d(InitLayer(LAY_HATCH));
|
|
// pWall->AddToMSpace(Adesk::kTrue);
|
|
// } else if (nIntNum==2) {
|
|
// if ((ptInt[0]&segOther)==PR_INSIDE) {
|
|
// TDbWall *pWall=(TDbWall *)TDbWall::desc()->create();
|
|
// (XLine &)(*pWall) = XLine(ptStart, ptInt[0]);
|
|
// pWall->SetWidth(0, nThick/2);
|
|
// pWall->SetWidth(1, nThick/2);
|
|
// pWall->SetLayerHatch2d(InitLayer(LAY_HATCH));
|
|
// pWall->AddToMSpace(Adesk::kTrue);
|
|
// } else if ((ptInt[1]&segOther)==PR_INSIDE) {
|
|
// TDbWall *pWall=(TDbWall *)TDbWall::desc()->create();
|
|
// (XLine &)(*pWall) = XLine(ptStart, ptInt[1]);
|
|
// pWall->SetWidth(0, nThick/2);
|
|
// pWall->SetWidth(1, nThick/2);
|
|
// pWall->SetLayerHatch2d(InitLayer(LAY_HATCH));
|
|
// pWall->AddToMSpace(Adesk::kTrue);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
// Add by lcf on 20050817
|
|
// command:等分加墙
|
|
class CDivideWallDlg : public CModelessDialog
|
|
{
|
|
public:
|
|
CDivideWallDlg(CWnd* pParent = NULL);
|
|
|
|
enum { IDD = IDD_DIVIDE_WALL };
|
|
CSpinButtonCtrl m_spin;
|
|
CEdit m_edit;
|
|
CComboBox m_ctrlThick;
|
|
static int g_nMaterial;
|
|
static int g_nUse;
|
|
static int g_nDivNum;
|
|
static CString g_szThick;
|
|
|
|
void SetDivNum(int nDivNum);
|
|
void SetThick(double dThick);
|
|
void SetUse(TWallData::UsageFlag flag);
|
|
int GetDivNum();
|
|
double GetThick();
|
|
TWallData::TWallStyle GetMaterial();
|
|
TWallData::UsageFlag GetUse();
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
virtual BOOL OnInitDialog();
|
|
virtual void OnOK();
|
|
afx_msg void OnCbnDropdownComboThick();
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
int CDivideWallDlg::g_nMaterial=2;
|
|
int CDivideWallDlg::g_nUse=1;
|
|
int CDivideWallDlg::g_nDivNum=2;
|
|
CString CDivideWallDlg::g_szThick=_T("240");
|
|
CDivideWallDlg::CDivideWallDlg(CWnd* pParent)
|
|
: CModelessDialog(CDivideWallDlg::IDD, pParent)
|
|
{
|
|
}
|
|
|
|
void CDivideWallDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_SPIN_DIVIDENUM, m_spin);
|
|
DDX_CBIndex(pDX, IDC_COMBO_MATERIAL, g_nMaterial);
|
|
DDX_CBIndex(pDX, IDC_COMBO_USE, g_nUse);
|
|
DDX_Text(pDX, IDC_EDIT_DIVIDENUM, g_nDivNum);
|
|
DDX_CBString(pDX, IDC_COMBO_THICK, g_szThick);
|
|
DDX_Control(pDX, IDC_EDIT_DIVIDENUM, m_edit);
|
|
DDV_MinMaxInt(pDX, g_nDivNum, 2, INT_MAX);
|
|
DDX_Control(pDX, IDC_COMBO_THICK, m_ctrlThick);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CDivideWallDlg, CModelessDialog)
|
|
ON_CBN_DROPDOWN(IDC_COMBO_THICK, OnCbnDropdownComboThick)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CDivideWallDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
m_spin.SetBuddy(&m_edit);
|
|
m_spin.SetRange(2, UD_MAXVAL);
|
|
|
|
CComboBox *pBox = (CComboBox*)GetDlgItem(IDC_COMBO_MATERIAL);
|
|
pBox->ResetContent();
|
|
pBox->AddString(WALLMATE_Concrete);
|
|
pBox->AddString(WALLMATE_Concrete1);
|
|
pBox->AddString(WALLMATE_Brick);
|
|
pBox->AddString(WALLMATE_Brick1);
|
|
pBox->AddString(WALLMATE_Rocket);
|
|
pBox->AddString(WALLMATE_Rocket1);
|
|
pBox->AddString(WALLMATE_Fill);
|
|
pBox->AddString(WALLMATE_Fill1);
|
|
pBox->AddString(WALLMATE_Fill2);
|
|
pBox->AddString(WALLMATE_Divider);
|
|
pBox->AddString(WALLMATE_Curtain);
|
|
pBox->SetCurSel(g_nMaterial);
|
|
|
|
CComboBox *pBox1 = (CComboBox*)GetDlgItem(IDC_COMBO_USE);
|
|
pBox1->ResetContent();
|
|
pBox1->AddString(_T("外墙"));
|
|
pBox1->AddString(_T("内墙"));
|
|
pBox1->AddString(_T("分户墙"));
|
|
pBox1->AddString(_T("虚墙"));
|
|
pBox1->AddString(_T("矮墙"));
|
|
pBox1->AddString(_T("卫生隔断"));
|
|
|
|
pBox1->SetCurSel(g_nUse);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CDivideWallDlg::OnCbnDropdownComboThick()
|
|
{
|
|
CString szText;
|
|
m_ctrlThick.GetWindowText(szText);
|
|
int nStyle;
|
|
CDataExchange dx(this, true);
|
|
DDX_CBIndex(&dx, IDC_COMBO_MATERIAL, nStyle);
|
|
|
|
m_ctrlThick.ResetContent();
|
|
m_ctrlThick.AddString(_T("40"));
|
|
m_ctrlThick.AddString(_T("60"));
|
|
m_ctrlThick.AddString(_T("100"));
|
|
m_ctrlThick.AddString(_T("120"));
|
|
m_ctrlThick.AddString(_T("180"));
|
|
m_ctrlThick.AddString(_T("200"));
|
|
m_ctrlThick.AddString(_T("240"));
|
|
m_ctrlThick.AddString(_T("250"));
|
|
m_ctrlThick.AddString(_T("300"));
|
|
m_ctrlThick.AddString(_T("360"));
|
|
m_ctrlThick.AddString(_T("400"));
|
|
m_ctrlThick.AddString(_T("480"));
|
|
m_ctrlThick.AddString(_T("500"));
|
|
|
|
m_ctrlThick.SetWindowText(szText);
|
|
}
|
|
|
|
void CDivideWallDlg::OnOK()
|
|
{
|
|
UpdateData();
|
|
CModelessDialog::OnOK();
|
|
}
|
|
|
|
void CDivideWallDlg::SetDivNum(int nDivNum)
|
|
{
|
|
g_nDivNum = nDivNum;
|
|
}
|
|
|
|
void CDivideWallDlg::SetThick(double dThick)
|
|
{
|
|
g_szThick.Format(_T("%lg"), dThick);
|
|
}
|
|
|
|
void CDivideWallDlg::SetUse(TWallData::UsageFlag flag)
|
|
{
|
|
if (flag == TWallData::kNormal)
|
|
g_nUse = 0;
|
|
else if (flag == TWallData::kApartment)
|
|
g_nUse = 1;
|
|
else if (flag == TWallData::kVirtual)
|
|
g_nUse = 2;
|
|
else
|
|
g_nUse = 3;
|
|
}
|
|
|
|
int CDivideWallDlg::GetDivNum()
|
|
{
|
|
return g_nDivNum;
|
|
}
|
|
|
|
double CDivideWallDlg::GetThick()
|
|
{
|
|
return _tstof(g_szThick);
|
|
}
|
|
|
|
TWallData::TWallStyle CDivideWallDlg::GetMaterial()
|
|
{
|
|
switch(g_nMaterial)
|
|
{
|
|
case 0:
|
|
return TWallData::kDivider;
|
|
case 1:
|
|
return TWallData::kCurtain;
|
|
case 2:
|
|
return TWallData::kFill;
|
|
case 3:
|
|
return TWallData::kFill1;
|
|
case 4:
|
|
return TWallData::kFill2;
|
|
case 5:
|
|
return TWallData::kBrick;
|
|
case 6:
|
|
return TWallData::kRocket;
|
|
case 7:
|
|
return TWallData::kConcrete;
|
|
default:
|
|
return TWallData::kDivider;
|
|
}
|
|
}
|
|
|
|
TWallData::UsageFlag CDivideWallDlg::GetUse()
|
|
{
|
|
if (g_nUse == 0)
|
|
return TWallData::kNormal;
|
|
else if (g_nUse == 1)
|
|
return TWallData::kApartment;
|
|
else if (g_nUse == 2)
|
|
return TWallData::kVirtual;
|
|
else
|
|
return TWallData::kParapet;
|
|
}
|
|
// Command: 等分加墙段
|
|
void DivideWall()
|
|
{
|
|
Entity ent;
|
|
if (SelectEntity(_T("\n选择等分所参照的墙段<退出>: "), ent, RBList(RTDXF0, _T("TCH_WALL"), NULL))!=RTNORM)
|
|
return;
|
|
|
|
static int nCount=2;
|
|
CDivideWallDlg dlg(acedGetAcadFrame());
|
|
|
|
XCurveSegment segWall;
|
|
double fWallHigh=0;//add by fxj 090326
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
|
if (!pWall)
|
|
return;
|
|
segWall = *pWall;
|
|
dlg.SetDivNum(nCount);
|
|
dlg.SetThick(pWall->GetWidth());
|
|
//dlg.SetUse(pWall->GetUsageFlag());
|
|
TWallData::TWallStyle xx = pWall->GetStyle();
|
|
switch(pWall->GetStyle())
|
|
{
|
|
case TWallData::kConcrete:
|
|
{
|
|
dlg.g_nMaterial = 0;
|
|
if (pWall->GetT20WallMat() == WALLMATE_Concrete1)
|
|
{
|
|
dlg.g_nMaterial += 1;
|
|
}
|
|
break;
|
|
}
|
|
|
|
case TWallData::kBrick:
|
|
{
|
|
dlg.g_nMaterial = 2;
|
|
if (pWall->GetT20WallMat() == WALLMATE_Brick1)
|
|
{
|
|
dlg.g_nMaterial += 1;
|
|
}
|
|
break;
|
|
}
|
|
case TWallData::kRocket:
|
|
{
|
|
dlg.g_nMaterial = 4;
|
|
if (pWall->GetT20WallMat() == WALLMATE_Rocket1)
|
|
{
|
|
dlg.g_nMaterial += 1;
|
|
}
|
|
break;
|
|
}
|
|
case TWallData::kFill:
|
|
{
|
|
dlg.g_nMaterial = 6;
|
|
break;
|
|
}
|
|
case TWallData::kFill1:
|
|
{
|
|
dlg.g_nMaterial = 7;
|
|
break;
|
|
}
|
|
case TWallData::kFill2:
|
|
{
|
|
dlg.g_nMaterial = 8;
|
|
break;
|
|
}
|
|
case TWallData::kDivider:
|
|
{
|
|
dlg.g_nMaterial = 9;
|
|
break;
|
|
}
|
|
case TWallData::kCurtain:
|
|
{
|
|
dlg.g_nMaterial = 10;
|
|
break;
|
|
}
|
|
}
|
|
|
|
fWallHigh=pWall->GetHeight();//add by fxj 090326
|
|
OPENOBJ_END();
|
|
ent.Redraw(3);
|
|
|
|
{
|
|
CAcModuleResourceOverride vTemp;
|
|
if ( !dlg.Create(dlg.IDD, acedGetAcadFrame()) )
|
|
{
|
|
ent.Redraw(4);
|
|
return;
|
|
}
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
Entity entOther;
|
|
if (entOther.FilterSelect(_T("\n选择作为另一边界的墙段<退出>: "), RBList(RTDXF0, _T("TCH_WALL"), NULL))!=RTNORM)
|
|
{
|
|
ent.Redraw(4);
|
|
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ent.Redraw(4);
|
|
|
|
if (entOther==ent) {
|
|
adsout << _T("\n非法选择!");
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
dlg.UpdateData();
|
|
nCount = dlg.GetDivNum();
|
|
double nThick = dlg.GetThick();
|
|
|
|
CString sT20Mat;
|
|
TWallData::TWallStyle st;
|
|
switch(dlg.g_nMaterial)
|
|
{
|
|
case 0:
|
|
sT20Mat = WALLMATE_Concrete;
|
|
st = TWallData::kConcrete;
|
|
break;
|
|
case 1:
|
|
sT20Mat = WALLMATE_Concrete1;
|
|
st = TWallData::kConcrete;
|
|
break;
|
|
case 2:
|
|
sT20Mat = WALLMATE_Brick;
|
|
st = TWallData::kBrick;
|
|
break;
|
|
case 3:
|
|
sT20Mat = WALLMATE_Brick1;
|
|
st = TWallData::kBrick;
|
|
break;
|
|
case 4:
|
|
sT20Mat = WALLMATE_Rocket;
|
|
st = TWallData::kRocket;
|
|
break;
|
|
case 5:
|
|
sT20Mat = WALLMATE_Rocket1;
|
|
st = TWallData::kRocket;
|
|
break;
|
|
case 6:
|
|
sT20Mat = WALLMATE_Fill;
|
|
st = TWallData::kFill;
|
|
break;
|
|
case 7:
|
|
sT20Mat = WALLMATE_Fill1;
|
|
st = TWallData::kFill1;
|
|
break;
|
|
case 8:
|
|
sT20Mat = WALLMATE_Fill2;
|
|
st = TWallData::kFill2;
|
|
break;
|
|
case 9:
|
|
sT20Mat = WALLMATE_Divider;
|
|
st = TWallData::kDivider;
|
|
break;
|
|
case 10:
|
|
sT20Mat = WALLMATE_Curtain;
|
|
st = TWallData::kCurtain;
|
|
break;
|
|
}
|
|
|
|
TWallData::UsageFlag nUse;// = dlg.GetUse();
|
|
dlg.DestroyWindow();
|
|
|
|
XCurveSegment segOther;
|
|
OPENOBJ_BEGIN(entOther, AcDb::kForRead, TDbWall, pOther);
|
|
if (!pOther)
|
|
return;
|
|
segOther = *pOther;
|
|
OPENOBJ_END();
|
|
segOther.SetLineFlag(LS_INFINITE);
|
|
|
|
double nTotalDist=segWall.GetLength();
|
|
double nUnitDist=nTotalDist/nCount;
|
|
for (int i=1; i<nCount; i++)
|
|
{
|
|
XPointDir2d ptStart;
|
|
segWall.Polar(i*nUnitDist, ptStart);
|
|
XLine ln(ptStart, ptStart.nDirection+PI/2.0);
|
|
XPoint ptInt[2];
|
|
int nIntNum=segOther.Intersection(ln, ptInt[0], ptInt[1]);
|
|
|
|
// add by xly on 110412 修改墙体材料中的示意幕墙变为玻璃幕墙
|
|
AcDbObjectId idWall;
|
|
if (nIntNum > 0)
|
|
{
|
|
TDbWall *pWall=(TDbWall *)TDbWall::desc()->create();
|
|
if (nIntNum == 1)
|
|
{
|
|
(XLine &)(*pWall) = XLine(ptStart, ptInt[0]);
|
|
}
|
|
else if (nIntNum == 2)
|
|
{
|
|
if ((ptInt[0]&segOther)==PR_INSIDE)
|
|
{
|
|
(XLine &)(*pWall) = XLine(ptStart, ptInt[0]);
|
|
}
|
|
else if ((ptInt[1]&segOther)==PR_INSIDE)
|
|
{
|
|
(XLine &)(*pWall) = XLine(ptStart, ptInt[1]);
|
|
}
|
|
}
|
|
pWall->SetWidth(0, nThick/2);
|
|
pWall->SetWidth(1, nThick/2);
|
|
pWall->SetStyle(st);
|
|
pWall->SetT20WallMat(sT20Mat);
|
|
switch(dlg.g_nUse)
|
|
{
|
|
case 0:
|
|
{
|
|
nUse=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kExternal);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
nUse=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kInternal);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
nUse=TWallData::kNormal;
|
|
pWall->SetCatalog(TDbWall::kDispartOwner);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
nUse=TWallData::kVirtual;
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
nUse=TWallData::kParapet;
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
nUse=TWallData::kApartment;
|
|
break;
|
|
}
|
|
}
|
|
pWall->SetUsageFlag(nUse);
|
|
pWall->SetLayerHatch2d(InitLayer(LAY_HATCH));
|
|
pWall->SetHeight(fWallHigh);//add by fxj 090326
|
|
// modify by xly on 110412 修改墙体材料中的示意幕墙变为玻璃幕墙
|
|
//pWall->AddToMSpace(Adesk::kTrue);
|
|
idWall = pWall->AddToMSpace(Adesk::kTrue);
|
|
}
|
|
// add by xly on 110412 修改墙体材料中的示意幕墙变为玻璃幕墙
|
|
if (st == TWallData::kCurtain)
|
|
{
|
|
if (idWall.isValid())
|
|
{
|
|
PickSet ssWall(SS_FREE);
|
|
ssWall += idWall;
|
|
if (ssWall.Length()>0)
|
|
{
|
|
ent = ssWall[0L];
|
|
Wall2Curtain(ent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void ChExtWallElev()
|
|
{
|
|
//AsureWCS();
|
|
PickSet ssWalls(SS_FREE);
|
|
PickSet ssExtWalls(SS_FREE);
|
|
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), 73, 1, NULL);
|
|
int nRetCode=SelectEntities(_T("\n请选择外墙:"), ssWalls, rbMask);
|
|
if (nRetCode==RTNORM && ssWalls.Length()>0) {
|
|
ads_real nHeight=CFG_LHeight;
|
|
ads_real nElev=0.0;
|
|
long nLen=ssWalls.Length();
|
|
for (long n=0; n<nLen; n++) {
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall && (pWall->GetWallFlag()&WF_EXTERNAL))
|
|
ssExtWalls+=entWall;
|
|
}
|
|
|
|
nLen=ssExtWalls.Length();
|
|
if (nLen>0) {
|
|
{ //取缺省高度和标高
|
|
Entity entWall=ssExtWalls[0L];
|
|
XDbObject obj(entWall, AcDb::kForRead);
|
|
ASSERT(!!obj);
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall) {
|
|
nHeight=pWall->GetHeight();
|
|
nElev=pWall->GetElevation();
|
|
}
|
|
}
|
|
if (GetDist(_T("\n新的高度"), nHeight, RSG_NONEG|RSG_NOZERO)==RTCAN)
|
|
return ;
|
|
if (GetDist(_T("\n新的标高"), nElev, 0)==RTCAN)
|
|
return ;
|
|
|
|
int nAnswer=Q_NO;
|
|
nAnswer=YesNoQuestion(_T("\n是否保持墙上门窗到墙基的距离不变"), nAnswer);
|
|
if (nAnswer==RTCAN)
|
|
return;
|
|
|
|
for (n=0; n<nLen; n++) {
|
|
Entity entWall=ssExtWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall) {
|
|
pWall->assertWriteEnabled();
|
|
pWall->ChangeElevation(nElev, nAnswer==Q_YES);
|
|
pWall->SetHeight(nHeight);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
BOOL bHasExt=FALSE;
|
|
PickSet ssTotalWalls(SS_FREE);
|
|
if (ssTotalWalls.Get(_T("X"), NULL, NULL, RBList(RTDXF0, _T("TCH_WALL,TCH_CURTAIN_WALL"), NULL))!=RTNORM)
|
|
return;
|
|
nLen=ssTotalWalls.Length();
|
|
for (long n=0; n<nLen; n++) {
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj) continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall && (pWall->GetWallFlag()&WF_EXTERNAL)) {
|
|
bHasExt=TRUE;
|
|
break;
|
|
}
|
|
}
|
|
if (bHasExt)
|
|
MessageBox(NULL,_T("您选择的不是外墙!"), _T("提示"), MB_OK|MB_ICONINFORMATION);
|
|
else
|
|
MessageBox(NULL,_T("未发现外墙,请先识别内外墙!"), _T("提示"), MB_OK|MB_ICONINFORMATION);
|
|
}
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//墙-幕墙
|
|
int Wall2Cwall()
|
|
{
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
CString sKeyWord = _T("Q");
|
|
TCHAR cKeyWord='0';
|
|
int iRe = SelectEnts(_T("\n请选择要转换为玻璃幕墙的墙或[幕墙转墙(Q)]<退出>: "),_T("\n请选择要转换为玻璃幕墙的墙: "),
|
|
rbMask,ssWalls,sKeyWord,cKeyWord);
|
|
//完成选择,进行转换
|
|
if (iRe == RTNORM)
|
|
{
|
|
//墙转玻璃幕墙
|
|
for (long n=0; n<ssWalls.Length(); n++)
|
|
{
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj)
|
|
continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall)
|
|
{
|
|
AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
//幕墙
|
|
TDbWall *pCWall = NULL;
|
|
AcDbCurve *pCv = pWall->GetAcDbCurve(0);
|
|
if (pCv)
|
|
{
|
|
pCWall = (TDbWall*)TDbCurtainWall::desc()->create();
|
|
if (pCWall)
|
|
{
|
|
DList<AcDbSoftPointerId> listBindWinid,idlist;
|
|
|
|
pCWall->SetFromCurve((*pCv));
|
|
pCWall->copyFrom(pWall);
|
|
int i=0;
|
|
for (i=0;i<pWall->GetOpeningIdList().Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = pWall->GetOpeningIdList()[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForRead);
|
|
if (pent)
|
|
{
|
|
if (pent->isKindOf(TDbBandWin::desc()))
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == pWall->objectId())
|
|
{
|
|
pWall->RemoveReferenceOpening(id);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
// sg modify 110318,解决64位下的崩溃问题
|
|
// listBindWinid.Append(&id);
|
|
listBindWinid.Append(new AcDbSoftPointerId(id));
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pWall->MoveOpeningTo(*pCWall);
|
|
pWall->MovePatchTo(*pCWall);
|
|
pCWall->ChangeElevation(pWall->GetElevation(),FALSE);
|
|
pCWall->SetHeight(pWall->GetHeight());
|
|
pCWall->SetWidth(0,pWall->GetWidth(0));
|
|
pCWall->SetWidth(1,pWall->GetWidth(1));
|
|
pCWall->SetStyle(TWallData::kCurtain);
|
|
pCWall->SetUsageFlag(pWall->GetUsageFlag());
|
|
pCWall->SetCatalog(pWall->GetCatalog());
|
|
|
|
TDbCurtainWall *pCurtinWall = (TDbCurtainWall*)pCWall;
|
|
pCurtinWall->SetLayerGlass3d(InitLayer(LAY_3DGLASS));
|
|
pCurtinWall->SetLayerCol3d(InitLayer(LAY_3DFRAME));
|
|
pCurtinWall->SetLayerRow3d(InitLayer(LAY_3DFRAME));
|
|
AcDbObjectId idNew,idOld;
|
|
idOld = pWall->objectId();
|
|
idNew = pCurtinWall->AddToMSpace(Adesk::kTrue);
|
|
for (i=0;i<listBindWinid.Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = *listBindWinid[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForWrite);
|
|
if (pent)
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == idOld)
|
|
{
|
|
pBandWin->SetWallId(j,idNew);
|
|
}
|
|
}
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pWall->erase();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//关键字Q
|
|
else if (iRe == RTKWORD)
|
|
{
|
|
return RTKWORD;
|
|
}
|
|
else
|
|
{
|
|
return RTCAN;
|
|
}
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
//幕墙--墙
|
|
int Cwall2Wall()
|
|
{
|
|
PickSet ssWalls(SS_FREE);
|
|
RBList rbMask(RTDXF0, _T("TCH_CURTAIN_WALL"), NULL);
|
|
CString sKeyWord = _T("Q");
|
|
TCHAR cKeyWord='0';
|
|
int iRe = SelectEnts(_T("\n请选择要转换为墙的玻璃幕墙或[墙转幕墙{Q}]<退出>: "),_T("\n请选择要转换为墙的玻璃幕墙: "),
|
|
rbMask,ssWalls,sKeyWord,cKeyWord);
|
|
//完成选择,进行转换
|
|
if (iRe == RTNORM)
|
|
{
|
|
TWallData::TWallStyle style;
|
|
static int iSel = 4;
|
|
CString strPrompt;
|
|
strPrompt.Format(_T("\n请选择转换墙体材料:[填充墙(0)/%s(1)/%s(2)/%s(3)/砖(4)/%s(5)/石材(6)/%s(7)/%s(8)/%s(9)]<%d>: "),
|
|
WALLMATE_Fill1,WALLMATE_Fill2,WALLMATE_Divider,WALLMATE_Brick1,WALLMATE_Rocket1, WALLMATE_Concrete, WALLMATE_Concrete1,iSel);
|
|
TCHAR sRetKey[100];
|
|
int nRetCode;
|
|
INITGET_BEG(0, _T("0 1 2 3 4 5 6 7 8 9"));
|
|
nRetCode = ads_getkword(strPrompt, sRetKey);
|
|
INITGET_END();
|
|
if (nRetCode == RTNORM)
|
|
{
|
|
if (CString("0").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 0;
|
|
}
|
|
else if (CString("1").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 1;
|
|
}
|
|
else if (CString("2").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 2;
|
|
}
|
|
else if (CString("3").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 3;
|
|
}
|
|
else if (CString("4").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 4;
|
|
}
|
|
else if (CString("5").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 5;
|
|
}
|
|
else if (CString("6").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 6;
|
|
}
|
|
else if (CString("7").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 7;
|
|
}
|
|
else if (CString("8").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 8;
|
|
}
|
|
else if (CString("9").CompareNoCase(sRetKey) == 0)
|
|
{
|
|
iSel = 9;
|
|
}
|
|
else
|
|
{
|
|
return RTCAN;
|
|
}
|
|
}
|
|
else if (nRetCode == RTNONE)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
return RTCAN;
|
|
}
|
|
|
|
CString sT20Mat;
|
|
//材料
|
|
switch(iSel)
|
|
{
|
|
case 0:
|
|
{
|
|
style = TWallData::kFill;
|
|
sT20Mat = WALLMATE_Fill;
|
|
}
|
|
break;
|
|
case 1:
|
|
{
|
|
style = TWallData::kFill1;
|
|
sT20Mat = WALLMATE_Fill1;
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
style = TWallData::kFill2;
|
|
sT20Mat = WALLMATE_Fill2;
|
|
}
|
|
break;
|
|
case 3:
|
|
{
|
|
style = TWallData::kDivider;
|
|
sT20Mat = WALLMATE_Divider;
|
|
}
|
|
break;
|
|
case 4:
|
|
{
|
|
style = TWallData::kBrick;
|
|
sT20Mat = WALLMATE_Brick;
|
|
}
|
|
break;
|
|
case 5:
|
|
{
|
|
style = TWallData::kBrick;
|
|
sT20Mat = WALLMATE_Brick1;
|
|
}
|
|
break;
|
|
case 6:
|
|
{
|
|
style = TWallData::kRocket;
|
|
sT20Mat = WALLMATE_Rocket;
|
|
}
|
|
break;
|
|
case 7:
|
|
{
|
|
style = TWallData::kRocket;
|
|
sT20Mat = WALLMATE_Rocket1;
|
|
}
|
|
break;
|
|
case 8:
|
|
{
|
|
style = TWallData::kConcrete;
|
|
sT20Mat = WALLMATE_Concrete;
|
|
}
|
|
break;
|
|
case 9:
|
|
{
|
|
style = TWallData::kConcrete;
|
|
sT20Mat = WALLMATE_Concrete1;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//玻璃幕墙转墙
|
|
for (long n=0; n<ssWalls.Length(); n++)
|
|
{
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj)
|
|
continue;
|
|
TDbCurtainWall *pCWall=TDbCurtainWall::cast(obj.m_pObject);
|
|
if (pCWall)
|
|
{
|
|
AcDbObjectId idSurf=pCWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pCWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
//新墙
|
|
TDbWall *pNewWall = NULL;
|
|
AcDbCurve *pCv = pCWall->GetAcDbCurve(0);
|
|
if (pCv)
|
|
{
|
|
pNewWall = (TDbWall*)TDbWall::desc()->create();
|
|
if (pNewWall)
|
|
{
|
|
DList<AcDbSoftPointerId> listBindWinid,idlist;
|
|
|
|
pNewWall->SetFromCurve((*pCv));
|
|
pNewWall->copyFrom(pCWall);
|
|
|
|
int i=0;
|
|
for (i=0;i<pCWall->GetOpeningIdList().Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = pCWall->GetOpeningIdList()[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForRead);
|
|
if (pent)
|
|
{
|
|
if (pent->isKindOf(TDbBandWin::desc()))
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == pCWall->objectId())
|
|
{
|
|
pCWall->RemoveReferenceOpening(id);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
// sg modify 110318,解决64位下的崩溃问题
|
|
// listBindWinid.Append(&id);
|
|
listBindWinid.Append(new AcDbSoftPointerId(id));
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pCWall->MoveOpeningTo(*pNewWall);
|
|
pCWall->MovePatchTo(*pNewWall);
|
|
pNewWall->ChangeElevation(pCWall->GetElevation(),FALSE);
|
|
pNewWall->SetHeight(pCWall->GetHeight());
|
|
pNewWall->SetWidth(0,pCWall->GetWidth(0));
|
|
pNewWall->SetWidth(1,pCWall->GetWidth(1));
|
|
pNewWall->SetStyle(style);
|
|
pNewWall->SetT20WallMat(sT20Mat);
|
|
pNewWall->SetUsageFlag(pCWall->GetUsageFlag());
|
|
pNewWall->SetCatalog(pCWall->GetCatalog());
|
|
|
|
AcDbObjectId idNew,idOld;
|
|
idOld = pCWall->objectId();
|
|
idNew = pNewWall->AddToMSpace(Adesk::kTrue);
|
|
for (i=0;i<listBindWinid.Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = *listBindWinid[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForWrite);
|
|
if (pent)
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == idOld)
|
|
{
|
|
pBandWin->SetWallId(j,idNew);
|
|
}
|
|
}
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pCWall->erase();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//关键字Q
|
|
else if (iRe == RTKWORD)
|
|
{
|
|
return RTKWORD;
|
|
}
|
|
else
|
|
{
|
|
return RTCAN;
|
|
}
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
void ConvertCurtain()//墙转化为玻璃幕墙
|
|
{
|
|
//重新设计命令的操作流程,兼顾现在“墙”转换成“幕墙”和“幕墙”转换成“墙”的功能
|
|
//modify by lxb on 20120109
|
|
|
|
static int iFlag = 0;// 0,1
|
|
|
|
//清空选择集
|
|
g_ssPickFirst.Free();
|
|
|
|
while(TRUE)
|
|
{
|
|
int iRe = -1;
|
|
if (iFlag == 0)
|
|
{
|
|
iRe = Wall2Cwall();
|
|
}
|
|
else if (iFlag == 1)
|
|
{
|
|
iRe = Cwall2Wall();
|
|
}
|
|
if (iRe == RTKWORD)
|
|
{
|
|
iFlag++;
|
|
iFlag = iFlag%2;
|
|
continue;
|
|
}
|
|
if (iRe == RTCAN)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
/* PickSet ssWalls(SS_FREE);
|
|
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
int nRetCode=SelectEntities(_T("\n请选择要转化为玻璃幕墙的墙体:"), ssWalls, rbMask);
|
|
if (nRetCode==RTNORM&&ssWalls.Length()>0)
|
|
{
|
|
for (long n=0; n<ssWalls.Length(); n++)
|
|
{
|
|
Entity entWall=ssWalls[n];
|
|
XDbObject obj(entWall, AcDb::kForWrite);
|
|
if (!obj)
|
|
continue;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if (pWall)
|
|
{
|
|
AcDbObjectId idSurf=pWall->GetLayerSurf2d();
|
|
if (!idSurf.isValid())
|
|
pWall->SetLayerSurf2d(InitLayer(LAY_SURFACE));
|
|
|
|
//幕墙
|
|
TDbWall *pCWall = NULL;
|
|
AcDbCurve *pCv = pWall->GetAcDbCurve(0);
|
|
if (pCv)
|
|
{
|
|
pCWall = (TDbWall*)TDbCurtainWall::desc()->create();
|
|
if (pCWall)
|
|
{
|
|
DList<AcDbSoftPointerId> listBindWinid,idlist;
|
|
|
|
pCWall->SetFromCurve((*pCv));
|
|
pCWall->copyFrom(pWall);
|
|
int i=0;
|
|
for (i=0;i<pWall->GetOpeningIdList().Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = pWall->GetOpeningIdList()[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForRead);
|
|
if (pent)
|
|
{
|
|
if (pent->isKindOf(TDbBandWin::desc()))
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == pWall->objectId())
|
|
{
|
|
pWall->RemoveReferenceOpening(id);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
// sg modify 110318,解决64位下的崩溃问题
|
|
// listBindWinid.Append(&id);
|
|
listBindWinid.Append(new AcDbSoftPointerId(id));
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pWall->MoveOpeningTo(*pCWall);
|
|
pWall->MovePatchTo(*pCWall);
|
|
pCWall->ChangeElevation(pWall->GetElevation(),FALSE);
|
|
pCWall->SetHeight(pWall->GetHeight());
|
|
pCWall->SetWidth(0,pWall->GetWidth(0));
|
|
pCWall->SetWidth(1,pWall->GetWidth(1));
|
|
pCWall->SetStyle(TWallData::kCurtain);
|
|
pCWall->SetUsageFlag(pWall->GetUsageFlag());
|
|
|
|
TDbCurtainWall *pCurtinWall = (TDbCurtainWall*)pCWall;
|
|
pCurtinWall->SetLayerGlass3d(InitLayer(LAY_3DGLASS));
|
|
pCurtinWall->SetLayerCol3d(InitLayer(LAY_3DFRAME));
|
|
pCurtinWall->SetLayerRow3d(InitLayer(LAY_3DFRAME));
|
|
AcDbObjectId idNew,idOld;
|
|
idOld = pWall->objectId();
|
|
idNew = pCurtinWall->AddToMSpace(Adesk::kTrue);
|
|
for (i=0;i<listBindWinid.Length();i++)
|
|
{
|
|
AcDbSoftPointerId id = *listBindWinid[i];
|
|
AcDbEntity *pent = NULL;
|
|
Acad::ErrorStatus es = acdbOpenAcDbEntity(pent,id,AcDb::kForWrite);
|
|
if (pent)
|
|
{
|
|
TDbBandWin *pBandWin = TDbBandWin::cast(pent);
|
|
if (pBandWin)
|
|
{
|
|
long nNum = pBandWin->GetWallNum();
|
|
int j=0;
|
|
for (j=0;j<nNum;j++)
|
|
{
|
|
AcDbObjectId idTem = pBandWin->GetWallId(j);
|
|
if (idTem == idOld)
|
|
{
|
|
pBandWin->SetWallId(j,idNew);
|
|
}
|
|
}
|
|
}
|
|
pent->close();
|
|
}
|
|
}
|
|
pWall->erase();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
}
|