3598 lines
91 KiB
C++
3598 lines
91 KiB
C++
#include "stdafx.h"
|
||
#include "dbelipse.h"
|
||
#include "acestext.h"
|
||
#include "resource.h"
|
||
#include "SelectFilterDlg.h"
|
||
#include "dbspline.h"
|
||
|
||
#include "dbobjptr.h"
|
||
#include "dbgroup.h "
|
||
#include <Shlwapi.h>
|
||
|
||
//#include <dbwipe.h>
|
||
#include <rxregsvc.h>
|
||
#include <imgdef.h>
|
||
#include <imgent.h>
|
||
|
||
// Zyu add on 100817,门窗三维块文件名
|
||
#define WDLib3D _T("$WDLIB3D$")
|
||
#define U_WDLib3D _T("$U_WDLIB3D$")
|
||
|
||
// extern GEOAPI int GetPickSetByGroup(const TCHAR *szGroup, PickSet &ss);
|
||
// extern GEOAPI int MakeGroup(PickSet &ss, const TCHAR *GroupName, BOOL bClearOld);
|
||
extern GEOAPI int GetClipBoundary(XPoly2D &poly2d);
|
||
// extern GEOAPI Acad::ErrorStatus ExplodeAcis(const AcDbEntity *pEntity, AcDbVoidPtrArray &entSet);
|
||
// extern GEOAPI void MakeVisible(PickSet &ss, bool bTrue);
|
||
// extern GEOAPI int DragPickSet(PickSet &ss, XPoint &ptBase);
|
||
// extern GEOAPI int DragPickSet1(PickSet &ss, XPoint &ptBase);
|
||
// TARCH_IMPEXP void DocStatus();
|
||
|
||
// extern TARCH_IMPEXP void MdiOpenDwgFile(const TCHAR *pszFile, const TCHAR *pszInitCmd);
|
||
// extern GEOAPI XPface * ConstructPolyFace(const AcDbVoidPtrArray &entSet);
|
||
extern GEOAPI BOOL g_bExplodeMesh;
|
||
extern TARCH_IMPEXP BOOL g_bExpOtherDb;
|
||
//extern GEOAPI void WCS2ECS(AcGePoint3d& pt,AcDbObjectId& objId,BOOL bVer=0)
|
||
static void PostAcadCommand(const TCHAR *pszCmd)
|
||
{
|
||
|
||
CWnd *pWnd=acedGetAcadDockCmdLine();
|
||
if (!pWnd) pWnd=acedGetAcadDwgView();
|
||
ASSERT(pWnd);
|
||
//pWnd->SendMessage(WM_CHAR, 27, 65537);
|
||
// Zyu modify on 100722,支持64位
|
||
//int nLen=_tcslen(pszCmd);
|
||
INT_PTR nLen=_tcslen(pszCmd);
|
||
for(int i=0; i<nLen; i++)
|
||
pWnd->SendMessage(WM_CHAR, pszCmd[i]);
|
||
}
|
||
///////////////////////////////////////////////////
|
||
// Zyu modify on 100811,重写SetElev函数
|
||
// Begin
|
||
/*
|
||
static void SetElev(Entity ent)
|
||
{
|
||
int nFlag=0;
|
||
if(ent.Is(_T("LINE")))
|
||
{
|
||
XLine ln(ent);
|
||
ln.StartPoint().z=ln.EndPoint().z=0;
|
||
ln.Modify(&ent);
|
||
}
|
||
else if(ent.Is(_T("ARC")) || ent.Is(_T("CIRCLE"))){
|
||
//XPoint pt;
|
||
//ent.GetData(10, &pt);
|
||
//pt.z=0;
|
||
//ent.SetData(10, &pt);
|
||
//ent.Modify();
|
||
// [3/12/2008 nsh]
|
||
//------------begin-------------
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,AcDbCurve,pEnt)
|
||
if(pEnt)
|
||
{
|
||
XPoint pt;
|
||
if(ent.Is(_T("ARC")))
|
||
{
|
||
pt=((AcDbArc*)pEnt)->center();
|
||
((AcDbArc*)pEnt)->setCenter(XPoint(pt.x,pt.y,0));
|
||
}
|
||
else
|
||
{
|
||
pt=((AcDbCircle*)pEnt)->center();
|
||
((AcDbCircle*)pEnt)->setCenter(XPoint(pt.x,pt.y,0));
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
//----------end--------------
|
||
}
|
||
else if(ent.Is(_T("LWPOLYLINE")))
|
||
{
|
||
//OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbPolyline, pline);
|
||
AcDbEntity *pEnt = NULL;
|
||
Acad::ErrorStatus es;
|
||
AcDbObjectId idFirst;
|
||
acdbGetObjectId(idFirst,ent);
|
||
es = acdbOpenAcDbEntity(pEnt,idFirst,AcDb::kForWrite);
|
||
if (es ==Acad::eOk)
|
||
{
|
||
AcDbPolyline *pline = AcDbPolyline::cast(pEnt);
|
||
if(pline)
|
||
{
|
||
AcGePlane plane;
|
||
AcDb::Planarity type;
|
||
es = pline->getPlane(plane,type);
|
||
AcGeVector3d vec;
|
||
vec = plane.normal();
|
||
AcDb2dPolyline *p2Dline = new AcDb2dPolyline;
|
||
es = pline->convertTo(p2Dline);
|
||
if (es ==Acad::eObjectToBeDeleted)
|
||
{
|
||
delete pline;
|
||
pline = NULL;
|
||
AcDbObjectIterator*pIter = p2Dline->vertexIterator();
|
||
AcDbObjectId id = p2Dline->objectId();
|
||
if (pIter!=NULL)
|
||
{
|
||
for (pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb2dVertex*pVertex=NULL;
|
||
es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
AcGePoint3d ptTem = p2Dline->vertexPosition((*pVertex));
|
||
ptTem.z = 0;
|
||
//WCS2ECS(ptTem,id);
|
||
AcGePoint3d ptVer = Wcs2Ecs(ptTem,vec);
|
||
pVertex->setPosition(ptVer);
|
||
pVertex->close();
|
||
}
|
||
}
|
||
delete pIter;
|
||
}
|
||
p2Dline->close();
|
||
AcDbEntity *pEnt1 = NULL;
|
||
es = acdbOpenAcDbEntity(pEnt1,id,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
pline = new AcDbPolyline;
|
||
pline->convertFrom(pEnt1);
|
||
pline->close();
|
||
}
|
||
}
|
||
//pline->setElevation(0.0);
|
||
}
|
||
}
|
||
//OPENOBJ_END();
|
||
|
||
}
|
||
else if(ent.Is(_T("DIMENSION")))
|
||
{
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbDimension, pDim);
|
||
if(pDim) {
|
||
double nElev=pDim->elevation();
|
||
AcGePoint3d ptText=pDim->textPosition();
|
||
AcGePoint3d ptDimBlk=pDim->dimBlockPosition();
|
||
nElev=0.0;
|
||
ptText[2]=0.0;
|
||
ptDimBlk[2]=0.0;
|
||
pDim->setElevation(nElev);
|
||
ASSERT(fabs(pDim->elevation())<_DIST_SNAP);
|
||
pDim->setTextPosition(ptText);
|
||
pDim->setDimBlockPosition(ptDimBlk);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
ent.FreeGroups();
|
||
for(int i=10; i<16; i++) {
|
||
XPoint pt;
|
||
if(ent.GetData(i, &pt)==RTNORM) {
|
||
pt.z=0;
|
||
ent.SetData(i, &pt);
|
||
}
|
||
}
|
||
ent.Modify();
|
||
} else if(ent.Is(_T("INSERT")))
|
||
{
|
||
XPoint ptIns;
|
||
ent.GetData(10, &ptIns);
|
||
ptIns.z=0;
|
||
ent.SetData(10, &ptIns);
|
||
ent.Modify();
|
||
Entity entnext=ent;
|
||
while(entnext.GetNext()==RTNORM)
|
||
{
|
||
entnext.FreeGroups();
|
||
if(!entnext.Is(_T("ATTRIB")))
|
||
{
|
||
break;
|
||
}
|
||
XPoint pt10, pt11;
|
||
if(entnext.GetData(10, &pt10)==RTNORM)
|
||
{
|
||
pt10.z=0;
|
||
entnext.SetData(10, &pt10);
|
||
}
|
||
if(entnext.GetData(11, &pt11)==RTNORM)
|
||
{
|
||
pt11.z=0;
|
||
entnext.SetData(11, &pt11);
|
||
}
|
||
entnext.Modify();
|
||
}
|
||
ent.Update();
|
||
} else if(ent.Is(_T("TEXT")) || ent.Is(_T("MTEXT")))
|
||
{
|
||
XPoint pt10, pt11;
|
||
if(ent.GetData(10, &pt10)==RTNORM)
|
||
{
|
||
pt10.z=0;
|
||
ent.SetData(10, &pt10);
|
||
}
|
||
if(ent.GetData(11, &pt11)==RTNORM)
|
||
{
|
||
pt11.z=0;
|
||
ent.SetData(11, &pt11);
|
||
}
|
||
ent.Modify();
|
||
} else if(ent.Is(_T("HATCH"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbHatch, pHatch);
|
||
if(pHatch) {
|
||
pHatch->setElevation(0.0);
|
||
}
|
||
OPENOBJ_END();
|
||
//} else if(ent.Is(_T("POLYLINE")) && ent.GetData(70, &nFlag)==RTNORM && nFlag<7) {
|
||
} else if(ent.Is(_T("POLYLINE"))) {
|
||
// [3/12/2008 nsh]
|
||
//--------------begin----------------
|
||
//OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbCurve, pline);
|
||
AcDbEntity *pline = NULL;
|
||
Acad::ErrorStatus es;
|
||
AcDbObjectId idFirst;
|
||
acdbGetObjectId(idFirst,ent);
|
||
es = acdbOpenAcDbEntity(pline,idFirst,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
if(pline->isKindOf(AcDb2dPolyline::desc()))
|
||
{
|
||
|
||
AcDb2dPolyline *p2Dline=AcDb2dPolyline::cast(pline);
|
||
AcGeVector3d vec = p2Dline->normal();
|
||
AcDbObjectIterator*pIter = p2Dline->vertexIterator();
|
||
if (pIter!=NULL)
|
||
{
|
||
for (pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb2dVertex*pVertex=NULL;
|
||
Acad::ErrorStatus es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
AcGePoint3d ptTem = p2Dline->vertexPosition((*pVertex));
|
||
ptTem.z = 0;
|
||
AcGePoint3d ptVec = Wcs2Ecs(ptTem,vec);
|
||
pVertex->setPosition(ptVec);
|
||
pVertex->close();
|
||
}
|
||
}
|
||
delete pIter;
|
||
}
|
||
//p2Dline->setElevation(0.0);
|
||
}
|
||
else
|
||
{
|
||
AcDb3dPolyline *p3Dline=AcDb3dPolyline::cast(pline);
|
||
if(p3Dline)
|
||
{
|
||
AcDbObjectIterator* pIter=p3Dline->vertexIterator();
|
||
if(pIter!=NULL)
|
||
{
|
||
for(pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb3dPolylineVertex*pVertex=NULL;
|
||
Acad::ErrorStatus es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
pVertex->setPosition(XPoint(pVertex->position().x,pVertex->position().y,0.0));
|
||
pVertex->close();
|
||
}
|
||
|
||
}
|
||
delete pIter;
|
||
}
|
||
}
|
||
}
|
||
pline->close();
|
||
pline=NULL;
|
||
}
|
||
//---------------end---------------------
|
||
//OPENOBJ_END();
|
||
} else if(ent.Is(_T("ELLIPSE"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEllipse, pEllipse);
|
||
if(pEllipse) {
|
||
AcGePoint3d ptCen=pEllipse->center();
|
||
ptCen.z=0;
|
||
pEllipse->setCenter(ptCen);
|
||
}
|
||
OPENOBJ_END();
|
||
} else if(ent.Is(_T("SPLINE"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbSpline, pEnt);
|
||
if(pEnt) {
|
||
int num=pEnt->numControlPoints();
|
||
for(int n=0; n<num; n++) {
|
||
AcGePoint3d pt;
|
||
if(pEnt->getControlPointAt(n, pt)==Acad::eOk) {
|
||
pt.z=0;
|
||
pEnt->setControlPointAt(n, pt);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
// sg add 100526,根据8.5需求,支持对CAD的点对象,进行统一标高
|
||
else if (ent.Is(_T("Point")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbPoint, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
AcGePoint3d pt = pEnt->position();
|
||
pt.z = 0;
|
||
pEnt->setPosition(pt);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
*/
|
||
namespace //add by yyc 20160405
|
||
{ //过滤含有特殊字符的图层
|
||
void Springstrfunc(CString& strLayerName, CString strKey)//在每个特殊字符前插入`转义字符
|
||
{
|
||
int idex = strLayerName.Find(strKey);
|
||
do
|
||
{
|
||
if (strLayerName.Find(_T("`")) == (idex - 1 <= 0 ? 0:idex -1))
|
||
{
|
||
idex++;
|
||
continue;
|
||
}
|
||
strLayerName.Insert(idex, _T("`"));
|
||
idex = strLayerName.Find(strKey, (idex+2));
|
||
} while (idex != -1);
|
||
}
|
||
void SpringStr(CString& strLayerName)//所以特殊字符名,拼接处理图层名
|
||
{
|
||
if (strLayerName.Find(_T("@")) != -1)
|
||
Springstrfunc(strLayerName, _T("@"));
|
||
if (strLayerName.Find(_T("#")) != -1)
|
||
Springstrfunc(strLayerName, _T("#"));
|
||
if (strLayerName.Find(_T("$")) != -1)
|
||
Springstrfunc(strLayerName, _T("$"));
|
||
if (strLayerName.Find(_T("!")) != -1)
|
||
Springstrfunc(strLayerName, _T("!"));
|
||
if (strLayerName.Find(_T("%")) != -1)
|
||
Springstrfunc(strLayerName, _T("%"));
|
||
if (strLayerName.Find(_T("^")) != -1)
|
||
Springstrfunc(strLayerName, _T("^"));
|
||
if (strLayerName.Find(_T("~")) != -1)
|
||
Springstrfunc(strLayerName, _T("~"));
|
||
if (strLayerName.Find(_T("&")) != -1)
|
||
Springstrfunc(strLayerName, _T("&"));
|
||
if (strLayerName.Find(_T("+")) != -1)
|
||
Springstrfunc(strLayerName, _T("+"));
|
||
if (strLayerName.Find(_T("-")) != -1)
|
||
Springstrfunc(strLayerName, _T("-"));
|
||
if (strLayerName.Find(_T("[")) != -1)
|
||
Springstrfunc(strLayerName, _T("["));
|
||
if (strLayerName.Find(_T("]")) != -1)
|
||
Springstrfunc(strLayerName, _T("]"));
|
||
if (strLayerName.Find(_T("{")) != -1)
|
||
Springstrfunc(strLayerName, _T("{"));
|
||
if (strLayerName.Find(_T("}")) != -1)
|
||
Springstrfunc(strLayerName, _T("}"));
|
||
if (strLayerName.Find(_T("(")) != -1)
|
||
Springstrfunc(strLayerName, _T("("));
|
||
if (strLayerName.Find(_T(")")) != -1)
|
||
Springstrfunc(strLayerName, _T(")"));
|
||
}
|
||
}
|
||
void SetLineElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbLine, pLine)
|
||
if (pLine != NULL)
|
||
pLine->setThickness(0.0);
|
||
OPENOBJ_END()
|
||
|
||
XLine ln(ent);
|
||
ln.StartPoint().z=ln.EndPoint().z=0;
|
||
// 判断是否处理立面对象
|
||
if (!bModifyElevEnt && (ln.StartPoint() == ln.EndPoint()))
|
||
{
|
||
return;
|
||
}
|
||
ln.Modify(&ent);
|
||
}
|
||
|
||
// Zyu add on 101208,标记是否进行对象类型变化的提示
|
||
bool g_bPrompt = false;
|
||
void SetCurveElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
AcDbCurve *pCurve = NULL;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbCurve, pEnt);
|
||
if (pEnt)
|
||
{
|
||
AcGePlane plane;
|
||
AcDb::Planarity planarity;
|
||
if (Acad::eOk == pEnt->getPlane(plane, planarity))
|
||
{
|
||
// 是否处理立面对象
|
||
if (!bModifyElevEnt
|
||
&& planarity == AcDb::kPlanar
|
||
&& plane.normal().isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 处理平行于XOY平面的对象
|
||
if (plane.normal().isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
// 重置圆弧对象的圆心
|
||
if (pEnt->isKindOf(AcDbArc::desc()))
|
||
{
|
||
AcGePoint3d ptCenter = ((AcDbArc*)pEnt)->center();
|
||
ptCenter.z = 0;
|
||
((AcDbArc*)pEnt)->setCenter(ptCenter);
|
||
((AcDbArc*)pEnt)->setThickness(0.0);
|
||
}
|
||
// 重置圆对象的圆心
|
||
else if (pEnt->isKindOf(AcDbCircle::desc()))
|
||
{
|
||
AcGePoint3d ptCenter = ((AcDbCircle*)pEnt)->center();
|
||
ptCenter.z = 0;
|
||
((AcDbCircle*)pEnt)->setCenter(ptCenter);
|
||
((AcDbCircle*)pEnt)->setThickness(0.0);
|
||
}
|
||
// 重置椭圆对象的圆心
|
||
else if (pEnt->isKindOf(AcDbEllipse::desc()))
|
||
{
|
||
AcGePoint3d ptCenter = ((AcDbEllipse*)pEnt)->center();
|
||
ptCenter.z = 0;
|
||
((AcDbEllipse*)pEnt)->setCenter(ptCenter);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
|
||
// 做XOY平面的投影
|
||
if (Acad::eOk == pEnt->getOrthoProjectedCurve(AcGePlane::kXYPlane, pCurve))
|
||
{
|
||
// 拷贝原曲线的属性
|
||
pCurve->setPropertiesFrom(pEnt);
|
||
|
||
// 替换对象
|
||
if (Acad::eObjectToBeDeleted == pEnt->handOverTo(pCurve))
|
||
{
|
||
pCurve->close();
|
||
delete pEnt;
|
||
// Zyu add on 101208,进行对象类型变化的提示
|
||
g_bPrompt = true;
|
||
}
|
||
else
|
||
{
|
||
delete pCurve;
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetLWPlineElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
AcDbObjectId objId;
|
||
if (Acad::eOk != acdbGetObjectId(objId, ent.name))
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (Acad::eOk != acdbOpenAcDbEntity(pEnt, objId, AcDb::kForWrite))
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (pEnt != NULL)
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
AcDbPolyline *pline = AcDbPolyline::cast(pEnt);
|
||
if(pline)
|
||
{
|
||
pline->setThickness(0.0);
|
||
AcGePlane plane;
|
||
AcDb::Planarity type;
|
||
es = pline->getPlane(plane,type);
|
||
AcGeVector3d vec;
|
||
vec = plane.normal();
|
||
// 是否处理立面对象
|
||
if (!bModifyElevEnt && vec.isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
AcDb2dPolyline *p2Dline = new AcDb2dPolyline;
|
||
es = pline->convertTo(p2Dline);
|
||
if (es ==Acad::eObjectToBeDeleted)
|
||
{
|
||
delete pline;
|
||
pline = NULL;
|
||
AcDbObjectIterator*pIter = p2Dline->vertexIterator();
|
||
AcDbObjectId id = p2Dline->objectId();
|
||
if (pIter!=NULL)
|
||
{
|
||
for (pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb2dVertex*pVertex=NULL;
|
||
es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
AcGePoint3d ptTem = p2Dline->vertexPosition((*pVertex));
|
||
ptTem.z = 0;
|
||
//WCS2ECS(ptTem,id);
|
||
AcGePoint3d ptVer = Wcs2Ecs(ptTem,vec);
|
||
pVertex->setPosition(ptVer);
|
||
pVertex->close();
|
||
}
|
||
}
|
||
delete pIter;
|
||
}
|
||
p2Dline->close();
|
||
AcDbEntity *pEnt1 = NULL;
|
||
es = acdbOpenAcDbEntity(pEnt1,id,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
pline = new AcDbPolyline;
|
||
pline->convertFrom(pEnt1);
|
||
if (vec.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
pline->setElevation(0.0);
|
||
}
|
||
pline->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pEnt->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void SetDimentionElev(TEntitySet ent)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbDimension, pDim);
|
||
if(pDim)
|
||
{
|
||
double nElev=pDim->elevation();
|
||
AcGePoint3d ptText=pDim->textPosition();
|
||
AcGePoint3d ptDimBlk=pDim->dimBlockPosition();
|
||
nElev=0.0;
|
||
ptText[2]=0.0;
|
||
ptDimBlk[2]=0.0;
|
||
pDim->setElevation(nElev);
|
||
ASSERT(fabs(pDim->elevation())<_DIST_SNAP);
|
||
pDim->setTextPosition(ptText);
|
||
pDim->setDimBlockPosition(ptDimBlk);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
ent.FreeGroups();
|
||
for(int i=10; i<16; i++)
|
||
{
|
||
XPoint pt;
|
||
if(ent.GetData(i, &pt)==RTNORM)
|
||
{
|
||
pt.z=0;
|
||
ent.SetData(i, &pt);
|
||
}
|
||
}
|
||
ent.Modify();
|
||
}
|
||
|
||
void SetInsertElev(TEntitySet ent)
|
||
{
|
||
XPoint ptIns;
|
||
ent.GetData(10, &ptIns);
|
||
ptIns.z=0;
|
||
ent.SetData(10, &ptIns);
|
||
ent.Modify();
|
||
Entity entnext=ent;
|
||
while(entnext.GetNext()==RTNORM)
|
||
{
|
||
entnext.FreeGroups();
|
||
if(!entnext.Is(_T("ATTRIB")))
|
||
{
|
||
break;
|
||
}
|
||
XPoint pt10, pt11;
|
||
if(entnext.GetData(10, &pt10)==RTNORM)
|
||
{
|
||
pt10.z=0;
|
||
entnext.SetData(10, &pt10);
|
||
}
|
||
if(entnext.GetData(11, &pt11)==RTNORM)
|
||
{
|
||
pt11.z=0;
|
||
entnext.SetData(11, &pt11);
|
||
}
|
||
entnext.Modify();
|
||
}
|
||
ent.Update();
|
||
}
|
||
|
||
void SetTextElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbText, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
pEnt->setThickness(0.0);
|
||
AcGeVector3d vtNormal = pEnt->normal();
|
||
// 是否处理立面对象
|
||
if (!bModifyElevEnt)
|
||
{
|
||
if (vtNormal.isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
AcGePlane plane;
|
||
AcDb::Planarity type;
|
||
if (Acad::eOk == pEnt->getPlane(plane,type))
|
||
{
|
||
AcGePoint3d ptOrigin;
|
||
AcGeVector3d vtXAxis;
|
||
AcGeVector3d vtYAxis;
|
||
plane.getCoordSystem(ptOrigin, vtXAxis, vtYAxis);
|
||
|
||
vtXAxis.rotateBy(pEnt->rotation(), plane.normal());
|
||
|
||
AcGePoint3d ptLoc = pEnt->position();
|
||
ptLoc.z = 0;
|
||
|
||
// 设置法向为Z轴
|
||
pEnt->setNormal(AcGeVector3d::kZAxis);
|
||
// 设置位置点的标高为0
|
||
pEnt->setPosition(ptLoc);
|
||
// 设置文字方向
|
||
pEnt->setRotation(vtXAxis.angleOnPlane(AcGePlane::kXYPlane));
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetMTextElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbMText, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
// 是否处理立面对象
|
||
if (!bModifyElevEnt && pEnt->normal().isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcGeVector3d vtDir = pEnt->direction();
|
||
// 根据文字方向是否与Z轴平行,调整XOY平面内的文字方向
|
||
if (vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
if (vtDir.isCodirectionalTo(AcGeVector3d::kZAxis))
|
||
{
|
||
vtDir = -pEnt->normal();
|
||
}
|
||
else
|
||
{
|
||
vtDir = pEnt->normal();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
vtDir.z = 0;
|
||
}
|
||
|
||
if (pEnt->normal().z < 0)
|
||
{
|
||
pEnt->setNormal(-AcGeVector3d::kZAxis);
|
||
}
|
||
else
|
||
{
|
||
pEnt->setNormal(AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
pEnt->setDirection(vtDir);
|
||
AcGePoint3d ptLoc = pEnt->location();
|
||
ptLoc.z = 0;
|
||
pEnt->setLocation(ptLoc);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetHatchElev(TEntitySet ent)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbHatch, pHatch);
|
||
if(pHatch)
|
||
{
|
||
pHatch->setElevation(0.0);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetPlineElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pline);
|
||
if (pline != NULL)
|
||
{
|
||
if(pline->isKindOf(AcDb2dPolyline::desc()))
|
||
{
|
||
AcDb2dPolyline *p2Dline=AcDb2dPolyline::cast(pline);
|
||
p2Dline->setThickness(0.0);
|
||
AcGeVector3d vec = p2Dline->normal();
|
||
// 立面对象
|
||
if (vec.isPerpendicularTo(AcGeVector3d::kZAxis))
|
||
{
|
||
// 是否处理
|
||
if(!bModifyElevEnt)
|
||
{
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
AcDbObjectIterator*pIter = p2Dline->vertexIterator();
|
||
if (pIter!=NULL)
|
||
{
|
||
for (pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb2dVertex*pVertex=NULL;
|
||
Acad::ErrorStatus es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
AcGePoint3d ptTem = p2Dline->vertexPosition((*pVertex));
|
||
ptTem.z = 0;
|
||
AcGePoint3d ptVec = Wcs2Ecs(ptTem,vec);
|
||
pVertex->setPosition(ptVec);
|
||
pVertex->close();
|
||
}
|
||
}
|
||
delete pIter;
|
||
}
|
||
}
|
||
}
|
||
// 平行于XOY平面的多段线设置标高为0
|
||
else if (vec.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
p2Dline->setElevation(0);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcDb3dPolyline *p3Dline=AcDb3dPolyline::cast(pline);
|
||
if(p3Dline)
|
||
{
|
||
AcDbObjectIterator* pIter=p3Dline->vertexIterator();
|
||
if(pIter!=NULL)
|
||
{
|
||
for(pIter->start();!pIter->done();pIter->step())
|
||
{
|
||
AcDbObjectId vertId=pIter->objectId();
|
||
AcDb3dPolylineVertex*pVertex=NULL;
|
||
Acad::ErrorStatus es = acdbOpenObject(pVertex,vertId,AcDb::kForWrite);
|
||
if (es == Acad::eOk)
|
||
{
|
||
pVertex->setPosition(XPoint(pVertex->position().x,pVertex->position().y,0.0));
|
||
pVertex->close();
|
||
}
|
||
|
||
}
|
||
delete pIter;
|
||
}
|
||
}
|
||
}
|
||
pline->close();
|
||
pline=NULL;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetSplineElev(TEntitySet ent)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbSpline, pEnt);
|
||
if (pEnt)
|
||
{
|
||
int num=pEnt->numControlPoints();
|
||
for(int n=0; n<num; n++)
|
||
{
|
||
AcGePoint3d pt;
|
||
if (pEnt->getControlPointAt(n, pt)==Acad::eOk)
|
||
{
|
||
pt.z=0;
|
||
pEnt->setControlPointAt(n, pt);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetWipeoutElev(TEntitySet ent)
|
||
{
|
||
#if (ADS < 16)
|
||
if (!AT_loaded(_T("wipeout")))
|
||
{
|
||
int iRet = acrxLoadModule(_T("wipeout.arx"), Adesk::kFalse, true);
|
||
if (!iRet)
|
||
{
|
||
adsout << _T("\n请事先安装AutoCAD快捷工具!");
|
||
return ;
|
||
}
|
||
}
|
||
//LH 2013-2-27 修改原因当ADS=19时不执行下面代码
|
||
//#else if (ADS<19)
|
||
#endif
|
||
#if (16<ADS && ADS<19)
|
||
if (!AT_loaded(_T("AcWipeout")))
|
||
{
|
||
int iRet = acrxLoadModule(_T("AcWipeout.arx"), Adesk::kFalse, true);
|
||
if (!iRet)
|
||
{
|
||
adsout << _T("\n无法加载AcWipeout.arx!");
|
||
return ;
|
||
}
|
||
}
|
||
#endif
|
||
//LH 2013-2-28 由于AutoCAD2013版本后去除了AcWipeout.arx文件,所以2013版本需要判断是否加载了acismobj19.dbx
|
||
#if (ADS==19)
|
||
if(!AT_loaded(_T("acismobj19")))
|
||
{
|
||
int nRet=acrxLoadModule(_T("acismobj19.dbx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n无法加载acismobj19.dbx!");
|
||
return;
|
||
}
|
||
}
|
||
#endif
|
||
#if (ADS==20)
|
||
if(!AT_loaded(_T("acismobj20")))
|
||
{
|
||
int nRet=acrxLoadModule(_T("acismobj20.dbx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n无法加载acismobj20.dbx!");
|
||
return;
|
||
}
|
||
}
|
||
#endif
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbRasterImage, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
AcGePoint3d origin;
|
||
AcGeVector3d u, v;
|
||
|
||
pEnt->getOrientation(origin, u, v);
|
||
origin.z = 0;
|
||
pEnt->setOrientation(origin, u, v);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetPointElev(TEntitySet ent)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbPoint, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
pEnt->setThickness(0.0);
|
||
AcGePoint3d pt = pEnt->position();
|
||
pt.z = 0;
|
||
pEnt->setPosition(pt);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetTDbEntElev(TEntitySet ent, bool bModifyElevEnt = true)
|
||
{
|
||
double dElev = 0;
|
||
// 阳台标高设置为-100
|
||
if (ent.Is(_T("TCH_BALCONY")))
|
||
{
|
||
dElev = -100;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
TEntityBase *pEntBase = TEntityBase::Cast(pEnt);
|
||
if (pEntBase != NULL)
|
||
{
|
||
if (Acad::eOk == pEnt->upgradeOpen())
|
||
{
|
||
pEntBase->UnifyElevation(dElev);
|
||
pEnt->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void SetElev(Entity ent, bool bModifyElevEnt = true)
|
||
{
|
||
if(ent.Is(_T("LINE")))
|
||
{
|
||
SetLineElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("ARC")) || ent.Is(_T("CIRCLE")) || ent.Is(_T("ELLIPSE")))
|
||
{
|
||
SetCurveElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("LWPOLYLINE")))
|
||
{
|
||
SetLWPlineElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("DIMENSION")))
|
||
{
|
||
SetDimentionElev(ent);
|
||
}
|
||
else if(ent.Is(_T("INSERT")))
|
||
{
|
||
SetInsertElev(ent);
|
||
}
|
||
else if(ent.Is(_T("TEXT")))
|
||
{
|
||
SetTextElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("MTEXT")))
|
||
{
|
||
SetMTextElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("HATCH")))
|
||
{
|
||
SetHatchElev(ent);
|
||
}
|
||
else if(ent.Is(_T("POLYLINE")))
|
||
{
|
||
SetPlineElev(ent, bModifyElevEnt);
|
||
}
|
||
else if(ent.Is(_T("SPLINE")))
|
||
{
|
||
SetSplineElev(ent);
|
||
}
|
||
else if (ent.Is(_T("Point")))
|
||
{
|
||
SetPointElev(ent);
|
||
}
|
||
else if (ent.Is(_T("WIPEOUT")))
|
||
{
|
||
SetWipeoutElev(ent);
|
||
}
|
||
else
|
||
{
|
||
SetTDbEntElev(ent, bModifyElevEnt);
|
||
}
|
||
}
|
||
// End
|
||
|
||
void ModifyElev1()
|
||
{
|
||
XSymbolList lstBlocks(_T("BLOCK"));
|
||
for(int i=0; i<lstBlocks.Length(); i++) {
|
||
const TCHAR *szBlock=lstBlocks[i];
|
||
XBlockTable block(szBlock);
|
||
|
||
// Zyu add on 100816,始终不对门窗的三维块做处理
|
||
CString strBlockName(szBlock);
|
||
if ((strBlockName.Find(WDLib3D) != -1)
|
||
|| (strBlockName.Find(U_WDLib3D) != -1))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
// Zyu modify on 101117,首先处理门窗对象,再处理门窗所在的墙对象。
|
||
//do {
|
||
// SetElev(block.ent);
|
||
// block.ent.FreeGroups();
|
||
//} while(block.EntNext()==RTNORM);
|
||
XBlockTable blockOpening(szBlock);
|
||
do
|
||
{
|
||
// 处理门窗对象
|
||
if (blockOpening.ent.Is(_T("TCH_OPENING")))
|
||
{
|
||
SetElev(blockOpening.ent);
|
||
blockOpening.ent.FreeGroups();
|
||
}
|
||
} while (blockOpening.EntNext() == RTNORM);
|
||
|
||
do
|
||
{
|
||
// 处理非门窗对象
|
||
if (!block.ent.Is(_T("TCH_OPENING")))
|
||
{
|
||
SetElev(block.ent);
|
||
block.ent.FreeGroups();
|
||
}
|
||
} while (block.EntNext() == RTNORM);
|
||
}
|
||
//acedPostCommand(_T("Regen\n"));
|
||
}
|
||
|
||
|
||
// Command: 统一标高
|
||
void ModifyElev()
|
||
{
|
||
// 修改描述:修改命令交互,完善对CAD对象的处理,增加对上华对象的操作
|
||
// 修改人、修改时间:Zyu modify on 100719
|
||
/*
|
||
int nAns=YesNoQuestion(_T("\n是否重置包含在图块内的对象的标高"), Q_YES);
|
||
if (nAns==RTCAN)
|
||
return;
|
||
if (nAns==Q_YES)
|
||
ModifyElev1();
|
||
|
||
PickSet ss(SS_FREE);
|
||
g_ssPickFirst.Free();
|
||
if (SelectEntities(_T("\n选择需要恢复零标高的对象:"), ss, RBList())==RTNORM) {
|
||
long lCount=ss.Length();
|
||
for(long i=0L; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
SetElev(ent);
|
||
}
|
||
}
|
||
*/
|
||
|
||
TPickEntSet ss(SS_FREE);
|
||
g_ssPickFirst.Free();
|
||
|
||
// Zyu add on 101208,不提示对象类型的变化
|
||
g_bPrompt = false;
|
||
int iRetCode = RTKWORD; // 返回码
|
||
TCHAR chRet = 0; // 返回的关键字
|
||
static bool bModifyElevEnt = true; // 是否处理立面对象
|
||
static bool bResetBlkEnt = true; // 是否重置块内对象
|
||
CString sPrompt; // 提示
|
||
|
||
while (RTKWORD == iRetCode)
|
||
{
|
||
sPrompt.Format(_T("选择需要恢复零标高的对象或[%s/%s] <退出>:"),
|
||
bModifyElevEnt ? _T("不处理立面视图对象(F),当前:处理") : _T("处理立面视图对象(F),当前:不处理"),
|
||
bResetBlkEnt ? _T("不重置块内对象(Q),当前:重置") : _T("重置块内对象(Q),当前:不重置"));
|
||
|
||
// Zyu modify on 101208,修改提示方式
|
||
//iRetCode = SelectEntities(sPrompt, ss, TRBList(), _T("F Q"), chRet);
|
||
iRetCode = SelectEnts(sPrompt, _T("选择需要恢复零标高的对象<退出>:"), TRBList(), ss, _T("FQ"), chRet);
|
||
|
||
switch (iRetCode)
|
||
{
|
||
case RTKWORD:
|
||
{
|
||
bModifyElevEnt = ((_T('F') == chRet) ? !bModifyElevEnt : bModifyElevEnt);
|
||
bResetBlkEnt = ((_T('Q') == chRet) ? !bResetBlkEnt : bResetBlkEnt);
|
||
}
|
||
break;
|
||
case RTNORM:
|
||
{
|
||
// 是否重置块内对象
|
||
if (bResetBlkEnt)
|
||
{
|
||
ModifyElev1();
|
||
}
|
||
|
||
// Zyu add on 101116,首先处理门窗对象,再处理门窗所在的墙对象。
|
||
TPickEntSet ssOther(SS_FREE);
|
||
ssOther += ss;
|
||
// 过滤出所有门窗对象
|
||
ss.BaseFilter(TRBList(acutBuildList(RTDXF0, _T("TCH_OPENING"), NULL)));
|
||
// 获得其余对象
|
||
ssOther -= ss;
|
||
AcDbObjectIdArray arIds;
|
||
ssOther.AsIdArray(arIds);
|
||
|
||
long lLen = ss.Length();
|
||
// 如果门窗对象所在的墙对象不进行统一标高,则门窗对象也不进行处理,从选择集中移出。
|
||
for (long i = 0; i < lLen;)
|
||
{
|
||
OPENOBJ_BEGIN(ss[i], AcDb::kForRead, TDbOpening, pOpening);
|
||
if (NULL != pOpening)
|
||
{
|
||
// Zyu modify on 101122,修正平台兼容性引起的编译错误
|
||
//if (0 > arIds.find(pOpening->GetWallId()))
|
||
int iFind = -1;
|
||
if (!arIds.find(pOpening->GetWallId(), iFind))
|
||
{
|
||
ss -= ss[i];
|
||
continue;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
i++;
|
||
}
|
||
ss += ssOther;
|
||
|
||
long lCount = ss.Length();
|
||
TEntitySet ent;
|
||
// 设置选中对象的标高
|
||
for(long j = 0L; j < lCount; j++)
|
||
{
|
||
ent = ss[j];
|
||
SetElev(ent, bModifyElevEnt);
|
||
}
|
||
|
||
// Zyu add on 101208,提示对象类型已经改变
|
||
if (g_bPrompt)
|
||
{
|
||
adsout<<_T("\n圆、圆弧已转换为直线或椭圆!");
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
namespace
|
||
{
|
||
//分层遍历图块,解决嵌套块的产生,如果是组的话,也需要将图层
|
||
void HierarchyChangeBlock(AcDbObjectId idEnt, AcDbObjectId objectLayerId)
|
||
{
|
||
OPENOBJ_BEGIN(idEnt, AcDb::kForWrite, AcDbEntity, pEntity);
|
||
if (pEntity)
|
||
{
|
||
pEntity->setLayer(objectLayerId);
|
||
AcCmColor color;
|
||
color.setColorMethod(AcCmEntityColor::kByLayer);
|
||
pEntity->setColor(color);
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
AcDbObjectId idBlock(AcDbObjectId::kNull);
|
||
OPENOBJ_BEGIN(idEnt, AcDb::kForRead, AcDbBlockReference, pBlockRef);
|
||
if (pBlockRef)
|
||
{
|
||
idBlock=pBlockRef->blockTableRecord();
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
if (!idBlock.isValid())
|
||
{
|
||
return;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(idBlock, AcDb::kForWrite, AcDbBlockTableRecord, pOrg)
|
||
if (pOrg)
|
||
{
|
||
AcDbBlockTableRecordIterator *pIterator=NULL;
|
||
pOrg->newIterator( pIterator);
|
||
if (pIterator)
|
||
{
|
||
for (pIterator->start(); !pIterator->done(); pIterator->step())
|
||
{
|
||
AcDbObjectId idEntity;
|
||
Acad::ErrorStatus es = pIterator->getEntityId(idEntity);
|
||
if(es!=Acad::eOk)
|
||
continue;
|
||
HierarchyChangeBlock(idEntity, objectLayerId);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
|
||
//转地形图,实现统一标高并更改图层名称和颜色
|
||
void ConvertReliefmap()
|
||
{
|
||
while (true)
|
||
{
|
||
PickSet ssEntitys(SS_FREE);
|
||
g_ssPickFirst.Free();
|
||
TRBList rbFilter(acutBuildList(RTDXF0, _T("*"), NULL));
|
||
int iRetCode = SelectEntities(_T("\n请选择地形底图<退出>:"), ssEntitys, rbFilter);
|
||
if (iRetCode != RTNORM)
|
||
return;
|
||
|
||
long lCount=ssEntitys.Length();
|
||
if (lCount <= 0)
|
||
return;
|
||
|
||
//统一标高,ModElev命令实现
|
||
ModifyElev1();
|
||
TPickEntSet ssOther(SS_FREE);
|
||
ssOther += ssEntitys;
|
||
ssEntitys.BaseFilter(TRBList(acutBuildList(RTDXF0, _T("TCH_OPENING"), NULL)));// 过滤出所有门窗对象
|
||
ssOther -= ssEntitys;// 获得其余对象
|
||
AcDbObjectIdArray arIds;
|
||
ssOther.AsIdArray(arIds);
|
||
|
||
long lLen = ssEntitys.Length();
|
||
for (long i = 0; i < lLen;)
|
||
{
|
||
OPENOBJ_BEGIN(ssEntitys[i], AcDb::kForRead, TDbOpening, pOpening);
|
||
if (NULL != pOpening)
|
||
{
|
||
int iFind = -1;
|
||
if (!arIds.find(pOpening->GetWallId(), iFind))
|
||
{
|
||
ssEntitys -= ssEntitys[i];
|
||
continue;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
i++;
|
||
}
|
||
ssEntitys += ssOther;
|
||
|
||
lCount = ssEntitys.Length();
|
||
TEntitySet ent;
|
||
// 设置选中对象的标高
|
||
for(long j = 0L; j < lCount; j++)
|
||
{
|
||
ent = ssEntitys[j];
|
||
SetElev(ent);
|
||
}
|
||
if (g_bPrompt)
|
||
{
|
||
adsout<<_T("\n圆、圆弧已转换为直线或椭圆!");
|
||
}
|
||
|
||
//设置图层
|
||
|
||
//根据图层关键字
|
||
|
||
//CString strKey(_T("地形"));
|
||
//CString strName(_T("RMAP"));
|
||
//CString strLineType(_T("CONTINUOUS"));
|
||
//int nColorIndex = 252;//RMAP指定图层颜色
|
||
//
|
||
//GetLayerInfoByKeyWord(strKey, strName, strLineType, nColorIndex);
|
||
//AcDbObjectId objectLayerId = GetLayerIdFromString(strName);
|
||
//if (!objectLayerId)
|
||
//{
|
||
// objectLayerId = MakeLayer(strName, FALSE);
|
||
// TAcDbLayerTableRecPtr tLayer(strName, AcDb::kForWrite);
|
||
// if (!tLayer)
|
||
// return;
|
||
|
||
// AcDbLayerTableRecord &lay = tLayer;
|
||
// lay.setIsLocked(Adesk::kTrue);
|
||
|
||
// AcCmColor cmColor;
|
||
// if (cmColor.setColorIndex(nColorIndex) == Acad::eOk)
|
||
// lay.setColor(cmColor);
|
||
|
||
// AcDbObjectId idLineType = InitLineType(strLineType);
|
||
// if(!idLineType.isNull())
|
||
// lay.setLinetypeObjectId(idLineType);
|
||
//}
|
||
AcDbObjectId objectLayerId = InitLayer(LAY_RAMP);
|
||
TAcDbLayerTableRecPtr tLayer(LAY_RAMP, AcDb::kForWrite);
|
||
if (!tLayer)
|
||
return;
|
||
|
||
AcDbLayerTableRecord &lay = tLayer;
|
||
lay.setIsLocked(Adesk::kTrue);
|
||
|
||
lCount = ssEntitys.Length();
|
||
for (long i=0L; i<lCount; i++)
|
||
{
|
||
Entity ent = ssEntitys[i];
|
||
AcDbObjectId endId;
|
||
acdbGetObjectId(endId, ent);
|
||
HierarchyChangeBlock(endId, objectLayerId);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
void DragCopy()
|
||
{
|
||
extern TARCH_IMPEXP BOOL g_bDragRubber;
|
||
AcAxDocLock docLock;
|
||
VERIFY(docLock.lockStatus() == Acad::eOk);
|
||
|
||
PickSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("*"), NULL);
|
||
if (SelectEntities(_T("\n请选择要拷贝的对象: "), ss, mask)==RTNORM) {
|
||
XPoint ptLow, ptUp;
|
||
ss.GetExtend(ptLow, ptUp);
|
||
ptLow=Wcs2Ucs(ptLow);
|
||
|
||
while(1) {
|
||
PickSet ss1(SS_FREE);
|
||
ss1.IncludeBegin();
|
||
{
|
||
XPushVar<int> tVar(_T("OSMODE"), 0);
|
||
// Zyu modify on 100721,支持64位
|
||
//ads_command(RTSTR, _T("COPY"), RTPICKS, (long *)ss, RTS TR, _T(""),
|
||
// RTSTR, _T("0,0"), RTSTR, _T("0,0"), RTNONE);
|
||
ads_command(RTSTR, _T("COPY"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RTSTR, _T("0,0"), RTSTR, _T("0,0"), RTNONE);
|
||
}
|
||
ss1.IncludeEnd();
|
||
if (g_bDragRubber) {
|
||
if (DragPickSet1(ss1, ptLow)!=RTNORM) {
|
||
ss1.Erase();
|
||
break;
|
||
} else {
|
||
ss.Free();
|
||
ss += ss1;
|
||
}
|
||
} else {
|
||
if (DragPickSet(ss1, ptLow)!=RTNORM) {
|
||
ss1.Erase();
|
||
break;
|
||
} else {
|
||
ss.Free();
|
||
ss += ss1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
void DragMove()
|
||
{
|
||
AcAxDocLock docLock;
|
||
VERIFY(docLock.lockStatus() == Acad::eOk);
|
||
|
||
PickSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("*"), NULL);
|
||
if (SelectEntities(_T("\n请选择要移动的对象: "), ss, mask)==RTNORM) {
|
||
//add by whl on 051201
|
||
PickSet ssWin(SS_FREE);
|
||
for(long i=0;i<ss.Length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(ss[i],AcDb::kForRead,TDbWall,pWall)
|
||
if (pWall!=NULL)
|
||
{
|
||
const DList<AcDbSoftPointerId> &lstWin=pWall->GetOpeningIdList();
|
||
for(long j=0;j<lstWin.Length();j++)
|
||
ssWin+=lstWin[j];
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
ss+=ssWin;
|
||
|
||
XPoint ptLow, ptUp;
|
||
ss.GetExtend(ptLow, ptUp);
|
||
ptLow=Wcs2Ucs(ptLow);
|
||
ads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), RTNONE);
|
||
if (DragPickSet(ss, ptLow)!=RTNORM) {
|
||
ads_command(RTSTR, _T(".UNDO"), RTSTR, _T("BACK"), RTNONE);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Command: 粘贴
|
||
void PasteClip()
|
||
{
|
||
//modify by xlc on 090706 剪贴板为空时返回,解决提示未知命令的问题
|
||
//if (GetClipboardOwner()==NULL)
|
||
{
|
||
//adsout<<_T("\n剪贴板为空,请重新选择!");
|
||
//return;
|
||
}
|
||
if (OpenClipboard(NULL))
|
||
{
|
||
UINT nFormat=EnumClipboardFormats(0);
|
||
HANDLE hClipboardData = GetClipboardData(nFormat);
|
||
char *pchData = (char*)GlobalLock(hClipboardData);
|
||
if (pchData==NULL)
|
||
{
|
||
adsout<<_T("\n剪贴板为空,请重新选择!");
|
||
CloseClipboard();
|
||
return;
|
||
}
|
||
CloseClipboard();
|
||
}
|
||
|
||
{
|
||
COleDataObject obj;
|
||
if (!obj.AttachClipboard())
|
||
return;
|
||
|
||
//#include _T("AcTc_i.h")
|
||
// CIAcadToolCopyPaste iP;
|
||
// COleVariant bOk(FALSE);
|
||
// iP.CanPaste(obj,bOk);
|
||
// if (!bOk.boolVal)
|
||
// return;
|
||
}
|
||
|
||
AcAxDocLock docLock;
|
||
VERIFY(docLock.lockStatus() == Acad::eOk);
|
||
PickSet ss(SS_FREE);
|
||
|
||
ss.IncludeBegin();
|
||
ads_command(RTSTR, _T(".PASTECLIP"), RTSTR, _T("0,0"), RTNONE);
|
||
ss.IncludeEnd();
|
||
if (ss.Length()) {
|
||
XPoint ptBase;
|
||
if (DragPickSet(ss,ptBase)!=RTNORM)
|
||
{
|
||
if (ADS > 19)
|
||
ss.Delete();
|
||
else
|
||
ss.Erase();
|
||
}
|
||
}
|
||
}
|
||
|
||
void RelMove()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("*"), NULL);
|
||
if (SelectEntities(_T("\n请选择要移动的对象: "), ss, mask)==RTNORM)
|
||
{
|
||
//add by whl on 051201
|
||
PickSet ssWin(SS_FREE);
|
||
for(long i=0;i<ss.Length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(ss[i],AcDb::kForRead,TDbWall,pWall)
|
||
if (pWall!=NULL)
|
||
{
|
||
const DList<AcDbSoftPointerId> &lstWin=pWall->GetOpeningIdList();
|
||
for(long j=0;j<lstWin.Length();j++)
|
||
ssWin+=lstWin[j];
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
ss+=ssWin;
|
||
|
||
int nRet;
|
||
XPoint vt;
|
||
XString sVt;
|
||
INITGET_BEG(0, _T("X Y Z"));
|
||
nRet=ads_getstring(0, _T("\n请输入位移(x,y,z)或 [横移(X)/纵移(Y)/竖移(Z)]<退出>: "), sVt);
|
||
INITGET_END();
|
||
if (nRet==RTNORM) {
|
||
if (!sVt)
|
||
return;
|
||
double nDist=0;
|
||
if (sVt[0]==_T('X')) {
|
||
if (GetDist(_T("\n横移"), nDist)==RTNORM)
|
||
vt.x=nDist;
|
||
} else if (sVt[0]==_T('Y')) {
|
||
if (GetDist(_T("\n纵移"), nDist)==RTNORM)
|
||
vt.y=nDist;
|
||
} else if (sVt[0]==_T('Z')) {
|
||
if (GetDist(_T("\n竖移"), nDist)==RTNORM)
|
||
vt.z=nDist;
|
||
} else {
|
||
if (_stscanf(sVt, _T("%lf,%lf,%lf"), &vt.x, &vt.y, &vt.z)<1) {
|
||
adsout << _T("\n格式错误!");
|
||
return;
|
||
}
|
||
}
|
||
XPoint org;
|
||
ads_matrix mat;
|
||
org.GetMoveMatrix(vt, mat);
|
||
ads_xformss(ss, mat);
|
||
}
|
||
}
|
||
}
|
||
|
||
void T3DOrbit()
|
||
{
|
||
int nExpMode=IsExplode3D();
|
||
if (!nExpMode) {
|
||
adsout << _T("\n不能对二维视图进行三维动态观察!");
|
||
return;
|
||
}
|
||
|
||
int viewmode;
|
||
xg_getvar(_T("VIEWMODE"), &viewmode);
|
||
if (!(viewmode&0x01)) { //透视状态下无需设置Camera和Target
|
||
ads_command(RTSTR, _T("CAMERA"), RTSTR, _T(""), RTSTR, _T(""), RTNONE);
|
||
XPoint ptViewCtr, ptCamera, vtViewDir, ptTarget;
|
||
xg_getvar(_T("VIEWCTR"), &ptViewCtr);
|
||
VERIFY(xg_getvar(_T("VIEWDIR"), &vtViewDir)==RTNORM);
|
||
ptTarget=ptViewCtr;
|
||
{
|
||
XPushVar<int> vTemp(_T("APERTURE"), 20);
|
||
if (ads_osnap(ptViewCtr, _T("NEA"), ptTarget)!=RTNORM) {
|
||
ptTarget=ptViewCtr;
|
||
int nOsMode=0;
|
||
xg_getvar(_T("OSMODE"), &nOsMode);
|
||
nOsMode &= ~0x4000;
|
||
nOsMode |= OS_NEA;
|
||
XPushVar<int> osmode(_T("OSMODE"), nOsMode);
|
||
if (XGetPoint(NULL, _T("\n请点取观察中心"), ptTarget)!=RTNORM)
|
||
return;
|
||
}
|
||
}
|
||
|
||
XPushVar<int> vTemp1(_T("OSMODE"), 0);
|
||
ptCamera = vtViewDir + ptTarget;
|
||
ads_command(RTSTR, _T("CAMERA"), RT3DPOINT, &ptCamera, RT3DPOINT, &ptTarget, RTNONE);
|
||
}
|
||
PostAcadCommand(_T("3DORBIT\n"));
|
||
}
|
||
|
||
|
||
////////////////////////////////////////////
|
||
// Command: 反转pline
|
||
void RevPline()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("POLYLINE,LWPOLYLINE,TCH_CURVEMESH2,TCH_PATH_ARRAY,TCH_WALL,TCH_CURTAIN_WALL"), NULL);
|
||
Entity ent;
|
||
if (SelectEntity(_T("\n选择要反转的PLINE、墙体、线图案或路径曲面:"), ent, rbMask)==RTNORM)
|
||
{
|
||
if (ent.Is(_T("TCH_CURVEMESH2"))||ent.Is(_T("TCH_PATH_ARRAY")))
|
||
{
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,TDbCurveEntity,pEnt);
|
||
if (pEnt!=NULL)
|
||
{
|
||
AcGeVector3d vt;
|
||
XPoly2D poly;
|
||
pEnt->GetPathPoly(poly,vt);
|
||
poly.Reverse();
|
||
pEnt->SetPathPoly(poly,vt);
|
||
if (poly.IsClosed())
|
||
{
|
||
adsout << _T("\n曲线对象现在变为")
|
||
<< (poly.PathArea()>0? _T("顺时针") : _T("逆时针")) << _T("!");
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("TCH_WALL"))||ent.Is(_T("TCH_CURTAIN_WALL")))//add by whl on 060213
|
||
{
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,TDbWall,pEnt);
|
||
if (pEnt!=NULL && !pEnt->Is(CURVE_ARC))// [12/24/2007 nsh]
|
||
{
|
||
pEnt->assertWriteEnabled();
|
||
Exchange(pEnt->StartPoint(),pEnt->EndPoint());
|
||
double lw=pEnt->GetWidth(0),rw=pEnt->GetWidth(1);
|
||
pEnt->SetWidth(0,rw);
|
||
pEnt->SetWidth(1,lw);
|
||
|
||
//add by whl on 070713
|
||
if (pEnt->Is(CURVE_LINE))//直线墙上的窗会翻转,因此要提前处理
|
||
{
|
||
const DList<AcDbSoftPointerId> &lstOpening=pEnt->GetOpeningIdList();
|
||
for(long i=0;i<lstOpening.Length();i++)
|
||
{
|
||
TDbOpening* pOpening=NULL;
|
||
acdbOpenObject(pOpening,lstOpening[i],AcDb::kForWrite);
|
||
if (pOpening!=NULL)
|
||
{
|
||
pOpening->m_nRotation=pEnt->Direction(pOpening->m_ptLocation);
|
||
XPoint ptLabel=pOpening->GetLabelPos();
|
||
pOpening->MirrorSelf(TRUE);
|
||
pOpening->MirrorSelf(FALSE);
|
||
pOpening->SetLabelPos(ptLabel);//因为MirrorSelf有会修改这个
|
||
|
||
pOpening->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
pEnt->UpdateAssocObjectGraphics();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
XString sEntType;
|
||
XPoly2D poly(ent);
|
||
poly.Reverse();
|
||
if (ent.GetData(0, (TCHAR *)sEntType)==RTNORM && _tcsicmp(sEntType, _T("LWPOLYLINE"))==0) {
|
||
AcDbPolyline *pline=NULL;
|
||
XDbObject obj(ent, AcDb::kForWrite);
|
||
if (!!obj) {
|
||
pline=AcDbPolyline::cast(obj.m_pObject);
|
||
if (pline) {
|
||
ASSERT(poly.Length()==int(pline->numVerts()));
|
||
for(int i=0; i<poly.Length(); i++) {
|
||
pline->setPointAt(i, poly[i]->AsAcGePoint2d());
|
||
pline->setBulgeAt(i, tan(poly.GetBulge(i)/4));
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
XString sLayer;
|
||
ent.GetData(8, (TCHAR *)sLayer);
|
||
ent.Delete();
|
||
poly.Make(sLayer);
|
||
}
|
||
poly.SetFlag(poly.GetFlag() | 0x01);
|
||
// poly.flag |= 0x01;
|
||
adsout << _T("\npline现在变为")
|
||
<< (poly.PathArea()>0? _T("顺时针") : _T("逆时针")) << _T("!");
|
||
}
|
||
}
|
||
}
|
||
/////////////////////////////////////////////////////////////////////
|
||
class TAppFileOpenBuf {
|
||
public:
|
||
const TCHAR *pszFileName;
|
||
const TCHAR *pszCmd;
|
||
|
||
TAppFileOpenBuf() {pszFileName=NULL; pszCmd=NULL;}
|
||
};
|
||
|
||
void
|
||
openSyncDocHelper( void *pData)
|
||
{
|
||
AcApDocument* pDoc = acDocManager->curDocument();
|
||
if (acDocManager->isApplicationContext()) {
|
||
TAppFileOpenBuf *pbuf=(TAppFileOpenBuf *)pData;
|
||
acDocManager->appContextOpenDocument(pbuf->pszFileName);
|
||
if (pbuf->pszCmd)
|
||
acedPostCommand(pbuf->pszCmd);
|
||
} else
|
||
acutPrintf(_T("\nERROR: in Document context : %s\n"),pDoc->fileName());
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
///////////////////////////////////////////
|
||
|
||
static XPoint g_ptViewMin;
|
||
static XPoint g_ptViewMax;
|
||
static double g_sV;
|
||
|
||
static ads_real View_p()
|
||
{
|
||
ads_point p;
|
||
ads_real view_h;
|
||
struct resbuf *res;
|
||
|
||
res=ads_newrb(RTPOINT);
|
||
ads_getvar(_T("SCREENSIZE"),res);
|
||
ads_point_set(res->resval.rpoint,p);
|
||
ads_relrb(res);
|
||
res=ads_newrb(RTREAL);
|
||
ads_getvar(_T("VIEWSIZE"),res);
|
||
view_h=res->resval.rreal;
|
||
ads_relrb(res);
|
||
return view_h/p[Y];
|
||
}
|
||
|
||
// 消除重线
|
||
int InitDup()
|
||
{
|
||
extern GEOAPI BOOL g_bEchoSearch;
|
||
XPushMemVar<BOOL> vTemp(g_bEchoSearch, TRUE);
|
||
XSymbolList lstLayers(_T("LAYER"));
|
||
for(int i=0; i<lstLayers.Length(); i++) {
|
||
PickSet ss(SS_FREE);
|
||
RBList mask=ads_buildlist(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, lstLayers[i], 67, 0, NULL);
|
||
//adsout << _T(".");
|
||
if (ss.Get(_T("X"), NULL, NULL, mask)==RTNORM) {
|
||
long oldLen=ss.Length();
|
||
DList<XCurveSegment> lstCurves;
|
||
for(long idx=0L; idx<oldLen; idx++) {
|
||
Entity ent=ss[idx];
|
||
lstCurves.Append(new XCurveSegment(ent));
|
||
}
|
||
|
||
HandleCurveDup(ss);
|
||
}
|
||
}
|
||
return RTNORM;
|
||
}
|
||
|
||
|
||
// Step1:
|
||
void ConvertTo2D()
|
||
{
|
||
void IConvert2DPrep();
|
||
|
||
//add by whl on 050603
|
||
#if ADS>15
|
||
XPoint ptMin,ptMax;
|
||
AT_ScrCorner(ptMin, ptMax);
|
||
PickSet ssExt(SS_FREE);
|
||
ssExt.IncludeBegin();
|
||
XRectAngle(ptMin,ptMax).Make();
|
||
ssExt.IncludeEnd();
|
||
#endif
|
||
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("X"));
|
||
|
||
//写出WMF文件
|
||
XString sTempPath(256), sShortPath(256);
|
||
GetTempPath(255, sTempPath);
|
||
sTempPath << _T("TCHWMF.WMF");
|
||
{
|
||
XPushVar<int> filedia(0);
|
||
// Zyu modify on 100721,支持64位
|
||
//ads_command(RTSTR, _T("WMFOUT"), RTSTR, (TCHAR *)sTempPath, RTPICKS, (long *)ss, RTSTR, _T(""), RTNONE);
|
||
ads_command(RTSTR, _T("WMFOUT"), RTSTR, (TCHAR *)sTempPath, RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""), RTNONE);
|
||
}
|
||
|
||
//add by whl on 050603
|
||
#if ADS>15
|
||
ssExt.Erase();
|
||
#endif
|
||
|
||
IConvert2DPrep();
|
||
}
|
||
|
||
// Step2:
|
||
void IConvert2DPrep()
|
||
{
|
||
XString sElevDwg;
|
||
xg_getvar(_T("DWGPREFIX"), sElevDwg);
|
||
if (GetFileDia(sElevDwg, 1, _T("dwg"), _T("输入新生成的文件名"))!=RTNORM)
|
||
return;
|
||
XString sTemplate;
|
||
//sTemplate << g_sAppPath << _T("acad.dwt");
|
||
if (!FindFile(_T("acad.dwt"), sTemplate) || !CopyFile(sTemplate, sElevDwg, FALSE)) {
|
||
adsout << _T("\n不能覆盖生成") << sElevDwg;
|
||
return;
|
||
}
|
||
|
||
|
||
AT_ScrCorner(g_ptViewMin, g_ptViewMax);
|
||
g_sV = View_p();
|
||
XString sCmd;
|
||
sCmd << _T("(C:") << GetFullCmdName(_T("_IMap2D")) << _T(")\n");
|
||
MdiOpenDwgFile(sElevDwg, sCmd);
|
||
}
|
||
|
||
// Step3:
|
||
void IConvert2D()
|
||
{
|
||
XString sTempPath(256), sShortPath(256);
|
||
GetTempPath(255, sTempPath);
|
||
sTempPath << _T("TCHWMF.WMF");
|
||
if (!FindFile(sTempPath))
|
||
return;
|
||
//GetShortPathName(sTempPath, sShortPath, 255);
|
||
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
ads_command(RTSTR, _T(".ZOOM"), RT3DPOINT, &g_ptViewMin, RT3DPOINT, &g_ptViewMax, RTNONE);
|
||
XPoint ptLeftUp(g_ptViewMin.x, g_ptViewMax.y);
|
||
{
|
||
XPushVar<int> filedia(0);
|
||
ads_command(RTSTR, _T(".WMFIN"), RTSTR, (TCHAR *)sTempPath, RT3DPOINT, &ptLeftUp,
|
||
RTREAL, 1.0, RTREAL, 1.0, RTREAL, 0.0, RTNONE);
|
||
}
|
||
//----------------------------------------------------------
|
||
ads_name en;
|
||
ads_entlast(en);
|
||
Entity ent;
|
||
ent=en;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbBlockReference, pBlk);
|
||
if (pBlk) {
|
||
AcGeScale3d bScale = pBlk->scaleFactors();
|
||
AcDbExtents bExtent;
|
||
pBlk->getGeomExtents(bExtent);
|
||
AcGePoint3d pMax = bExtent.maxPoint();
|
||
AcGePoint3d pMin = bExtent.minPoint();
|
||
|
||
double sX = pMax[0]-pMin[0];
|
||
double sY = pMax[1]-pMin[1];
|
||
|
||
bScale[0] = (g_ptViewMax.x-g_ptViewMin.x) / (sX-g_sV*0.5);
|
||
bScale[1] = (g_ptViewMax.y-g_ptViewMin.y) / sY;
|
||
|
||
bScale[0]=bScale[1]=(bScale[0]+bScale[1])/2.0;//add by whl on 050603
|
||
//ads_printf(_T("\nX=%0.5f Y=%.5f"),bScale[0],bScale[1]);
|
||
pBlk->setScaleFactors(bScale);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
PickSet ssPline(SS_FREE|SS_CREATE);
|
||
ssPline.IncludeBegin();
|
||
ads_command(RTSTR, _T(".EXPLODE"), RTENAME, en, RTNONE);
|
||
ssPline.IncludeEnd();
|
||
{
|
||
ssPline.BaseFilter(RBList(RTDXF0, _T("POLYLINE,LWPOLYLINE"), NULL));
|
||
long lCount=ssPline.Length();
|
||
for(long i=0L; i<lCount; i++) {
|
||
AcDbVoidPtrArray entitySet;
|
||
Entity ent=ssPline[i];
|
||
XDbObject obj(ent, AcDb::kForWrite);
|
||
if (!obj) continue;
|
||
AcDbEntity *pEnt=AcDbEntity::cast(obj.m_pObject);
|
||
if (pEnt->explode(entitySet)==Acad::eOk) {
|
||
long lNum=entitySet.length();
|
||
for(long j=0L; j<lNum; j++) {
|
||
AcDbEntity *pEnt=(AcDbEntity *)entitySet[j];
|
||
AddToModelSpace(pEnt, Adesk::kTrue);
|
||
}
|
||
pEnt->erase();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (YesNoQuestion(_T("\n是否进行消除重线"))==Q_YES) {
|
||
//XPushPrec vPrec(6.0, 5.0/360.0*PI); //2度的误差内进行
|
||
// [11/5/2007 nsh]
|
||
XPushPrec vPrec(_AS_SYS_UNIT(6.0), 5.0/360.0*PI);
|
||
//------------------------------------------------
|
||
InitDup();
|
||
}
|
||
_tremove(sTempPath);
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////
|
||
// 立面坐标系
|
||
void ElevUcs()
|
||
{
|
||
XPoint ptOrg, ptX;
|
||
if (XGetPoint(NULL,_T("\n立面坐标系原点"), ptOrg)!=RTNORM ||
|
||
XGetPoint(ptOrg, _T("\nX轴正方向"), ptX)!=RTNORM ||
|
||
ptOrg==ptX)
|
||
return;
|
||
ptOrg=Ucs2Wcs(ptOrg);
|
||
ptX=Ucs2Wcs(ptX);
|
||
XPoint ptY=ptOrg;
|
||
ptY.z += 100.0;
|
||
|
||
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, &ptOrg,
|
||
RT3DPOINT, &ptX, RT3DPOINT, &ptY, RTNONE);
|
||
ads_command(RTSTR, _T(".PLAN"), RTSTR, _T(""), RTNONE);
|
||
|
||
}
|
||
|
||
|
||
|
||
void UpdateDwgView()
|
||
{
|
||
acedGetAcadDwgView()->Invalidate();
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
// 处理炸开实体
|
||
Acad::ErrorStatus
|
||
DealExplodeSolide(PickSet &sset, AcDbVoidPtrArray &entSet)
|
||
{
|
||
// 取得选择集中的第一个实体
|
||
long ssLength = sset.Length();
|
||
for(long iLength = 0L;iLength<ssLength;iLength++)
|
||
{
|
||
Entity entres = sset[iLength];
|
||
OPENOBJ_BEGIN(entres, AcDb::kForRead, AcDbEntity, pEnt);
|
||
ExplodeAcis(pEnt, entSet);
|
||
OPENOBJ_END();
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
// Command:实体转面
|
||
void ExplSolid()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择ACIS对象:"), ss, RBList(RTDXF0, _T("3DSOLID,3DBODY,REGION"), NULL))==RTNORM) {
|
||
long ssLength = ss.Length();
|
||
for(long iLength = 0L;iLength<ssLength;iLength++) {
|
||
Entity entres = ss[iLength];
|
||
TCHAR szLay[256]=_T("");
|
||
entres.GetData(8, szLay);
|
||
OPENOBJ_BEGIN(entres, AcDb::kForRead, AcDbEntity, pEnt);
|
||
AcDbVoidPtrArray entSet;
|
||
ExplodeAcis(pEnt, entSet);
|
||
XPface *pMesh=ConstructPolyFace(entSet);
|
||
if (pMesh) {
|
||
entres.Delete();
|
||
pMesh->Make(szLay);
|
||
delete pMesh;
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
OPENOBJ_END();
|
||
}
|
||
ss.Erase();
|
||
}
|
||
}
|
||
|
||
// Command: 三维面转多格面
|
||
void PolyFace()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择三维面(3DFACE):"), ss, RBList(RTDXF0, _T("3DFACE"), NULL))==RTNORM) {
|
||
AcDbVoidPtrArray entSet;
|
||
long len=ss.Length();
|
||
for(long i=0L; i<len; i++) {
|
||
Entity ent=ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbFace, pFace);
|
||
if (pFace)
|
||
entSet.append(pFace->clone());
|
||
OPENOBJ_END();
|
||
}
|
||
XPface *pMesh=ConstructPolyFace(entSet);
|
||
if (pMesh) {
|
||
ss.Erase();
|
||
pMesh->Make();
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
}
|
||
}
|
||
|
||
// Command: 隐去边线
|
||
void HideEdge()
|
||
{
|
||
Entity entFace;
|
||
RBList mask=ads_buildlist(RTDXF0, _T("3DFACE,POLYLINE"),NULL);
|
||
XPoint ptPick;
|
||
XPushVar<int> osmode(_T("OSMODE"), OS_NEA);
|
||
while(entFace.FilterSelect1(GetPickBoxWcs(), _T("\n点取3DFace或PFace的边:"), mask, ptPick)==RTNORM) {
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
if (entFace.Is(_T("3DFACE"))) {
|
||
X3DFace face(entFace);
|
||
for(int i=0; i<4; i++) {
|
||
int iNext=i+1;
|
||
if (iNext==4)
|
||
iNext=0;
|
||
XLine ln(face.GetVertex(i), face.GetVertex(iNext));
|
||
if (ln.GetLength()>_DIST_SNAP) {
|
||
if ((ptPick&ln)==PR_INSIDE) {
|
||
int nFlagBit=(0x01<<i);
|
||
face.SetFlag(face.GetFlag() | nFlagBit);
|
||
//face.flag |= nFlagBit;
|
||
face.Modify(entFace);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
OPENOBJ_BEGIN(entFace, AcDb::kForRead, AcDbPolyFaceMesh, pMesh);
|
||
if (pMesh) {
|
||
AcDbObjectIterator *pIterator=pMesh->vertexIterator();
|
||
ASSERT(pIterator);
|
||
XPointList lstVertexes;
|
||
for (pIterator->start(); !pIterator->done(); pIterator->step()) {
|
||
AcDbObjectId idSubEnt=pIterator->objectId();
|
||
XDbObject subObj(idSubEnt, AcDb::kForRead);
|
||
ASSERT(!!subObj);
|
||
if (subObj.m_pObject->isKindOf(AcDbPolyFaceMeshVertex::desc())) {
|
||
AcDbPolyFaceMeshVertex *pSubEnt=AcDbPolyFaceMeshVertex::cast(subObj.m_pObject);
|
||
ASSERT(pSubEnt);
|
||
AcGePoint3d ptVertex=pSubEnt->position();
|
||
lstVertexes.Append(new XPoint(ptVertex));
|
||
} else if (subObj.m_pObject->isKindOf(AcDbFaceRecord::desc())) {
|
||
AcDbFaceRecord *pSubEnt=AcDbFaceRecord::cast(subObj.m_pObject);
|
||
ASSERT(pSubEnt);
|
||
|
||
for(int idx=0; idx<4; idx++) {
|
||
Adesk::Int16 vtxIndex=0, vtxIndex1=0; // ARX SDK 的文档有错
|
||
int iNext=idx+1;
|
||
if (iNext==4)
|
||
iNext=0;
|
||
if (pSubEnt->getVertexAt(idx, vtxIndex)==Acad::eOk &&
|
||
pSubEnt->getVertexAt(iNext, vtxIndex1)==Acad::eOk) {
|
||
ASSERT(vtxIndex!=0 && vtxIndex1!=0);
|
||
ASSERT(abs(vtxIndex)<=lstVertexes.Length());
|
||
ASSERT(abs(vtxIndex1)<=lstVertexes.Length());
|
||
XPoint pt1=*lstVertexes[abs(vtxIndex)-1];
|
||
XPoint pt2=*lstVertexes[abs(vtxIndex1)-1];
|
||
if (vtxIndex>0) {
|
||
XLine ln(pt1, pt2);
|
||
if ((ptPick&ln)==PR_INSIDE) {
|
||
if (pSubEnt->upgradeOpen()==Acad::eOk) {
|
||
pSubEnt->makeEdgeInvisibleAt(idx);
|
||
pSubEnt->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
adsout << _T("\n点取的对象既不是3DFace,也不是PFace!");
|
||
}
|
||
}
|
||
delete pIterator;
|
||
if (pMesh->upgradeOpen()==Acad::eOk) {
|
||
pMesh->recordGraphicsModified();
|
||
pMesh->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// Command: 隐去边线
|
||
void UnHideEdge()
|
||
{
|
||
Entity entFace;
|
||
RBList mask=ads_buildlist(RTDXF0, _T("3DFACE,POLYLINE"),NULL);
|
||
XPoint ptPick;
|
||
XPushVar<int> osmode(_T("OSMODE"), OS_NEA);
|
||
while(entFace.FilterSelect1(GetPickBoxWcs(), _T("\n点取3DFace或PFace的边:"), mask, ptPick)==RTNORM) {
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
if (entFace.Is(_T("3DFACE"))) {
|
||
X3DFace face(entFace);
|
||
for(int i=0; i<4; i++) {
|
||
int iNext=i+1;
|
||
if (iNext==4)
|
||
iNext=0;
|
||
XLine ln(face.GetVertex(i), face.GetVertex(iNext));
|
||
if (ln.GetLength()>_DIST_SNAP) {
|
||
if ((ptPick&ln)==PR_INSIDE) {
|
||
int nFlagBit=(0x01<<i);
|
||
face.SetFlag(face.GetFlag() & (~nFlagBit));
|
||
//face.flag &= ~nFlagBit;
|
||
face.Modify(entFace);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
OPENOBJ_BEGIN(entFace, AcDb::kForRead, AcDbPolyFaceMesh, pMesh);
|
||
if (pMesh) {
|
||
AcDbObjectIterator *pIterator=pMesh->vertexIterator();
|
||
ASSERT(pIterator);
|
||
XPointList lstVertexes;
|
||
for (pIterator->start(); !pIterator->done(); pIterator->step()) {
|
||
AcDbObjectId idSubEnt=pIterator->objectId();
|
||
XDbObject subObj(idSubEnt, AcDb::kForRead);
|
||
ASSERT(!!subObj);
|
||
if (subObj.m_pObject->isKindOf(AcDbPolyFaceMeshVertex::desc())) {
|
||
AcDbPolyFaceMeshVertex *pSubEnt=AcDbPolyFaceMeshVertex::cast(subObj.m_pObject);
|
||
ASSERT(pSubEnt);
|
||
AcGePoint3d ptVertex=pSubEnt->position();
|
||
lstVertexes.Append(new XPoint(ptVertex));
|
||
} else if (subObj.m_pObject->isKindOf(AcDbFaceRecord::desc())) {
|
||
AcDbFaceRecord *pSubEnt=AcDbFaceRecord::cast(subObj.m_pObject);
|
||
ASSERT(pSubEnt);
|
||
|
||
for(int idx=0; idx<4; idx++) {
|
||
Adesk::Int16 vtxIndex=0, vtxIndex1=0; // ARX SDK 的文档有错
|
||
int iNext=idx+1;
|
||
if (iNext==4)
|
||
iNext=0;
|
||
if (pSubEnt->getVertexAt(idx, vtxIndex)==Acad::eOk &&
|
||
pSubEnt->getVertexAt(iNext, vtxIndex1)==Acad::eOk) {
|
||
ASSERT(vtxIndex!=0 && vtxIndex1!=0);
|
||
ASSERT(abs(vtxIndex)<=lstVertexes.Length());
|
||
ASSERT(abs(vtxIndex1)<=lstVertexes.Length());
|
||
XPoint pt1=*lstVertexes[abs(vtxIndex)-1];
|
||
XPoint pt2=*lstVertexes[abs(vtxIndex1)-1];
|
||
if (vtxIndex>0) {
|
||
XLine ln(pt1, pt2);
|
||
if ((ptPick&ln)==PR_INSIDE) {
|
||
if (pSubEnt->upgradeOpen()==Acad::eOk) {
|
||
pSubEnt->makeEdgeVisibleAt(idx);
|
||
pSubEnt->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
adsout << _T("\n点取的对象既不是3DFace,也不是PFace!");
|
||
}
|
||
}
|
||
delete pIterator;
|
||
if (pMesh->upgradeOpen()==Acad::eOk) {
|
||
pMesh->recordGraphicsModified();
|
||
pMesh->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
#if !defined(NDEBUG)
|
||
|
||
void SplitPoly()
|
||
{
|
||
Entity ent;
|
||
RBList mask(RTDXF0, _T("POLYLINE,LWPOLYLINE"), NULL);
|
||
if (SelectEntity(_T("\nSelect polyline: "), ent, mask)==RTNORM) {
|
||
XPoly2D poly(ent);
|
||
if (!poly.IsClosed())
|
||
return ;
|
||
XPoint pt1, pt2;
|
||
if (XGetPoint(NULL, _T("\nstart point: "), pt1)==RTNORM &&
|
||
XGetPoint(pt1, _T("\nend point: "), pt2)==RTNORM) {
|
||
XPoly2D poly1(0), poly2(0);
|
||
if (SplitPoly2D(poly, pt1, pt2, poly1, poly2)==RTNORM) {
|
||
ent.Delete();
|
||
poly1.Make();
|
||
poly2.Make();
|
||
}
|
||
}
|
||
}
|
||
return ;
|
||
}
|
||
|
||
#endif
|
||
|
||
|
||
|
||
|
||
/////////////////////////////////////////
|
||
// Command: 测量模型界限
|
||
void GetExtend()
|
||
{
|
||
extern TARCH_IMPEXP BOOL g_bQuickCalWallExtent;
|
||
XPushMemVar<BOOL> vTemp(g_bQuickCalWallExtent,FALSE);
|
||
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择对象:"), ss, RBList(RTDXF0, _T("*"), NULL))==RTNORM) {
|
||
Point low, up;
|
||
int rc=ss.GetExtend(low, up);
|
||
if (rc==RTNONE) {
|
||
ads_printf(_T("\n不能求解!"));
|
||
return;
|
||
}
|
||
adsout << _T("\nX=") << (up.x-low.x)
|
||
<< _T("; Y=") << (up.y-low.y)
|
||
<< _T("; Z=") << (up.z-low.z);
|
||
|
||
up.z = low.z;
|
||
XRectAngle box(low, up);
|
||
XScreenDc dc;
|
||
dc.m_nDrawMode=1;
|
||
XPoly2D poly2d(1);
|
||
box.AsPoly2D(poly2d);
|
||
poly2d.TransUCS(Groups(0), Groups(1));
|
||
dc << poly2d;
|
||
}
|
||
}
|
||
|
||
//----- add by xlc 07/4/6--------------------------
|
||
//将可以修改的实体和无法修改的实体分开
|
||
void FilterEnt(PickSet &ss, //[in/out]需要修改的
|
||
PickSet &ssRemain //[out]无法修改的
|
||
)
|
||
{
|
||
long len=ss.Length();
|
||
ssRemain.Free();
|
||
if (len < 1)
|
||
{
|
||
return;
|
||
}
|
||
|
||
for(long i=len-1;i>=0;i--)
|
||
{
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt)
|
||
{
|
||
AcDbObjectId idLayer = pEnt->layerId();
|
||
OPENOBJ_BEGIN(idLayer, AcDb::kForRead, AcDbLayerTableRecord, pLayer);
|
||
if (pLayer)
|
||
{
|
||
if (pLayer->isLocked())
|
||
{
|
||
ssRemain += ss[i];
|
||
ss -= ss[i];
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
// Command: 局部隐藏
|
||
void MakeHide()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择对象:"), ss, RBList())==RTNORM)
|
||
{
|
||
//---------add by xlc 07/4/10----
|
||
PickSet ssTemp(SS_FREE|SS_CREATE);
|
||
FilterEnt(ss,ssTemp);
|
||
//---------add end---------------
|
||
|
||
if (MakeGroup(ss, _T("_TCH_HIDE_GROUP"), FALSE)==RTNORM)
|
||
{
|
||
MakeVisible(ss, false);
|
||
adsout << _T("\n选中的") << (int)ss.Length() << _T("个对象被隐藏起来!");
|
||
|
||
//---------add by xlc 07/4/10----
|
||
if (ssTemp.Length() > 0)
|
||
{
|
||
adsout << _T("\n选中的") << (int)ssTemp.Length() << _T("个对象无法隐藏!请检查是否图层锁定!");
|
||
}
|
||
//---------add end---------------
|
||
}
|
||
}
|
||
TArchCmdReactor::ResetAll();
|
||
}
|
||
|
||
|
||
// Command: 局部可见
|
||
void LocalVisible()
|
||
{
|
||
int cvport=0;
|
||
xg_getvar(_T("CVPORT"), &cvport);
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择对象:"), ss, RBList())==RTNORM) {
|
||
PickSet ssAll(SS_FREE);
|
||
int nCode=cvport==1? 1 : 0;
|
||
ssAll.Get(_T("X"), NULL, NULL, RBList(67, nCode, NULL));
|
||
ssAll -= ss;
|
||
|
||
//---------add by xlc 07/4/9----
|
||
PickSet ssTemp(SS_FREE|SS_CREATE);
|
||
FilterEnt(ssAll,ssTemp);
|
||
//---------add end---------------
|
||
|
||
if (MakeGroup(ssAll, _T("_TCH_HIDE_GROUP"), FALSE)==RTNORM)
|
||
{
|
||
MakeVisible(ssAll, false);
|
||
adsout << _T("\n其他") << (int)ssAll.Length() << _T("个对象被隐藏起来!");
|
||
|
||
//---------add by xlc 07/4/10----
|
||
if (ssTemp.Length() > 0)
|
||
{
|
||
adsout << _T("\n其他") << (int)ssTemp.Length() << _T("个对象无法隐藏!请检查是否图层锁定!");
|
||
}
|
||
//---------add end---------------
|
||
}
|
||
}
|
||
TArchCmdReactor::ResetAll();
|
||
}
|
||
|
||
|
||
// Command: 恢复可见
|
||
//add by xlc on 07/04/09
|
||
//擦除名字为strName的空组
|
||
void EraseNullGroup(CString strName)
|
||
{
|
||
AcDbDictionary *pGroupDict = NULL;
|
||
if ( acdbHostApplicationServices()->workingDatabase()
|
||
->getGroupDictionary(pGroupDict, AcDb::kForRead) == Acad::eOk )
|
||
{
|
||
AcDbObjectId idGroup;
|
||
pGroupDict->getAt(strName, idGroup);
|
||
pGroupDict->close();
|
||
|
||
AcDbObjectPointer<AcDbGroup> pGroup(idGroup, AcDb::kForWrite);
|
||
if (pGroup.openStatus() == Acad::eOk)
|
||
{
|
||
if (pGroup->numEntities() == 0)
|
||
pGroup->erase();
|
||
}
|
||
pGroup->close();
|
||
}
|
||
}
|
||
//modify by xlc on 07/04/06
|
||
/*void UnHide()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
if (GetPickSetByGroup(_T("_TCH_HIDE_GROUP"), ss)==RTNORM)
|
||
{
|
||
MakeVisible(ss, true);//如果ss中有对象被锁定
|
||
adsout << _T("\n处于隐藏状态的") << (int)ss.Length() << _T("个对象恢复可见!");//注意如果ss中有锁定内容,这一句就不对
|
||
PickSet ssTemp(SS_FREE|SS_CREATE);
|
||
MakeGroup(ssTemp, _T("_TCH_HIDE_GROUP"), TRUE);//注意如果ss中有锁定内容,ssTemp应是剩余未成功恢复可见内容。
|
||
}
|
||
else
|
||
{
|
||
if (YesNoQuestion(_T("\n未发现明显隐藏组!是否需要进行全图搜索?",FALSE)))//可能是个空组,也可能组不存在,但都有可能有隐藏内容
|
||
{
|
||
//搜索全图以得到隐藏对象,放入ss中。
|
||
//adsout << _T("\n处于隐藏状态的") << (int)ss.Length() << _T("个对象恢复可见!");
|
||
//最后要删除_TCH_HIDE_GROUP,能找到的话
|
||
}
|
||
else
|
||
return;
|
||
}
|
||
|
||
|
||
TArchCmdReactor::ResetAll();
|
||
}*/
|
||
|
||
void UnHide()
|
||
{
|
||
PickSet ss(SS_FREE);
|
||
GetPickSetByGroup(_T("_TCH_HIDE_GROUP"), ss);
|
||
|
||
if (ss.Length() == 0)//空组或无组
|
||
{
|
||
if (YesNoQuestion(_T("\n未发现明显隐藏组!是否需要进行全图搜索"),FALSE))//可能是个空组,也可能组不存在,但都有可能有隐藏内容
|
||
{
|
||
//---------add by xlc 07/4/10----
|
||
int cvport=0;
|
||
xg_getvar(_T("CVPORT"), &cvport);
|
||
int nCode=cvport==1? 1 : 0;
|
||
PickSet ssAll;
|
||
ssAll.Get(_T("X"), NULL, NULL, RBList(67, nCode, NULL));
|
||
|
||
long len=ssAll.Length();
|
||
for(long i=0;i<len;i++)
|
||
{
|
||
Entity ent=ssAll[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt)
|
||
{
|
||
if (pEnt->visibility() == AcDb::kInvisible)
|
||
{
|
||
ss+=ssAll[i];
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
//---------add end---------------
|
||
|
||
}
|
||
else
|
||
return;
|
||
}
|
||
|
||
PickSet ssTemp(SS_FREE|SS_CREATE);
|
||
FilterEnt(ss,ssTemp);
|
||
|
||
MakeVisible(ss, true);
|
||
adsout << _T("\n处于隐藏状态的") << (int)ss.Length() << _T("个对象恢复可见!");
|
||
|
||
//--------add by xlc 07/04/06----------
|
||
int nNum=(int)ssTemp.Length(); //无法修改的实体数
|
||
if (nNum>0)
|
||
{
|
||
adsout << _T("\n处于隐藏状态的") << nNum << _T("个对象无法恢复可见!请检查是否图层锁定!");
|
||
}
|
||
|
||
MakeGroup(ssTemp, _T("_TCH_HIDE_GROUP"), TRUE);
|
||
EraseNullGroup(_T("_TCH_HIDE_GROUP"));
|
||
//--------add end----------
|
||
|
||
TArchCmdReactor::ResetAll();
|
||
}
|
||
|
||
|
||
//视口放大命令,用于布局空间. add by zyu on 10/01/12
|
||
void PMaxVport()
|
||
{
|
||
int iTileMode = 0, iCVPort = 0;
|
||
VERIFY(xg_getvar(_T("TILEMODE"), &iTileMode) == RTNORM);
|
||
VERIFY(xg_getvar(_T("CVPORT"), &iCVPort) == RTNORM);
|
||
|
||
Entity ent;
|
||
ads_point ptCenter;
|
||
double dHeight;
|
||
|
||
if (1 == iCVPort)
|
||
{ //布局空间
|
||
RBList mask(RTDXF0, _T("VIEWPORT"), NULL);
|
||
if (SelectEntity(_T("\n请点取要放大的视口<退出>:"), ent, mask) != RTNORM)
|
||
{
|
||
return ;
|
||
}
|
||
int iVPortNum;//获得实体的CVPort号
|
||
VERIFY(ent.GetData(69, &iVPortNum));
|
||
|
||
MSpace(iVPortNum);//在获得ptCenter之前,一定要Mspace.
|
||
|
||
struct resbuf viewctr;
|
||
ads_getvar(_T("VIEWCTR"), &viewctr);
|
||
VERIFY(xg_getvar(_T("VIEWSIZE"), &dHeight));
|
||
ptCenter[X] = viewctr.resval.rpoint[X];
|
||
ptCenter[Y] = viewctr.resval.rpoint[Y];
|
||
ptCenter[Z] = viewctr.resval.rpoint[Z];
|
||
|
||
//Ucs to Wcs
|
||
ads_trans(ptCenter, (resbuf *)&Groups(1), (resbuf *)&Groups(0), false, ptCenter);
|
||
|
||
PSpace();
|
||
}
|
||
else if (0 == iTileMode)
|
||
{ //在布局空间下,输入过mspace命令.
|
||
if (GetViewport(iCVPort, ent) != RTNORM)
|
||
{
|
||
return ;
|
||
}
|
||
|
||
struct resbuf viewctr;
|
||
ads_getvar(_T("VIEWCTR"), &viewctr);
|
||
VERIFY(xg_getvar(_T("VIEWSIZE"), &dHeight));
|
||
ptCenter[X] = viewctr.resval.rpoint[X];
|
||
ptCenter[Y] = viewctr.resval.rpoint[Y];
|
||
ptCenter[Z] = viewctr.resval.rpoint[Z];
|
||
|
||
//Ucs to Wcs.
|
||
ads_trans(ptCenter, (resbuf *)&Groups(1), (resbuf *)&Groups(0), false, ptCenter);
|
||
}
|
||
else
|
||
{ //在模型空间
|
||
acutPrintf(_T("\n只能在布局空间(TILEMODE=0)下使用!"));
|
||
return;
|
||
}
|
||
|
||
VERIFY(xg_setvar(_T("TILEMODE"), 1) == RTNORM);//回到模型空间.
|
||
|
||
//Wcs to Ucs.
|
||
ads_trans(ptCenter, (resbuf *)&Groups(0), (resbuf *)&Groups(1), false, ptCenter);
|
||
|
||
ads_command(RTSTR, _T(".ZOOM"),
|
||
RTSTR, _T("C"),
|
||
RT3DPOINT, ptCenter,
|
||
RTREAL, dHeight,
|
||
RTNONE);
|
||
|
||
ads_point ptScale;
|
||
VERIFY(ent.GetData(10, &ptScale) == RTNORM);
|
||
|
||
DocSetPScale(ptScale[Z]);// 设置比例.
|
||
};
|
||
|
||
// Command: 视口放大
|
||
// Modify on 2002/10/15, 对于单视口,不进行任何操作
|
||
void MaxVport()
|
||
{
|
||
int nTileMode=0;
|
||
VERIFY(xg_getvar(_T("TILEMODE"), &nTileMode)==RTNORM);
|
||
if (nTileMode==0)
|
||
{
|
||
// sg modify 100120,两个视口放大命令合并,统一为旧的TMaxVport
|
||
// adsout << _T("\n只能在“模型”布局(TILEMODE=1)下使用!");
|
||
PMaxVport();
|
||
return;
|
||
}
|
||
|
||
DList<TViewportInfo> ss;
|
||
ReadVports(ss);
|
||
if (ss.Length()>1) {
|
||
XPushVar<int> expert(_T("EXPERT"), 4);
|
||
ads_command(RTSTR, _T("-VPORTS"), RTSTR, _T("S"), RTSTR, _T("_TCH_VPBACKUP"), RTNONE);
|
||
ads_command(RTSTR, _T("-VPORTS"), RTSTR, _T("SI"), RTNONE);
|
||
}
|
||
}
|
||
|
||
// Command: 视口恢复
|
||
void ResVport()
|
||
{
|
||
int nTileMode=0;
|
||
VERIFY(xg_getvar(_T("TILEMODE"), &nTileMode)==RTNORM);
|
||
if (nTileMode==0) {
|
||
adsout << _T("\n只能在“模型”布局(TILEMODE=0)下使用!");
|
||
return;
|
||
}
|
||
ads_command(RTSTR, _T("-VPORTS"), RTSTR, _T("R"), RTSTR, _T("_TCH_VPBACKUP"),
|
||
RTNONE);
|
||
}
|
||
|
||
|
||
// Command: 有厚度的线变面
|
||
void ThickCurve2Face()
|
||
{
|
||
RBList mask=ads_buildlist(RTDXF0, _T("LINE,ARC,CIRCLE,LWPOLYLINE"),
|
||
-4, _T(">"), 39, 10.0, NULL);
|
||
PickSet ssCurve(SS_FREE);
|
||
const TCHAR *prompts[2]={_T("选择有厚度的曲线"), _T("移除物体")};
|
||
|
||
if (ads_ssget(_T(":$"), prompts, NULL, mask, ssCurve)!=RTNORM)
|
||
return;
|
||
|
||
|
||
long lCount=ssCurve.Length();
|
||
for(long i=0L; i<lCount; i++) {
|
||
Entity ent=ssCurve[i];
|
||
double nThick=0.0;
|
||
ent.GetData(39, &nThick);
|
||
XPoint vtNormal(0,0,1);
|
||
ent.GetData(210, &vtNormal);
|
||
AcDbEntity *pEntNew=NULL;
|
||
if (ent.Is(_T("LINE"))) {
|
||
XLine ln(ent);
|
||
if (ln.GetLength()>_DIST_SNAP) {
|
||
XPoint vt=vtNormal;
|
||
vt *= nThick;
|
||
pEntNew=new AcDbFace(ln.StartPoint(), ln.EndPoint(),
|
||
(const XPoint &)(ln.EndPoint()+vt),
|
||
(const XPoint &)(ln.StartPoint()+vt));
|
||
AddToModelSpace(pEntNew, Adesk::kFalse);
|
||
}
|
||
} else if (ent.Is(_T("ARC")) || ent.Is(_T("CIRCLE")) || ent.Is(_T("LWPOLYLINE"))) {
|
||
AcDbVoidPtrArray entSet;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbCurve, pEnt);
|
||
TMasterProperties prop;
|
||
prop.SetFrom(pEnt);
|
||
if (pEnt)
|
||
InitModel(prop, pEnt, NULL, entSet);
|
||
OPENOBJ_END();
|
||
XPface *pMesh=ConstructPolyFace(entSet);
|
||
if (pMesh) {
|
||
pMesh->Make(_T("0"));
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
AcDbObjectId idLast;
|
||
acdbGetObjectId(idLast, entLast.name);
|
||
acdbOpenObject(pEntNew, idLast, AcDb::kForWrite);
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
|
||
}
|
||
if (pEntNew) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
||
pEntNew->setPropertiesFrom(pEnt);
|
||
pEnt->erase();
|
||
OPENOBJ_END();
|
||
pEntNew->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
// 由线转pface
|
||
void Line2Face()
|
||
{
|
||
GEOAPI void xdRemoveDupCurves(DList<XCurveSegment> &lstCurves, BOOL bExactDup,BOOL bIntsect);
|
||
//extern GEOAPI XPface * ConstructPolyFace(const AcDbVoidPtrArray &entSet);
|
||
RBList mask=ads_buildlist(RTDXF0, _T("LINE,POLYLINE,LWPOLYLINE"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
if (SelectEntities(_T("\n选择构成面的边(LINE/PLINE): "), ss, mask)!=RTNORM)
|
||
return;
|
||
|
||
DList<XCurveSegment> lstCurves;
|
||
long lCount=ss.Length();
|
||
for(long i=0L; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
if (ent.Is(_T("LINE"))) {
|
||
XCurveSegment *pSeg=new XCurveSegment(ent);
|
||
pSeg->SetElevation(0.0);
|
||
if (pSeg->GetLength()<_DIST_SNAP)
|
||
delete pSeg;
|
||
else
|
||
lstCurves.Append(pSeg);
|
||
} else {
|
||
XPoly2D poly2d(ent);
|
||
poly2d.SetElevation(0.0);
|
||
if (!poly2d.HasArcSegment()) {
|
||
ExplodePoly2D(poly2d, lstCurves);
|
||
}
|
||
}
|
||
}
|
||
DList<XPoly2D> lstRegions; //搜索闭合区域
|
||
|
||
// Search Begin ...
|
||
xdRemoveDupCurves(lstCurves, FALSE, TRUE);
|
||
XSearchRegionFromCurve aSearch;
|
||
try {
|
||
aSearch.InitStart(lstCurves);
|
||
} catch(...) {
|
||
adsout << _T("\n发生例外情况!");
|
||
return;
|
||
}
|
||
|
||
if (aSearch.SearchRegions()) {
|
||
DList<int> lstOut;
|
||
aSearch.GetOutsideRegions1(lstOut);
|
||
int nOutSideNum=lstOut.Length();
|
||
|
||
for(int n=0; n<aSearch.m_regions.Length(); n++) {
|
||
BOOL bIsOutSide=FALSE;
|
||
for(int k=0; k<nOutSideNum; k++) {
|
||
if (n==*lstOut[k]) {
|
||
bIsOutSide=TRUE;
|
||
break;
|
||
}
|
||
}
|
||
if (bIsOutSide)
|
||
continue;
|
||
|
||
XPoly2D *pNewPoly=new XPoly2D;
|
||
VERIFY(aSearch.m_regions[n]->CenterPoly2D(*pNewPoly)==RTNORM);
|
||
pNewPoly->Compress();
|
||
if (pNewPoly->PathArea()>0.0)
|
||
pNewPoly->Reverse(); //变为逆时针
|
||
lstRegions.Append(pNewPoly);
|
||
}
|
||
}
|
||
// End Search
|
||
|
||
|
||
DList<X3DFace> lstFaces; //搜索获得的面
|
||
for(int k=0; k<lstRegions.Length(); k++) {
|
||
XPoly poly;
|
||
lstRegions[k]->MapToPolygon(poly);
|
||
XPolygonEx polygon(poly);
|
||
polygon.SetElevation(0.0);
|
||
if (polygon.Length()<3)
|
||
continue;
|
||
if (polygon.Length()<=4 && polygon.IsConvex()) {//凸的4边形或三角形
|
||
X3DFace *pFace=new X3DFace;
|
||
for(int m=0; m<polygon.Length(); m++)
|
||
pFace->GetVertex(m) = *polygon[m];
|
||
if (polygon.Length()==3)
|
||
pFace->GetVertex(3)=pFace->GetVertex(0);
|
||
lstFaces.Append(pFace);
|
||
} else {
|
||
DList<XTriangle> lstTris;
|
||
polygon.Trianglize(lstTris, TRUE);
|
||
for(int m=0; m<lstTris.Length(); m++) {
|
||
X3DFace *pFace=new X3DFace;
|
||
lstTris[m]->AsFace(*pFace);
|
||
lstFaces.Append(pFace);
|
||
}
|
||
}
|
||
}
|
||
|
||
AcDbVoidPtrArray entSet;
|
||
for(k=0; k<lstFaces.Length(); k++)
|
||
entSet.append(lstFaces[k]->AsDbFace());
|
||
if (entSet.length()>=1) {
|
||
XPface *pMesh=ConstructPolyFace(entSet);
|
||
if (pMesh) {
|
||
pMesh->Make();
|
||
delete pMesh;
|
||
}
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
static int nAnsLast=Q_YES;
|
||
int nAns=YesNoQuestion(_T("\n是否删除原始的边线"), nAnsLast);
|
||
if (nAns==Q_YES) {
|
||
ss.Delete();
|
||
nAnsLast=nAns;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
// Command: 对象选择
|
||
// Modified on 2004/2/23 by ZJQ: 增加颜色和线型过滤
|
||
//void SelObject()
|
||
//{
|
||
// PickSet ssFirst(SS_FREE);
|
||
// ssFirst += g_ssPickFirst;
|
||
// g_ssPickFirst.Free();
|
||
//
|
||
// CWnd *pWnd=acedGetAcadFrame();
|
||
// CSelectFilterDlg dlg(pWnd);
|
||
// {
|
||
// CAcModuleResourceOverride vTemp;
|
||
// dlg.Create(dlg.IDD, pWnd);
|
||
// }
|
||
// acedGetAcadDwgView()->SetFocus();
|
||
//
|
||
// Entity ent;
|
||
// int rt=SelectEntity1(_T("\n请选择一个参考图元<退出>:"), ent, XPoint(), RBList());
|
||
// dlg.UpdateData(TRUE);
|
||
// if (::IsWindow(dlg.m_hWnd))
|
||
// dlg.DestroyWindow();
|
||
//
|
||
// if (rt==RTNORM) {
|
||
// RBList rbMask;
|
||
// if (dlg.m_bObject) {
|
||
// TCHAR szDxf[256]=_T("");
|
||
// ent.GetData(0, szDxf);
|
||
// resbuf *rb=ads_buildlist(RTDXF0, szDxf, NULL);
|
||
// rbMask.Append(rb);
|
||
// }
|
||
// if (dlg.m_bLayer) {
|
||
// TCHAR szLayer[256]=_T("");
|
||
// ent.GetData(8, szLayer);
|
||
// resbuf *rb=ads_buildlist(8, szLayer, NULL);
|
||
// rbMask.Append(rb);
|
||
// }
|
||
// BOOL bColorDefault=FALSE;
|
||
// BOOL bLinetypeDefault=FALSE;
|
||
// if (dlg.m_bColor) {
|
||
// int nColor;
|
||
// if (ent.GetData(62, &nColor)==RTNORM) {
|
||
// resbuf *rb=ads_buildlist(62, nColor, NULL);
|
||
// rbMask.Append(rb);
|
||
// } else
|
||
// bColorDefault=TRUE;
|
||
// }
|
||
// if (dlg.m_bLinetype) {
|
||
// TCHAR szLinetype[256]=_T("");
|
||
// if (ent.GetData(6, szLinetype)==RTNORM) {
|
||
// resbuf *rb=ads_buildlist(6, szLinetype, NULL);
|
||
// rbMask.Append(rb);
|
||
// } else
|
||
// bLinetypeDefault=TRUE;
|
||
// }
|
||
// if (dlg.m_bBlockName) {
|
||
// if (ent.Is(_T("INSERT")) || ent.Is(_T("TCH_BLOCK_INSERT"))) {
|
||
// TCHAR szBlockName[256]=_T("");
|
||
// if (ent.GetData(2, szBlockName)==RTNORM) {
|
||
// resbuf *rb=ads_buildlist(2, szBlockName, NULL);
|
||
// rbMask.Append(rb);
|
||
// }
|
||
// } else if (ent.Is(_T("TCH_OPENING"))) {
|
||
// TCHAR szBlockName[256]=_T("");
|
||
// if (ent.GetData(302, szBlockName)==RTNORM) {
|
||
// resbuf *rb=ads_buildlist(302, szBlockName, NULL);
|
||
// rbMask.Append(rb);
|
||
// }
|
||
// }else if (ent.Is(_T("TCH_TEXT"))||ent.Is(_T("TEXT"))){//add by whl on 04/06/15
|
||
// TCHAR szText[256]=_T("");
|
||
// if (ent.GetData(1,szText)==RTNORM){
|
||
// resbuf *rb=ads_buildlist(1, szText, NULL);
|
||
// rbMask.Append(rb);
|
||
// }
|
||
// }
|
||
// }
|
||
// ads_sssetfirst(NULL, NULL);
|
||
//
|
||
// adsout << _T("\n提示:空选即为全选,中断用ESC!");
|
||
// PickSet ss(SS_FREE);
|
||
// const TCHAR *szPrompts[2]={ _T("选择对象:"), _T("移除对象:") };
|
||
// rt=ss.Get(_T(":$-I"), szPrompts, NULL, rbMask);
|
||
// if (rt==RTNONE || rt==RTERROR) {
|
||
// rt=ss.Get(_T("X"), NULL, NULL, rbMask);
|
||
// }
|
||
// if (bColorDefault || bLinetypeDefault) {
|
||
// PickSet ssExclude(SS_FREE);
|
||
// long num=ss.Length();
|
||
// for(long n=0L; n<num; n++) {
|
||
// Entity e=ss[n];
|
||
// if (bColorDefault) {
|
||
// int nColor=0;
|
||
// if (e.GetData(62, &nColor)==RTNORM && nColor!=256)
|
||
// ssExclude += e;
|
||
// }
|
||
// if (bLinetypeDefault) {
|
||
// TCHAR szLinetype[256]=_T("");
|
||
// if (e.GetData(6, szLinetype)==RTNORM && _tcsicmp(szLinetype, _T("BYLAYER"))!=0)
|
||
// ssExclude += e;
|
||
// }
|
||
// }
|
||
// ss -= ssExclude;
|
||
// }
|
||
// if (rt==RTNORM) {
|
||
// ss += ssFirst;
|
||
// adsout << _T("\n总共选中了") << int(ss.Length()) << _T("个,其中新选了")
|
||
// << int (ss.Length()-ssFirst.Length()) << _T("个。");
|
||
// rt=ads_sssetfirst(ss, ss);
|
||
// } else {
|
||
// ads_sssetfirst(ssFirst, ssFirst);
|
||
// }
|
||
// } else {
|
||
// }
|
||
//
|
||
// //return rt;
|
||
//}
|
||
|
||
|
||
// 判断属性是否匹配
|
||
bool Adjust(bool bType, CString szdxf,
|
||
bool bLayer, CString szLayer,
|
||
bool bColor, int nColor,
|
||
bool bLineType, CString szLineType,
|
||
bool bBlockName, bool bIsBlock, CString szBlockName,
|
||
bool bOpeningName, bool bIsOpening, CString szOpeningName,
|
||
bool bText, bool bIsText, CString szText,
|
||
bool bColumnSize, bool bIsColumn, double dHeight, int iMaterial, int iShape, double dArea, double dLength,
|
||
bool bMaterial, bool bIsColumnOrWall, int nMaterial,
|
||
Entity &ent)
|
||
{ // 比较这些属性是否都相同
|
||
TCHAR szBuf[100];
|
||
if (bType)
|
||
{
|
||
ent.GetData(0, szBuf);
|
||
if (szdxf.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
|
||
if (bLayer)
|
||
{
|
||
ent.GetData(8, szBuf);
|
||
if (szLayer.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
|
||
if (bColor)
|
||
{
|
||
int nColorTemp = -1;
|
||
if (ent.GetData(62, &nColorTemp) != RTNORM)
|
||
nColorTemp = 256; // CAD内置以层为颜色数值
|
||
|
||
if (nColorTemp != nColor)
|
||
return false;
|
||
}
|
||
|
||
if (bLineType)
|
||
{
|
||
if (ent.GetData(6, szBuf) != RTNORM)
|
||
::StrCpy(szBuf, _T("bylayer"));
|
||
|
||
if (szLineType.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
|
||
if (bBlockName)
|
||
{
|
||
if (bIsBlock)
|
||
{
|
||
if (ent.Is(_T("INSERT")) || ent.Is(_T("TCH_BLOCK_INSERT")))
|
||
{
|
||
ent.GetData(2, szBuf);
|
||
if (szBlockName.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bOpeningName)
|
||
{
|
||
if (bIsOpening)
|
||
{
|
||
if (ent.Is(_T("TCH_OPENING")))
|
||
{
|
||
ent.GetData(302, szBuf);
|
||
if (szOpeningName.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bText)
|
||
{
|
||
if (bIsText)
|
||
{
|
||
if (ent.Is(_T("TCH_TEXT"))||ent.Is(_T("TEXT")))
|
||
{
|
||
ent.GetData(1,szBuf);
|
||
if (szText.CompareNoCase(szBuf) != 0)
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bColumnSize)
|
||
{ // 柱子尺寸样式
|
||
if (bIsColumn)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pCol);
|
||
if (pCol != NULL)
|
||
{
|
||
double dHeightDif = fabs(pCol->GetHeight() - dHeight);
|
||
int iMaterialDif = pCol->GetMaterial() - iMaterial;
|
||
int iShapeDif = pCol->GetSectionShape() - iShape;
|
||
XPoly2D poly = pCol->GetOutlinePoly();
|
||
double dAreaDif = fabs(poly.Area() - dArea);
|
||
double dLengthDif = fabs(poly.Distance2d() - dLength);
|
||
|
||
if ((dHeightDif > 1.0E-6)
|
||
|| (iMaterialDif != 0)
|
||
|| (iShapeDif != 0)
|
||
|| (dAreaDif > 1.0E-6)
|
||
|| (dLengthDif > 1.0E-6))
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
if (bMaterial)
|
||
{
|
||
if (bIsColumnOrWall)
|
||
{
|
||
if (ent.Is(_T("TCH_WALL")) || ent.Is(_T("TCH_COLUMN")) || ent.Is(_T("TCH_CURTAIN_WALL")))
|
||
{
|
||
int nMaterialTemp = 0;
|
||
if (ent.Is(_T("TCH_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
nMaterialTemp =pWall->GetMaterialIndex();
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
else if (ent.Is(_T("TCH_COLUMN")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pCol);
|
||
nMaterialTemp =pCol->GetMaterial();
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("TCH_CURTAIN_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,TDbWall,pWall);
|
||
nMaterialTemp =pWall->GetMaterialIndex();
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
if (nMaterialTemp != nMaterial)
|
||
return false;
|
||
}
|
||
else
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
// Modify By LCF 2004/07/07
|
||
void SelObject()
|
||
{
|
||
PickSet ssFirst(SS_FREE);
|
||
ssFirst += g_ssPickFirst;
|
||
g_ssPickFirst.Free();
|
||
|
||
CWnd *pWnd=acedGetAcadFrame();
|
||
CSelectFilterDlg dlg(pWnd);
|
||
{
|
||
CAcModuleResourceOverride vTemp;
|
||
dlg.Create(dlg.IDD, pWnd);
|
||
}
|
||
acedGetAcadDwgView()->SetFocus();
|
||
|
||
Entity ent;
|
||
int rt;
|
||
INITGET_BEG(0,_T("2"));
|
||
rt=SelectEntity1(_T("\n请选择一个参考图元或 [恢复上次选择(2)]<退出>:"), ent, XPoint(), RBList());
|
||
INITGET_END();
|
||
|
||
dlg.UpdateData(TRUE);
|
||
if (::IsWindow(dlg.m_hWnd))
|
||
dlg.DestroyWindow();
|
||
if (rt==RTNORM) {
|
||
RBList rbMask;
|
||
|
||
const int CHARLEN = 100;
|
||
TCHAR szDxfRef[CHARLEN], szLayerRef[CHARLEN], szLineTypeRef[CHARLEN],
|
||
szBlockNameRef[CHARLEN], szOpeningNameRef[CHARLEN], szTextRef[CHARLEN];
|
||
|
||
int nColorRef = 0, nMaterialRef = 0, iMaterialRef = 0, iShapeRef = 0;
|
||
double dAreaRef = .0, dLengthRef = .0, dHeightRef = .0;
|
||
|
||
bool bExcludeAllSel = false, bIsBlockRef = false, bIsOpeningRef = false,
|
||
bIsTextRef = false, bIsColumnRef = false, bIsColumnOrWallRef = false;
|
||
|
||
// 修改描述:如果选择“排除在选择集外”一项,即在框定的对象范围内,
|
||
// 某对象只要未与选择的参考图元在过滤选项中勾选的所有项都匹配,则该对象即被选择。
|
||
// 修改人,修改时间:Zyu add on 100628
|
||
bool bFlag = false; // 记录是否添加过过滤选项
|
||
if (!dlg.IsInclude())
|
||
{
|
||
rbMask.Append(ads_buildlist(-4, _T("<OR"), NULL));
|
||
}
|
||
|
||
if (dlg.m_bObject) {
|
||
// TCHAR szDxf[256]=_T("");
|
||
// ent.GetData(0, szDxf);
|
||
ent.GetData(0, szDxfRef);
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(RTDXF0, szDxf, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), RTDXF0, szDxf, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), RTDXF0, szDxfRef, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(RTDXF0, szDxf, NULL));
|
||
rbMask.Append(ads_buildlist(RTDXF0, szDxfRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
if (dlg.m_bLayer) {
|
||
// TCHAR szLayer[256]=_T("");
|
||
// ent.GetData(8, szLayer);
|
||
ent.GetData(8, szLayerRef);
|
||
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(8, szLayer, NULL);
|
||
//rbMask.Append(rb);
|
||
CString str = szLayerRef;
|
||
if (str.Find(_T("@")) != -1 || str.Find(_T("#")) != -1 || str.Find(_T("$")) != -1 ||
|
||
str.Find(_T("%")) != -1 || str.Find(_T("^")) != -1 || str.Find(_T("&")) != -1 ||
|
||
str.Find(_T("-")) != -1 || str.Find(_T("+")) != -1 || str.Find(_T("~")) != -1 ||
|
||
str.Find(_T("!")) != -1 || str.Find(_T("[")) != -1 || str.Find(_T("]")) != -1 ||
|
||
str.Find(_T("{")) != -1 || str.Find(_T("}")) != -1 || str.Find(_T("(")) != -1 ||
|
||
str.Find(_T(")")) != -1)
|
||
{
|
||
SpringStr(str); //处理好的图层名
|
||
}
|
||
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), 8, szLayer, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), 8, str, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(8, szLayer, NULL));
|
||
rbMask.Append(ads_buildlist(8, str, NULL));
|
||
}
|
||
// End
|
||
}
|
||
// BOOL bColorDefault=FALSE;
|
||
// BOOL bLinetypeDefault=FALSE;
|
||
if (dlg.m_bColor) {
|
||
// int nColor;
|
||
// if (ent.GetData(62, &nColor)==RTNORM)
|
||
if (ent.GetData(62, &nColorRef)!=RTNORM)
|
||
{
|
||
nColorRef = 256; // 没打开颜色,说明是按照图层来显示的颜色
|
||
}
|
||
|
||
{
|
||
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(62, nColor, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), 62, nColor,-4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), 62, nColorRef,-4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(62, nColor, NULL));
|
||
rbMask.Append(ads_buildlist(62, nColorRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
// else
|
||
// bColorDefault=TRUE;
|
||
}
|
||
if (dlg.m_bLinetype) {
|
||
// TCHAR szLinetype[256]=_T("");
|
||
// if (ent.GetData(6, szLinetype)==RTNORM)
|
||
if (ent.GetData(6, szLineTypeRef)!=RTNORM)
|
||
{
|
||
::StrCpy(szLineTypeRef, _T("bylayer")); // 没有打开线形,说明是按照图层显示的线形
|
||
}
|
||
{
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(6, szLinetype, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"),6, szLinetype, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"),6, szLineTypeRef, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(6, szLinetype, NULL));
|
||
rbMask.Append(ads_buildlist(6, szLineTypeRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
// else
|
||
// bLinetypeDefault=TRUE;
|
||
}
|
||
BOOL bColumn = FALSE;
|
||
if (dlg.m_bBlockName)
|
||
{
|
||
bExcludeAllSel = true;
|
||
if (ent.Is(_T("INSERT")) || ent.Is(_T("TCH_BLOCK_INSERT")))
|
||
{
|
||
bIsBlockRef = true;
|
||
// TCHAR szBlockName[256]=_T("");
|
||
// if (ent.GetData(2, szBlockName)==RTNORM) {
|
||
if (ent.GetData(2, szBlockNameRef)==RTNORM) {
|
||
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(2, szBlockName, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), 2, szBlockName, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), 2, szBlockNameRef, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(2, szBlockName, NULL));
|
||
rbMask.Append(ads_buildlist(2, szBlockNameRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
}
|
||
else if (ent.Is(_T("TCH_OPENING")))
|
||
{
|
||
bIsOpeningRef = true;
|
||
// TCHAR szBlockName[256]=_T("");
|
||
// if (ent.GetData(302, szBlockName)==RTNORM) {
|
||
if (ent.GetData(302, szOpeningNameRef)==RTNORM) {
|
||
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(302, szBlockName, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), 302, szBlockName, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), 302, szOpeningNameRef, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(302, szBlockName, NULL));
|
||
rbMask.Append(ads_buildlist(302, szOpeningNameRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
}
|
||
else if (ent.Is(_T("TCH_TEXT"))||ent.Is(_T("TEXT")))
|
||
{//add by whl on 04/06/15
|
||
bIsTextRef = true;
|
||
// TCHAR szText[256]=_T("");
|
||
// if (ent.GetData(1,szText)==RTNORM)
|
||
if (ent.GetData(1,szTextRef)==RTNORM)
|
||
{
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(1, szText, NULL);
|
||
//rbMask.Append(rb);
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// rbMask.Append(ads_buildlist(-4, _T("<NOT"), 1, szText, -4, _T("NOT>"), NULL));
|
||
rbMask.Append(ads_buildlist(-4, _T("<NOT"), 1, szTextRef, -4, _T("NOT>"), NULL));
|
||
bFlag = true;
|
||
}
|
||
else
|
||
{
|
||
// rbMask.Append(ads_buildlist(1, szText, NULL));
|
||
rbMask.Append(ads_buildlist(1, szTextRef, NULL));
|
||
}
|
||
// End
|
||
}
|
||
}
|
||
else if (ent.Is(_T("TCH_COLUMN")))
|
||
{
|
||
bIsColumnRef = true;
|
||
TCHAR szDxf[256]=_T("");
|
||
ent.GetData(0, szDxf);
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf *rb=ads_buildlist(RTDXF0, szDxf, NULL);
|
||
//rbMask.Append(rb);
|
||
if (dlg.IsInclude())
|
||
{
|
||
rbMask.Append(ads_buildlist(RTDXF0, szDxf, NULL));
|
||
}
|
||
bColumn = TRUE;
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////////////////////////////////
|
||
// [11/8/2007 nsh]
|
||
//选择材质
|
||
int nMaterial;//记录选择出来的柱子或墙的材质
|
||
BOOL bMaterial=FALSE;
|
||
if (dlg.m_bMaterail)
|
||
{
|
||
bExcludeAllSel = true;
|
||
if (ent.Is(_T("TCH_WALL")) || ent.Is(_T("TCH_COLUMN")) || ent.Is(_T("TCH_CURTAIN_WALL")))
|
||
{
|
||
// Zyu modify on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//resbuf * rb=ads_buildlist(RTDXF0,_T("TCH_WALL,TCH_COLUMN,TCH_CURTAIN_WALL"),NULL);
|
||
//rbMask.Append(rb);
|
||
if (dlg.IsInclude())
|
||
{
|
||
rbMask.Append(ads_buildlist(RTDXF0,_T("TCH_WALL,TCH_COLUMN,TCH_CURTAIN_WALL"),NULL));
|
||
}
|
||
// End
|
||
|
||
if (ent.Is(_T("TCH_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
nMaterial =pWall->GetMaterialIndex();
|
||
// nMaterialRef =pWall->GetMaterialIndex();
|
||
OPENOBJ_END();
|
||
bMaterial =TRUE;
|
||
}
|
||
else if (ent.Is(_T("TCH_COLUMN")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pCol);
|
||
nMaterial =pCol->GetMaterial();
|
||
// nMaterialRef =pCol->GetMaterial();
|
||
OPENOBJ_END();
|
||
bMaterial =TRUE;
|
||
}
|
||
else if (ent.Is(_T("TCH_CURTAIN_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,TDbWall,pWall);
|
||
nMaterial =pWall->GetMaterialIndex();
|
||
// nMaterialRef =pWall->GetMaterialIndex();
|
||
OPENOBJ_END();
|
||
bMaterial =TRUE;
|
||
}
|
||
nMaterialRef = nMaterial;
|
||
bIsColumnOrWallRef = bMaterial ? true : false;
|
||
}
|
||
|
||
}
|
||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||
// Zyu add on 100628,支持“排除在选择集外”选项
|
||
if (!dlg.IsInclude())
|
||
{
|
||
// 在过滤器里添加了过滤选项后,最后添加一个“或”操作符
|
||
if (bFlag)
|
||
{
|
||
rbMask.Append(ads_buildlist(-4, _T("OR>"), NULL));
|
||
}
|
||
// 在过滤器里没添加过滤选项时,清空过滤器
|
||
else
|
||
{
|
||
rbMask.FreeGroups();
|
||
}
|
||
}
|
||
ads_sssetfirst(NULL, NULL);
|
||
|
||
adsout << _T("\n提示:空选即为全选,中断用ESC!");
|
||
PickSet ss(SS_FREE);
|
||
const TCHAR *szPrompts[2]={ _T("选择对象:"), _T("移除对象:") };
|
||
if (!dlg.IsInclude() && bExcludeAllSel)
|
||
rt=ss.Get(_T(":$-I"), szPrompts, NULL, RBList());
|
||
else
|
||
{
|
||
rt=ss.Get(_T(":$-I"), szPrompts, NULL, rbMask);
|
||
}
|
||
if (rt==RTNONE || rt==RTERROR) {
|
||
if (!dlg.IsInclude() && bExcludeAllSel)
|
||
rt=ss.Get(_T("X"), NULL, NULL, RBList());
|
||
else
|
||
rt=ss.Get(_T("X"), NULL, NULL, rbMask);
|
||
}
|
||
// Zyu add on 100628,支持“排除在选择集外”选项
|
||
PickSet ssExclude(SS_FREE);
|
||
|
||
// if (bColorDefault || bLinetypeDefault) {
|
||
// // Zyu modify on 100628,已经声明
|
||
// //PickSet ssExclude(SS_FREE);
|
||
// long num=ss.Length();
|
||
// for(long n=0L; n<num; n++) {
|
||
// Entity e=ss[n];
|
||
// if (bColorDefault) {
|
||
// int nColor=0;
|
||
// if (e.GetData(62, &nColor)==RTNORM && nColor!=256)
|
||
// ssExclude += e;
|
||
// }
|
||
// if (bLinetypeDefault) {
|
||
// TCHAR szLinetype[256]=_T("");
|
||
// if (e.GetData(6, szLinetype)==RTNORM && _tcsicmp(szLinetype, _T("BYLAYER"))!=0)
|
||
// ssExclude += e;
|
||
// }
|
||
// }
|
||
// ss -= ssExclude;
|
||
// }
|
||
|
||
if (dlg.IsInclude())
|
||
{
|
||
// 选择柱子形式
|
||
if (bColumn)
|
||
{
|
||
double dHeight;
|
||
int iMaterial;
|
||
int iShape;
|
||
double dArea;
|
||
double dLength;
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pColumn);
|
||
dHeight = pColumn->GetHeight();
|
||
iMaterial = pColumn->GetMaterial();
|
||
iShape = pColumn->GetSectionShape();
|
||
XPoly2D polyOutline = pColumn->GetOutlinePoly();
|
||
dArea = polyOutline.Area();
|
||
dLength = polyOutline.Distance2d();
|
||
OPENOBJ_END();
|
||
|
||
// Zyu modify on 100628,已经声明
|
||
//PickSet ssExclude(SS_FREE);
|
||
long num = ss.Length();
|
||
for(long i=0; i<num; i++)
|
||
{
|
||
Entity e = ss[i];
|
||
// Modify by Zyu on 100325,支持“排除在选择集外”选项
|
||
// Begin
|
||
//OPENOBJ_BEGIN(e, AcDb::kForRead, TDbColumn, pCol);
|
||
//double dHeightDif = fabs(pCol->GetHeight() - dHeight);
|
||
//int iMaterialDif = pCol->GetMaterial() - iMaterial;
|
||
//int iShapeDif = pCol->GetSectionShape() - iShape;
|
||
//XPoly2D poly = pCol->GetOutlinePoly();
|
||
//double dAreaDif = fabs(poly.Area() - dArea);
|
||
//double dLengthDif = fabs(poly.Distance2d() - dLength);
|
||
|
||
//if ((dHeightDif > 1.0E-6)
|
||
// || (iMaterialDif != 0)
|
||
// || (iShapeDif != 0)
|
||
// || (dAreaDif > 1.0E-6)
|
||
// || (dLengthDif > 1.0E-6))
|
||
// ssExclude += e;
|
||
//OPENOBJ_END();
|
||
if (dlg.IsInclude() || e.Is(_T("TCH_COLUMN")))
|
||
{
|
||
OPENOBJ_BEGIN(e, AcDb::kForRead, TDbColumn, pCol);
|
||
double dHeightDif = fabs(pCol->GetHeight() - dHeight);
|
||
int iMaterialDif = pCol->GetMaterial() - iMaterial;
|
||
int iShapeDif = pCol->GetSectionShape() - iShape;
|
||
XPoly2D poly = pCol->GetOutlinePoly();
|
||
double dAreaDif = fabs(poly.Area() - dArea);
|
||
double dLengthDif = fabs(poly.Distance2d() - dLength);
|
||
|
||
if ((dHeightDif > 1.0E-6)
|
||
|| (iMaterialDif != 0)
|
||
|| (iShapeDif != 0)
|
||
|| (dAreaDif > 1.0E-6)
|
||
|| (dLengthDif > 1.0E-6))
|
||
ssExclude += e;
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
ssExclude += e;
|
||
}
|
||
// End
|
||
}
|
||
ss -= ssExclude;
|
||
|
||
long lenEx = ssExclude.Length();
|
||
if(lenEx > 0)
|
||
adsout << _T("\n已滤除") << lenEx << _T("个。");
|
||
}
|
||
////////////////////////////////////////////////////////////////////////
|
||
// [11/8/2007 nsh]
|
||
//选择材质
|
||
if (bMaterial)
|
||
{//处理选择材质的处理过程
|
||
{//处理并选择柱子
|
||
int iMaterial;
|
||
// Zyu modify on 100628,已经声明
|
||
//PickSet ssExclude(SS_FREE);
|
||
long num = ss.Length();
|
||
iMaterial =nMaterial;
|
||
for(long i=0; i<num; i++)
|
||
{
|
||
Entity e = ss[i];
|
||
if(e.Is(_T("TCH_COLUMN")))
|
||
{
|
||
OPENOBJ_BEGIN(e, AcDb::kForRead, TDbColumn, pCol);
|
||
int iMaterialDif = pCol->GetMaterial() - iMaterial;
|
||
if(iMaterialDif !=0)
|
||
ssExclude += e;
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
ss -= ssExclude;
|
||
}
|
||
{//处理并选择墙体
|
||
int iMaterial;
|
||
//PickSet ssExclude(SS_FREE);
|
||
long num = ss.Length();
|
||
iMaterial =nMaterial;
|
||
for(long i=0; i<num; i++)
|
||
{
|
||
Entity e = ss[i];
|
||
if(e.Is(_T("TCH_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(e, AcDb::kForRead, TDbWall, pWall);
|
||
int iMaterialDif = pWall->GetMaterialIndex()-iMaterial;//得到的是材质的索引
|
||
if (iMaterialDif !=0)
|
||
ssExclude += e;
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
ss -= ssExclude;
|
||
}
|
||
{//处理玻璃幕墙的
|
||
int iMaterial;
|
||
// Zyu modify on 100628,已经声明
|
||
//PickSet ssExclude(SS_FREE);
|
||
long num = ss.Length();
|
||
iMaterial =nMaterial;
|
||
for(long i=0; i<num; i++)
|
||
{
|
||
Entity e = ss[i];
|
||
if (e.Is(_T("TCH_CURTAIN_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(e, AcDb::kForRead, TDbWall, pWall);
|
||
int iMaterialDif = pWall->GetMaterialIndex()-iMaterial;//得到的是材质的索引
|
||
if (iMaterialDif !=0)
|
||
ssExclude += e;
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
ss -= ssExclude;
|
||
}
|
||
// Zyu delete on 100325,无需修改
|
||
//bMaterial =FALSE;
|
||
}
|
||
}
|
||
else
|
||
{ // 要选择在选择集外的情形下:
|
||
if (bExcludeAllSel)
|
||
{ // 要逐一过滤:
|
||
if (bColumn)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pColumn);
|
||
dHeightRef = pColumn->GetHeight();
|
||
iMaterialRef = pColumn->GetMaterial();
|
||
iShapeRef = pColumn->GetSectionShape();
|
||
XPoly2D polyOutline = pColumn->GetOutlinePoly();
|
||
dAreaRef = polyOutline.Area();
|
||
dLengthRef = polyOutline.Distance2d();
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
for (long i = (long)ss.Length() - 1; i >= 0; i--)
|
||
{
|
||
Entity ee = ss[i];
|
||
if (Adjust(dlg.m_bObject ? true : false, szDxfRef,
|
||
dlg.m_bLayer ? true : false, szLayerRef,
|
||
dlg.m_bColor ? true : false, nColorRef,
|
||
dlg.m_bLinetype ? true : false, szLineTypeRef,
|
||
dlg.m_bBlockName && (ent.Is(_T("INSERT")) || ent.Is(_T("TCH_BLOCK_INSERT"))), bIsBlockRef, szBlockNameRef,
|
||
dlg.m_bBlockName && ent.Is(_T("TCH_OPENING")), bIsOpeningRef, szOpeningNameRef,
|
||
dlg.m_bBlockName && (ent.Is(_T("TCH_TEXT"))||ent.Is(_T("TEXT"))), bIsTextRef, szTextRef,
|
||
dlg.m_bBlockName && ent.Is(_T("TCH_COLUMN")), bIsColumnRef,
|
||
dHeightRef, iMaterialRef, iShapeRef, dAreaRef, dLengthRef,
|
||
dlg.m_bMaterail ? true : false, bIsColumnOrWallRef, nMaterialRef, ee))
|
||
{
|
||
// 匹配!删除之
|
||
ss -= ee;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////
|
||
// Zyu add on 100628,支持“排除在选择集外”选项
|
||
// if (!dlg.IsInclude() && ssExclude.Length() != 0)
|
||
// {
|
||
// ss.Free();
|
||
// ss += ssExclude;
|
||
// }
|
||
|
||
if(rt==RTNORM) {
|
||
ss += ssFirst;
|
||
adsout << _T("\n总共选中了") << int(ss.Length()) << _T("个,其中新选了")
|
||
<< int (ss.Length()-ssFirst.Length()) << _T("个。");
|
||
rt=ads_sssetfirst(ss, ss);
|
||
} else {
|
||
ads_sssetfirst(ssFirst, ssFirst);
|
||
}
|
||
} else if(rt==RTKWORD){//恢复上次选择
|
||
ads_sssetfirst(NULL, NULL);
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("p"));
|
||
adsout << _T("\n恢复上次选择,总共选中了") << int(ss.Length()) << _T("个图元");
|
||
rt=ads_sssetfirst(ss, ss);
|
||
}
|
||
|
||
//return rt;
|
||
}
|
||
|
||
//选择删除
|
||
void FilterErase()
|
||
{
|
||
PickSet ssAll(SS_FREE);
|
||
|
||
if (SelectEntities(_T("\n请选择删除范围<退出>:"), ssAll, RBList()) != RTNORM)
|
||
return;
|
||
Entity entSel;
|
||
PickSet ssSel(SS_FREE);
|
||
ssSel += ssAll;
|
||
|
||
int ret = SelectEntity(_T("\n请选择指定类型的图元<删除>:"), entSel, RBList());
|
||
while(ret == RTNORM){
|
||
BOOL bIsBlkMask = FALSE;
|
||
ssAll.Redraw(4);
|
||
ssSel.Free();
|
||
TCHAR szLayer[256], szEntName[256], szBlkName[256];
|
||
entSel.GetData(8, szLayer);
|
||
entSel.GetData(0, szEntName);
|
||
long len = ssAll.Length();
|
||
if (entSel.Is(_T("INSERT"))){
|
||
bIsBlkMask = TRUE;
|
||
entSel.GetData(2, szBlkName);
|
||
}
|
||
|
||
RBList rbMask(RTDXF0, szEntName, 8, szLayer, NULL);
|
||
RBList rbMask2(RTDXF0, _T("INSERT"), 8, szLayer, 2, szBlkName, NULL);
|
||
|
||
for(long i=0;i<len;i++){
|
||
Entity ent = ssAll[i];
|
||
if (bIsBlkMask){ //安图块名精细过滤
|
||
if (ent.MatchBase(rbMask2))
|
||
ssSel += ent;
|
||
}
|
||
else{
|
||
if (ent.MatchBase(rbMask))
|
||
ssSel += ent;
|
||
}
|
||
}
|
||
ssSel.Redraw(3);
|
||
ret = SelectEntity(_T("\n请选择指定类型的图元<删除>:"), entSel, RBList());
|
||
}
|
||
if (ret == RTCAN){
|
||
ssSel.Redraw(4);
|
||
return;
|
||
}
|
||
|
||
else
|
||
ssSel.Erase();
|
||
}
|
||
|
||
///////////////////////////////////////////////////////
|
||
// 交互选择指定DXF的实体, 在原来的基础上累加
|
||
int SelectEntityByDxf(const TCHAR *pszDxf, const TCHAR *pszLay=NULL)
|
||
{
|
||
RBList mask1=ads_buildlist(RTDXF0, pszDxf, 8, pszLay, NULL);
|
||
RBList mask2=ads_buildlist(RTDXF0, pszDxf, NULL);
|
||
XString sPrompt(256);
|
||
sPrompt << _T("选择图元(DXF=") << pszDxf << _T(",图层=") << (pszLay? pszLay : _T("任意")) << _T("):");
|
||
const TCHAR *szPrompts[2]={ (const TCHAR *)sPrompt, _T("") };
|
||
RBList &mask=pszLay? mask1 : mask2;
|
||
PickSet ss(SS_FREE);
|
||
if (ss.Get(_T(":$"), szPrompts, NULL, mask)==RTNORM) {
|
||
adsout << _T("\n总共选中了") << int(ss.Length()) << _T("个") << pszDxf << _T(". ");
|
||
PickSet ss1(SS_FREE|SS_CREATE);
|
||
resbuf *gset=NULL, *pset=NULL;
|
||
if (ads_ssgetfirst(&gset, &pset)==RTNORM) {
|
||
if (gset) {
|
||
if (gset->restype==RTPICKS) {
|
||
PickSet ss0(0);
|
||
ss0 = gset->resval.rlname;
|
||
ss += ss0;
|
||
ss0.Free();
|
||
}
|
||
ads_relrb(gset);
|
||
}
|
||
if (pset) {
|
||
if (pset->restype==RTPICKS)
|
||
ads_ssfree(pset->resval.rlname);
|
||
ads_relrb(pset);
|
||
}
|
||
}
|
||
return ads_sssetfirst(ss, ss1);
|
||
}
|
||
return RTERROR;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////
|
||
// Command: 预先选择物体
|
||
void SelObject1()
|
||
{
|
||
Entity ent;
|
||
int rt;
|
||
const TCHAR *szPrompts[2]={
|
||
_T("\n请选择一参考图元或 [打开图层过滤(C)] <退出>:"),
|
||
_T("\n请选择一参考图元或 [关闭图层过滤(C)] <退出>:"),
|
||
};
|
||
static BOOL bLayerFilter=TRUE;
|
||
do {
|
||
INITGET_BEG(0, _T("C"));
|
||
rt=ads_entsel(szPrompts[bLayerFilter], ent, XPoint());
|
||
INITGET_END();
|
||
if (rt==RTKWORD)
|
||
bLayerFilter=!bLayerFilter;
|
||
}while(rt==RTKWORD);
|
||
|
||
if (rt==RTNORM) {
|
||
TCHAR szLayer[256]=_T("");
|
||
XString sDxfName(256);
|
||
VERIFY(ent.GetData(0, (TCHAR *)sDxfName)==RTNORM &&
|
||
ent.GetData(8, szLayer)==RTNORM);
|
||
SelectEntityByDxf(sDxfName, bLayerFilter? szLayer:NULL);
|
||
}
|
||
}
|
||
|
||
|