782 lines
23 KiB
C++
782 lines
23 KiB
C++
/********************************************************************
|
|
created: 2006/01/20
|
|
created: 20:1:2006 11:41
|
|
filename: f:\tg_dev\telecdev\twtkernal\indoorsys.cpp
|
|
file path: f:\tg_dev\telecdev\twtkernal
|
|
file base: indoorsys
|
|
file ext: cpp
|
|
author: 沈睿
|
|
|
|
purpose: 室内系统图
|
|
*********************************************************************/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <DbEquipment.h>
|
|
#include <DbDimension.h>
|
|
#include <dbPipeValve.h>
|
|
#include <dbtext.h>
|
|
|
|
#include "jig.h"
|
|
|
|
#include "TPipeGraph.h"
|
|
extern void SearchOneselfPipe(AcDbObjectId idPipe, TPipeGraph &PipeGraph);
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 改楼层线
|
|
//***************************************************************************************************
|
|
|
|
void ModifyFloorLine()
|
|
{
|
|
RBList rbMask(RTDXF0, _T("ATS_TEXT,ATS_ELEVATION,LINE"), NULL);
|
|
PickSet ss(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择需要镜像的楼层线、标高:<退出>"), ss, rbMask) != RTNORM)
|
|
return;
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), NULL);
|
|
Entity entPipe;
|
|
if(SelectEntity(_T("\n请选择镜像的参考线(立管):<上下移位>"), entPipe, rbMaskPipe) != RTNORM)
|
|
{
|
|
XPoint ptIns;
|
|
double x,y,z;
|
|
|
|
ss.GetExtend(ptIns, &x, &y, &z);
|
|
|
|
XPoint ptUcs = Wcs2Ucs(ptIns);
|
|
ptUcs.z = 0;
|
|
int nRet = DragPickSet1(ss, ptUcs);
|
|
if(nRet != RTNORM)
|
|
return;
|
|
XPoint ptWcs = Ucs2Wcs(ptUcs);
|
|
|
|
TCHAR szTmp[32];
|
|
ads_getstring(0, _T("\n是否继续修改标高标注的文字<Y>:"), szTmp);
|
|
if(_tcsicmp(szTmp, _T("N")) == 0)
|
|
return;
|
|
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbElevation, pDim);
|
|
if(pDim){
|
|
CString csText = pDim->GetText();
|
|
double dLastElev = _tstof(csText);
|
|
XString sText1(_T("%.3f"), dLastElev+_AS_METER(ptWcs.y-ptIns.y));
|
|
pDim->SetText(sText1);
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
XPoint ptStart, ptEnd;
|
|
GetPipePoint(entPipe, ptStart, ptEnd);
|
|
SHads_command(RTSTR, _T(".MIRROR"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
|
RT3DPOINT, &ptStart, RT3DPOINT, &ptEnd, RTSTR, _T("Y"), RTNONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 系统缩放
|
|
//***************************************************************************************************
|
|
void ScalePipeSys()
|
|
{
|
|
PickSet ss(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择需要改变比例的系统图:<退出>"), ss, RBList()) != RTNORM)
|
|
return;
|
|
RBList rbMask(RTDXF0, _T("ATS_TEXT,ATS_ELEVATION,LINE"), NULL);
|
|
|
|
long len = ss.Length();
|
|
//1. 过滤出那些不需要进行缩放的标注对象
|
|
PickSet ssDim(SS_FREE);
|
|
for(long i=0;i<len;i++)
|
|
{
|
|
Entity ent = ss[i];
|
|
if(ent.MatchBase(rbMask))
|
|
{
|
|
CString csText = ReadXdata(ent, _T("TG-LAYER"));
|
|
if(csText != _T(""))
|
|
ssDim+=ent;
|
|
}
|
|
}
|
|
ss -= ssDim;
|
|
len = ssDim.Length();
|
|
//2. 这些标注对象各自找1个相当于立管的位置点
|
|
CMap<TLong_ptr,TLong_ptr,AcGePoint3d,AcGePoint3d&> map;
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), NULL);
|
|
acedSetStatusBarProgressMeter(_T("准备中..."), 0, len);
|
|
for(i=0;i<len;i++)
|
|
{
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
Entity entDim = ssDim[i];
|
|
CString csVPipeSerial = ReadXdata(entDim, _T("PIPE-SERIAL"));
|
|
|
|
XPoint ptLoc, ptNew, ptStart, ptEnd;
|
|
entDim.GetData(10, ptLoc);
|
|
ptLoc.z = 0;
|
|
ads_polar(ptLoc, 0, 100*DocGetPScale(), ptEnd);
|
|
ads_polar(ptLoc, PI, 100*DocGetPScale(), ptStart);
|
|
XLine line(ptStart, ptEnd, 1);
|
|
XPoint ptTmp;
|
|
double dDist(-1);
|
|
AcGePoint3dArray ptArr;
|
|
//先以最近的立管作为参考点
|
|
for(long j=0;j<ss.Length();j++)
|
|
{
|
|
Entity ent = ss[j];
|
|
if(!ent.Is(_T("ATS_PIPE")))
|
|
continue;
|
|
CString csText = ReadXdata(ent, _T("PIPE-SERIAL"));
|
|
if(csText == _T(""))
|
|
continue;
|
|
if(csVPipeSerial != _T("") && csVPipeSerial != csText)
|
|
continue;
|
|
|
|
XPoint ptS, ptE;
|
|
GetPipePoint(ent, ptS, ptE);
|
|
XLine line2(ptS, ptE, 1);
|
|
XPoint ptInter;
|
|
line.Intersection(&line2, ptInter);
|
|
if(!!ptInter)
|
|
{
|
|
double dDist2Pipe = ads_distance(ptLoc, ptInter);
|
|
if(dDist2Pipe < dDist || dDist < 0)
|
|
{
|
|
ptTmp = ptInter;
|
|
dDist = dDist2Pipe;
|
|
}
|
|
}
|
|
}
|
|
if(!ptTmp)
|
|
{
|
|
//如果找不到最近的立管,就以最近的管线交点作为参考点
|
|
for(j=0;j<ss.Length();j++)
|
|
{
|
|
Entity ent = ss[j];
|
|
if(!ent.Is(_T("ATS_PIPE")))
|
|
continue;
|
|
|
|
XPoint ptS, ptE;
|
|
GetPipePoint(ent, ptS, ptE);
|
|
XLine line2(ptS, ptE, 1);
|
|
XPoint ptInter;
|
|
line.Intersection(&line2, ptInter);
|
|
if(!!ptInter)
|
|
{
|
|
double dDist2Pipe = ads_distance(ptLoc, ptInter);
|
|
if(dDist2Pipe < dDist || dDist < 0)
|
|
{
|
|
ptTmp = ptInter;
|
|
dDist = dDist2Pipe;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!!ptTmp)
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id, entDim);
|
|
AcGePoint3d pt(ptTmp.AsAcGePoint3d());
|
|
map.SetAt(id.asOldId(), pt);
|
|
XLine line(ptLoc, ptTmp);
|
|
// line.Make();
|
|
}
|
|
}
|
|
acedRestoreStatusBar();
|
|
|
|
|
|
//3. 进行SCALE
|
|
XPoint ptIns;
|
|
if(ads_getpoint(NULL, _T("\n请选择基点:<退出>"), ptIns) != RTNORM)
|
|
return;
|
|
ptIns = Ucs2Wcs(ptIns);
|
|
double nScale(1);
|
|
ss.Scale(ptIns, &nScale);
|
|
if(nScale == 1)
|
|
return;
|
|
|
|
//4. 将管线上不需要缩放的阀门,标注反向scale回去
|
|
DList<AcDbObjectId> lstNode;
|
|
for(i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
if(ent.Is(_T("ATS_PIPE"))){
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
DList<AcDbObjectId> lstAttachment;
|
|
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
|
nodeId1 = pPipe->GetNode(0);
|
|
nodeId2 = pPipe->GetNode(1);
|
|
if(IsAppandEquip(lstNode, nodeId1)){
|
|
OPENOBJ_BEGIN(nodeId1, AcDb::kForWrite, TDbEquipment, pEquip1);
|
|
if(pEquip1){
|
|
pEquip1->SetScale(pEquip1->GetScale()/nScale);
|
|
pEquip1->SetYScale(pEquip1->GetYScale()/nScale); // cet 2011.3.14 add
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
if(IsAppandEquip(lstNode, nodeId2)){
|
|
OPENOBJ_BEGIN(nodeId2, AcDb::kForWrite, TDbEquipment, pEquip2);
|
|
if(pEquip2){
|
|
pEquip2->SetScale(pEquip2->GetScale()/nScale);
|
|
pEquip2->SetYScale(pEquip2->GetYScale()/nScale); // cet 2011.3.14 add
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
pPipe->GetAttachments(lstAttachment);
|
|
int leng = lstAttachment.Length();
|
|
for(int m=0;m<leng;m++){
|
|
AcDbObjectId idTmp = *lstAttachment[m];
|
|
OPENOBJ_BEGIN(idTmp, AcDb::kForWrite, TDbPipeValve, pValve);
|
|
if(pValve){
|
|
pValve->SetScale(pValve->GetScale()/nScale);
|
|
pValve->SetYScale(pValve->GetYScale()/nScale);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToScaling(nScale, ptIns.AsAcGePoint3d());
|
|
len = ssDim.Length();
|
|
for(i=0;i<len;i++)
|
|
{
|
|
Entity ent = ssDim[i];
|
|
AcDbObjectId id;
|
|
AcGePoint3d ptPipe, ptNew;
|
|
acdbGetObjectId(id, ent);
|
|
map.Lookup(id.asOldId(), ptPipe);
|
|
ptNew = ptPipe;
|
|
ptNew.transformBy(mat);
|
|
AcGeMatrix3d matNew;
|
|
AcGeVector3d vt1(ptNew - ptPipe);
|
|
matNew.setToTranslation(vt1);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt){
|
|
pEnt->transformBy(matNew);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// len = ssDim.Length();
|
|
// for(i=0;i<len;i++)
|
|
// {
|
|
// Entity ent = ssDim[i];
|
|
// XPoint ptLoc, ptNew;
|
|
// ent.GetData(10, ptLoc);
|
|
// ptNew = ptLoc;
|
|
// ptNew.TransformBy(mat);
|
|
// AcGeVector3d vt1(ptNew - ptLoc);
|
|
// AcGeVector3d vt2;
|
|
// vt2 = vt1.orthoProject(AcGeVector3d::kXAxis);
|
|
// AcGeMatrix3d matNew;
|
|
// matNew.setToTranslation(vt2);
|
|
// OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
// if(pEnt){
|
|
// pEnt->transformBy(matNew);
|
|
// }
|
|
// OPENOBJ_END();
|
|
// }
|
|
}
|
|
|
|
void ScalePipeSys2()
|
|
{
|
|
PickSet ss(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择需要改变比例的系统图:<退出>"), ss, RBList()) != RTNORM)
|
|
return;
|
|
RBList rbMask(RTDXF0, _T("ATS_TEXT,ATS_ELEVATION,LINE"), NULL);
|
|
|
|
long len = ss.Length();
|
|
PickSet ssDim(SS_FREE);
|
|
for(long i=0;i<len;i++)
|
|
{
|
|
Entity ent = ss[i];
|
|
if(ent.MatchBase(rbMask))
|
|
{
|
|
CString csText = ReadXdata(ent, _T("TG-LAYER"));
|
|
if(csText != _T(""))
|
|
ssDim+=ent;
|
|
}
|
|
}
|
|
ss -= ssDim;
|
|
|
|
XPoint ptIns;
|
|
if(ads_getpoint(NULL, _T("\n请选择基点:<退出>"), ptIns) != RTNORM)
|
|
return;
|
|
ptIns = Ucs2Wcs(ptIns);
|
|
double nScale(1);
|
|
ss.Scale(ptIns, &nScale);
|
|
if(nScale == 1)
|
|
return;
|
|
DList<AcDbObjectId> lstNode;
|
|
for(i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
if(ent.Is(_T("ATS_PIPE"))){
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
DList<AcDbObjectId> lstAttachment;
|
|
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
|
nodeId1 = pPipe->GetNode(0);
|
|
nodeId2 = pPipe->GetNode(1);
|
|
if(IsAppandEquip(lstNode, nodeId1)){
|
|
OPENOBJ_BEGIN(nodeId1, AcDb::kForWrite, TDbEquipment, pEquip1);
|
|
if(pEquip1){
|
|
pEquip1->SetScale(pEquip1->GetScale()/nScale);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
if(IsAppandEquip(lstNode, nodeId2)){
|
|
OPENOBJ_BEGIN(nodeId2, AcDb::kForWrite, TDbEquipment, pEquip2);
|
|
if(pEquip2){
|
|
pEquip2->SetScale(pEquip2->GetScale()/nScale);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
pPipe->GetAttachments(lstAttachment);
|
|
int leng = lstAttachment.Length();
|
|
for(int m=0;m<leng;m++){
|
|
AcDbObjectId idTmp = *lstAttachment[m];
|
|
OPENOBJ_BEGIN(idTmp, AcDb::kForWrite, TDbPipeValve, pValve);
|
|
if(pValve){
|
|
pValve->SetScale(pValve->GetScale()/nScale);
|
|
pValve->SetYScale(pValve->GetYScale()/nScale);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToScaling(nScale, ptIns.AsAcGePoint3d());
|
|
len = ssDim.Length();
|
|
for(i=0;i<len;i++)
|
|
{
|
|
Entity ent = ssDim[i];
|
|
XPoint ptLoc, ptNew;
|
|
ent.GetData(10, ptLoc);
|
|
ptNew = ptLoc;
|
|
ptNew.TransformBy(mat);
|
|
AcGeVector3d vt1(ptNew - ptLoc);
|
|
AcGeVector3d vt2;
|
|
vt2 = vt1.orthoProject(AcGeVector3d::kXAxis);
|
|
AcGeMatrix3d matNew;
|
|
matNew.setToTranslation(vt2);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt){
|
|
pEnt->transformBy(matNew);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 系统选择
|
|
//***************************************************************************************************
|
|
//extern Entity GetPipeDimByPt(XPoint pt, int idx);
|
|
extern Entity GetPipeDimByEnt(Entity ent);
|
|
|
|
// zxl 2013.09.04 add
|
|
void SelectPipesSys()
|
|
{
|
|
PickSet ssAll(SS_FREE);
|
|
int nRet = SelectEntities(_T("\n请拾取系统上的管线:"), ssAll, RBList());
|
|
if (nRet == RTCAN)
|
|
{
|
|
return;
|
|
}
|
|
|
|
PickSet ss(SS_FREE);
|
|
for (long l = 0l; l < ssAll.Length(); l++)
|
|
{
|
|
Entity ent = ssAll[l];
|
|
if (ent.In(&ss))
|
|
{
|
|
continue;
|
|
}
|
|
AcDbObjectId idPipe;
|
|
acdbGetObjectId(idPipe, ent);
|
|
TPipeGraph PipeGraph;
|
|
SearchOneselfPipe(idPipe, PipeGraph);
|
|
|
|
int len = PipeGraph.m_lstEdge.Length();
|
|
for(int i=0;i<len;i++)
|
|
{
|
|
AcDbObjectId idTmp = PipeGraph.m_lstEdge[i]->m_idPipe;
|
|
if(idTmp != NULL)
|
|
ss+=idTmp;
|
|
}
|
|
|
|
int len1 = PipeGraph.m_lstNode.Length();
|
|
for(i=0;i<len1;i++)
|
|
{
|
|
AcDbObjectId idTmp = PipeGraph.m_lstNode[i]->m_idNode;
|
|
if(idTmp != NULL)
|
|
ss += idTmp;
|
|
}
|
|
}
|
|
|
|
ads_sssetfirst(ss, ss);
|
|
}
|
|
|
|
void SelectPipeSys()
|
|
{
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
Entity entSel;
|
|
int ret(0);
|
|
TCHAR cRet;
|
|
XPoint pt;
|
|
INITGET_BEG(0, _T("R M"));
|
|
ret = SelectEntity(_T("\n请拾取系统上的管线[仅选择立管和标注(R)/选择多管线系统(M)]<退出>:"), entSel, pt, RBList(), _T("R M"), cRet);
|
|
INITGET_END();
|
|
|
|
if(ret == RTKWORD){
|
|
// zxl 2013.09.04 add
|
|
if (cRet == _T('m') || cRet == _T('M'))
|
|
{
|
|
SelectPipesSys();
|
|
return;
|
|
}
|
|
PickSet ss(SS_FREE);
|
|
PickSet ssSel(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择范围:<退出>"), ss, rbMask) != RTNORM)
|
|
return;
|
|
long len = ss.Length();
|
|
for(long i=0;i<len;i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(pPipe->IsVertical()){
|
|
Entity entDim = GetPipeDimByEnt(ent);
|
|
ssSel += ent;
|
|
if(!!entDim)
|
|
ssSel += entDim;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
ads_sssetfirst(ssSel, ssSel);
|
|
|
|
return;
|
|
}
|
|
else if(ret != RTNORM)
|
|
return;
|
|
|
|
AcDbObjectId idPipe;
|
|
acdbGetObjectId(idPipe, entSel);
|
|
TPipeGraph PipeGraph;
|
|
SearchOneselfPipe(idPipe, PipeGraph);//2006-11-28 把数据结构由树改为图,支持环路
|
|
PickSet ss(SS_FREE);
|
|
int len = PipeGraph.m_lstEdge.Length();
|
|
|
|
for(int i=0;i<len;i++){
|
|
AcDbObjectId idTmp = PipeGraph.m_lstEdge[i]->m_idPipe;
|
|
if(idTmp != NULL)
|
|
ss+=idTmp;
|
|
}
|
|
int len1 = PipeGraph.m_lstNode.Length();
|
|
for(i=0;i<len1;i++){
|
|
AcDbObjectId idTmp = PipeGraph.m_lstNode[i]->m_idNode;
|
|
if(idTmp != NULL)
|
|
ss += idTmp;
|
|
}
|
|
|
|
ads_sssetfirst(ss, ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 通气帽
|
|
//***************************************************************************************************
|
|
void DimSingleAerate(const TCHAR* szBlk)
|
|
{
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
Entity entSel;
|
|
XPoint ptPick, ptLoc;
|
|
if(SelectEntity1(g_nCurPipeWidth*DocGetPScale(), _T("\n请选择靠近标注端的管线<退出>:"), entSel, ptPick, rbMask) != RTNORM)
|
|
return;
|
|
XPoint ptS, ptE, ptNew;
|
|
GetPipePoint(entSel, ptS, ptE);
|
|
double n1 = ads_distance(ptS, ptPick);
|
|
double n2 = ads_distance(ptE, ptPick);
|
|
ptLoc = n1 < n2 ? ptS : ptE;
|
|
double nDist(800);
|
|
ads_getdist(ptLoc, _T("\n请输入通气帽管长<800>:"), &nDist);
|
|
if(nDist < 5)
|
|
return;
|
|
XPoint ptTmp = ptE == ptLoc ? ptS : ptE;
|
|
double nRotate = ads_angle(ptTmp, ptPick);
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
TDbPipe *pNewPipe = new TDbPipe;
|
|
pNewPipe = (TDbPipe*)pPipe->clone();
|
|
pNewPipe->SetStartPoint(ptLoc);
|
|
ads_polar(ptLoc, nRotate, nDist, ptNew);
|
|
pNewPipe->SetEndPoint(ptNew);
|
|
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
|
}
|
|
TDbEquipment *pEquip = new TDbEquipment;
|
|
pEquip->SetBlock2d(GetBlkIdByName(szBlk));
|
|
pEquip->SetLocation(ptNew);
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetSysBlock((const TCHAR*)szBlk);
|
|
pEquip->setLayer(LAY_EQ_DIRT);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
OPENOBJ_END();
|
|
|
|
InitLayer(LAY_DIM);
|
|
TDbDimension2 *pDim = new TDbDimension2;
|
|
pDim->setLayer(LAY_DIM);
|
|
pDim->SetLocation(ptNew);
|
|
pDim->SetRotation(ads_angle(ptNew, ptLoc));
|
|
pDim->SetStyleId(InitDimStyle(DS_LINEAR));
|
|
pDim->AddSegment(ptLoc);
|
|
pDim->SetDist2DimLine(0, FALSE);
|
|
|
|
TDimensionEdJig jig(pDim, _T("\n请点取尺寸线位置<退出>:"));
|
|
jig.m_nFlag=1;
|
|
if(jig.doIt() != RTNORM){
|
|
delete pDim;
|
|
return;
|
|
}
|
|
AcDbObjectId idDim = pDim->AddToMSpace(Adesk::kTrue);
|
|
}
|
|
|
|
void DrawAerate()
|
|
{
|
|
g_ssPickFirst.Free();
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择需要插入通气帽的管线<退出>"), ss, rbMask) != RTNORM)
|
|
return;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
XString xsTmp1, xsTmp2, xsTmp;
|
|
XString xsTmp3; // cet 2013.1.5 add
|
|
if(LoadDwbBlock(csDwb, _T("00000388"), xsTmp1) != RTNORM) //通气帽
|
|
return;
|
|
if(LoadDwbBlock(csDwb, _T("00000133"), xsTmp2) != RTNORM) //钢丝球
|
|
return;
|
|
if(LoadDwbBlock(csDwb, _T("00000539"), xsTmp3) != RTNORM) //蘑菇型 cet 2013.1.5 add
|
|
return;
|
|
TCHAR szText[256];
|
|
ads_getstring(0, _T("\n通气帽选用1:钢丝球 2:成品 3:蘑菇型 <钢丝球>:"), szText); // cet 2013.1.5 modify 增加样式3
|
|
if(_tcsicmp(szText, _T("2")) == 0)
|
|
xsTmp = xsTmp1;
|
|
else if(_tcsicmp(szText, _T("3")) == 0) // cet 2013.1.5 modify 增加样式3
|
|
xsTmp = xsTmp3;
|
|
else
|
|
xsTmp = xsTmp2;
|
|
|
|
double nDist(800);
|
|
|
|
double nDist2DimLine(0);
|
|
InitLayer(LAY_EQ_DIRT);
|
|
double nRotate(0);
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
XPoint ptLoc, ptNew, ptTmp;
|
|
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
|
nodeId1 = pPipe->GetNode(0);
|
|
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, TDbPipeNode, pNode1);
|
|
if(pNode1){
|
|
int num = pNode1->GetInterfaceNum();
|
|
if(num == 1){
|
|
ptLoc = pNode1->GetLocation();
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
nodeId2 = pPipe->GetNode(1);
|
|
OPENOBJ_BEGIN(nodeId2, AcDb::kForRead, TDbPipeNode, pNode2);
|
|
if(pNode2){
|
|
int num = pNode2->GetInterfaceNum();
|
|
if(num == 1){
|
|
if(!ptLoc)
|
|
ptLoc = pNode2->GetLocation();
|
|
else{
|
|
if(ss.Length() == 1){
|
|
DimSingleAerate(xsTmp);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(!ptLoc)
|
|
break;
|
|
if(i == 0){
|
|
ads_getdist(ptLoc, _T("\n请输入通气帽管长<800>:"), &nDist);
|
|
}
|
|
if(nDist < 5)
|
|
break;
|
|
ptTmp = pPipe->EndPoint() == ptLoc ? pPipe->StartPoint() : pPipe->EndPoint();
|
|
nRotate = ads_angle(ptTmp, ptLoc);
|
|
|
|
TDbPipe *pNewPipe = new TDbPipe;
|
|
pNewPipe = (TDbPipe*)pPipe->clone();
|
|
pNewPipe->SetStartPoint(ptLoc);
|
|
ads_polar(ptLoc, nRotate, nDist, ptNew);
|
|
pNewPipe->SetEndPoint(ptNew);
|
|
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
|
|
|
TDbEquipment *pEquip = new TDbEquipment;
|
|
pEquip->SetBlock2d(GetBlkIdByName(xsTmp));
|
|
pEquip->SetLocation(ptNew);
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetSysBlock((const TCHAR*)xsTmp);
|
|
pEquip->setLayer(LAY_EQ_DIRT);
|
|
pEquip->SetDang(0);
|
|
pEquip->SetPipeLength(0);
|
|
pEquip->SetSpare(0);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
OPENOBJ_END();
|
|
|
|
InitLayer(LAY_DIM);
|
|
TDbDimension2 *pDim = new TDbDimension2;
|
|
pDim->setLayer(LAY_DIM);
|
|
pDim->SetLocation(ptNew);
|
|
pDim->SetRotation(ads_angle(ptLoc, ptNew));
|
|
pDim->SetStyleId(InitDimStyle(DS_LINEAR));
|
|
pDim->AddSegment(ptLoc);
|
|
pDim->SetDist2DimLine(nDist2DimLine, FALSE);
|
|
if(i == 0){
|
|
TDimensionEdJig jig(pDim, _T("\n请点取尺寸线位置<退出>:"));
|
|
jig.m_nFlag=1;
|
|
ASSERT(pDim->IsValid());
|
|
if(jig.doIt() != RTNORM){
|
|
delete pDim;
|
|
return;
|
|
}
|
|
nDist2DimLine = pDim->GetDist2DimLine(FALSE);
|
|
}
|
|
AcDbObjectId idDim = pDim->AddToMSpace(Adesk::kTrue);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 检查口
|
|
//***************************************************************************************************
|
|
void InsCheckCmd()
|
|
{
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
XString xsTmp;
|
|
if(LoadDwbBlock(csDwb, _T("00000148"), xsTmp) != RTNORM) //检查口
|
|
return;
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
|
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_RAIN, -4, _T("and>"),
|
|
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_DIRT, -4, _T("and>"),
|
|
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, LAY_PIPE_USELESS, -4, _T("and>"),
|
|
-4, _T("or>"), NULL);
|
|
|
|
double nDist2DimLine(0);
|
|
InitLayer(LAY_EQ_DIRT);
|
|
|
|
double nDist(1000);
|
|
ads_getdist(NULL, _T("\n请输入检查口距地面距离<1000>:"), &nDist);
|
|
int idx = 0;
|
|
while(1){
|
|
|
|
XPoint ptIns, ptLoc;
|
|
if(ads_getpoint(NULL, _T("\n请点取检查口所在地面位置:<退出>"), ptLoc) != RTNORM)
|
|
break;
|
|
/* cet 2014.4.25 modify 支持ucs
|
|
ptLoc = Ucs2Wcs(ptLoc);
|
|
ptIns = ptLoc;
|
|
ptIns.y += nDist;
|
|
|
|
XPoint ptUcs = Wcs2Ucs(ptIns);
|
|
PickSet ss(SS_FREE);
|
|
GetPointPickSet(ptUcs, ss, rbMask, 50);
|
|
*/
|
|
ptIns = ptLoc;
|
|
ptIns.y += nDist;
|
|
ptIns = Ucs2Wcs(ptIns);
|
|
PickSet ss(SS_FREE);
|
|
GetPointPickSet(ptLoc, ss, rbMask, 50);
|
|
ptLoc = Ucs2Wcs(ptLoc);
|
|
|
|
long len = ss.Length();
|
|
if(len != 1)
|
|
continue;
|
|
AcGePoint3d ptIns2 = ptIns;
|
|
CString sLayerPipe;
|
|
OPENOBJ_BEGIN(ss[0L], AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
pPipe->getClosestPointTo(ptIns2, ptIns2);
|
|
sLayerPipe = pPipe->GetLayer();
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
TDbEquipment *pEquip = new TDbEquipment;
|
|
pEquip->SetBlock2d(GetBlkIdByName(xsTmp));
|
|
pEquip->SetLocation(ptIns2);
|
|
pEquip->SetHidePipe(FALSE);
|
|
pEquip->SetSysBlock((const TCHAR*)xsTmp);
|
|
//pEquip->setLayer(LAY_EQ_DIRT);
|
|
if (sLayerPipe.Compare(LAY_PIPE_DIRT) == 0)
|
|
{
|
|
pEquip->setLayer(LAY_EQ_DIRT);
|
|
}
|
|
else if (sLayerPipe.Compare(LAY_PIPE_USELESS) == 0)
|
|
{
|
|
pEquip->setLayer(InitLayer(LAY_EQ_USELESS));
|
|
}
|
|
pEquip->SetDang(0);
|
|
pEquip->SetAngle(Ucs2Wcs(0.0)); // cet 2014.4.25 add
|
|
pEquip->SetPipeLength(0);
|
|
pEquip->SetSpare(0);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
|
|
TDbDimension2 *pDim = new TDbDimension2;
|
|
pDim->setLayer(LAY_DIM);
|
|
pDim->SetLocation(ptLoc);
|
|
pDim->SetStyleId(InitDimStyle(DS_LINEAR));
|
|
// pDim->SetRotation(ads_angle(XPoint(ptIns2), ptLoc));
|
|
pDim->SetRotation(Ucs2Wcs(PI * 0.5));
|
|
pDim->AddSegment(ptIns2);
|
|
pDim->SetDist2DimLine(nDist2DimLine, FALSE);
|
|
if(idx == 0){
|
|
TDimensionEdJig jig(pDim, _T("\n请点取尺寸线位置<退出>:"));
|
|
jig.m_nFlag=1;
|
|
if(jig.doIt() != RTNORM){
|
|
delete pDim;
|
|
return;
|
|
}
|
|
nDist2DimLine = pDim->GetDist2DimLine(FALSE);
|
|
}
|
|
AcDbObjectId idDim = pDim->AddToMSpace(Adesk::kTrue);
|
|
idx++;
|
|
}
|
|
}
|
|
|