6987 lines
175 KiB
C++
6987 lines
175 KiB
C++
#include "StdAfx.h"
|
||
#include "StdArx.h"
|
||
#include "dbobjptr.h"
|
||
#include "CoreTools.h"
|
||
#include "AecDbEwCable.h"
|
||
#include "AecDbEwPipeDim.h"
|
||
#include "AecDbECableTray.h"
|
||
#include "AecDbEcFitting.h"
|
||
#include "AecDbEwEquipment.h"
|
||
#include "AecDb3dRoadAxisLine.h"
|
||
#include "AecDbX3dPartEntity.h"
|
||
#include "AecDbEwFlexiblePipe.h"
|
||
#include "AecInfCmdGrip.h"
|
||
#include "AecDbWall.h"
|
||
#include "AecDbSlab.h"
|
||
#include "AecDbECableJig.h"
|
||
#include "EarThwormDef.h"
|
||
#include "AecDbECableLine.h"
|
||
#include "AecDbDirPosition.h"
|
||
#include "KTCadUtility.h"
|
||
#include "KTCADUtilityEx.h"
|
||
#include "KTTempTol.h"
|
||
#include "KTCADSysVar.h"
|
||
#include "OffSetDlg.h"
|
||
#include "KTSetting.h"
|
||
#include "HDLGDlg.h"
|
||
#include "AcPolylineJig.h"
|
||
#include "PSDLDlg.h"
|
||
#include "DCQJDlg.h"
|
||
#include "AECStatusRecord.h"
|
||
#include "ECableParamDlg.h"
|
||
#include "CablelineTools.h"
|
||
#include "CHBLWDlg.h"
|
||
#include "CRXLGDlg.h"
|
||
#include "CHBLDDlg.h"
|
||
#include "BDQGDlg.h"
|
||
#include "CHZXGDlg.h"
|
||
#include "CDLFSDlg.h"
|
||
#include "CLJQXDlg.h"
|
||
#include "CSBTBDlg.h"
|
||
#include "KTExpressCalc.h"
|
||
#include "CXYCDDlg.h"
|
||
#include "CHFZDDlg.h"
|
||
#include "CYXKKDlg.h"
|
||
#include "CSDFSDlg.h"
|
||
#include "excel9.h"
|
||
#include "CSTXXDlg.h"
|
||
#include "CDLCKDLG.h"
|
||
#include "CSBBMDlg.h"
|
||
#include "GJXGDlg.h"
|
||
#include "FITLockedDlg.h"
|
||
#include "AecPipeLineModify.h"
|
||
#include "CQJBZDlg.h"
|
||
#include "KTModelLayoutXData.h"
|
||
|
||
#define DXF_PIPE _T("AEC_DBCABTRY")
|
||
#define DXF_PIPE_ONLY _T("AEC_DBCABTRY")
|
||
#define DXF_PIPE_DIM_ONLY _T("AEC_DBCABTRY,LINE")
|
||
#define DXF_PIPE_FIT_DIM_ONLY _T("AEC_DBCABTRY,AEC_DBECFIT,LINE")
|
||
|
||
#define DXF_PIPE_FIT _T("AEC_DBCABTRY,AEC_DBECFIT")
|
||
#define DXF_PIPE_FIT_DIM _T("AEC_DBCABTRY,AEC_DBECFIT,LINE")
|
||
#define DXF_ECABLE _T("AEC_EWCABLE")
|
||
|
||
#define gLayer_Pipe_Dim _T("LAY_PP3D_DIM")
|
||
#define gTextStyle_Pipe_Dim _T("Pipe_Dim")
|
||
|
||
extern bool DLLIMPEXP PickGripMessage(GripMessage& msg);
|
||
extern void DLLIMPEXP PushGripMessage(GripMessage&);
|
||
DLLIMPEXP bool GetDoubleClickEnt(LPCTSTR pszCmd,AcDbObjectId& id);
|
||
|
||
extern double GetElbowL(AecHvac::DuctParam* pParam);
|
||
extern double GetElbowLx(AecHvac::DuctParam* pParam);
|
||
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
||
extern void SortPoints(AcGePoint3dArray& points,AcDbCurve* pLine);
|
||
|
||
void FreeBuffer(int n, AcDbVoidPtrArray& arEntPtrs)
|
||
{
|
||
AcDbEntity* pEnt = NULL;
|
||
while (arEntPtrs.length() > n)
|
||
{
|
||
pEnt = (AcDbEntity*)arEntPtrs.last();
|
||
pEnt->erase();
|
||
pEnt->close();
|
||
DELETE_PTR(pEnt);
|
||
arEntPtrs.removeLast();
|
||
}
|
||
}
|
||
|
||
AcDbRegion* CreatePolygonRegionOnly(AcGePoint3d* pPoints,int nSize)
|
||
{
|
||
AcDbVoidPtrArray arCurPtrs;
|
||
for (int i = 0;i < nSize-1;i++)//5
|
||
{
|
||
if (pPoints[i].distanceTo(pPoints[i+1]) > 1.e-6)
|
||
{
|
||
AcDbLine* pLine = new AcDbLine(pPoints[i],pPoints[i+1]);
|
||
arCurPtrs.append(pLine);
|
||
|
||
//TEST
|
||
//AcDbLine* pCLn = (AcDbLine*)pLine->clone();
|
||
//pCLn->setColorIndex(1);
|
||
//AddToModelSpace(pCLn);
|
||
}
|
||
}
|
||
|
||
AcDbVoidPtrArray arRegPtrs;
|
||
AcDbRegion* pReg = NULL;
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
if ( Acad::eOk == ( es = AcDbRegion::createFromCurves(arCurPtrs,arRegPtrs) ) )
|
||
{
|
||
//FREE
|
||
AcDbEntity* pEnt = NULL;
|
||
for (int i = 0;i < arCurPtrs.length();i++)
|
||
{
|
||
pEnt = (AcDbEntity*)arCurPtrs.at(i);
|
||
DELETE_PTR(pEnt);
|
||
}
|
||
return (AcDbRegion*)arRegPtrs.first();
|
||
}
|
||
|
||
//error FREE
|
||
FreeBuffer(0,arCurPtrs);
|
||
return NULL;
|
||
}
|
||
|
||
void EL_HZQJCmdFnc()
|
||
{
|
||
AecDbECableJig jig;
|
||
jig.DoIt(WPipe::eBridge);
|
||
}
|
||
|
||
bool GetSamplePoints(AcDbCurve *pCurve, int nDivSegs, AcGePoint3dArray &arPts)
|
||
{
|
||
if (pCurve == NULL) return FALSE;
|
||
|
||
double dS = 0, dE = 0;
|
||
pCurve->getStartParam(dS);
|
||
pCurve->getEndParam(dE);
|
||
|
||
double dStep = (dE - dS) / nDivSegs;
|
||
AcGePoint3d pt;
|
||
|
||
for (int i = 0; i <= nDivSegs; i++)
|
||
{
|
||
if (Acad::eOk == pCurve->getPointAtParam(dS, pt))
|
||
{
|
||
arPts.append(pt);
|
||
}
|
||
dS += dStep;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
class CAutoWndDel
|
||
{
|
||
public:
|
||
CAutoWndDel() { m_pWnd = NULL; }
|
||
~CAutoWndDel()
|
||
{
|
||
if (m_pWnd != NULL)
|
||
{
|
||
delete m_pWnd;
|
||
}
|
||
}
|
||
CWnd* m_pWnd;
|
||
};
|
||
|
||
void EL_LJQJCmdFnc()
|
||
{
|
||
//选择路径
|
||
ads_name ent1;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, _T("LINE,ARC,AEC_ROADAXISLINE,LWPOLYLINE,POLYLINE"), 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择路径(直线,圆弧,路径线,多义线):"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent1);
|
||
|
||
AcGePoint3d pt;
|
||
AcGePoint3dArray arPts;
|
||
bool bHasFit = true;
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead) )
|
||
{
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
arPts.append(pLn->startPoint());
|
||
arPts.append(pLn->endPoint());
|
||
}
|
||
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pEnt);
|
||
if (pPl != NULL)
|
||
{
|
||
if (pPl->hasBulges())
|
||
{
|
||
pEnt->close();
|
||
acutPrintf(_T("\n选择的PLINE线不可以有圆弧!"));
|
||
return;
|
||
}
|
||
|
||
for (int i = 0;i < pPl->numVerts();i++)
|
||
{
|
||
pPl->getPointAt(i, pt);
|
||
arPts.append(pt);
|
||
}
|
||
}
|
||
|
||
AcDb3dPolyline *pPl3d = AcDb3dPolyline::cast(pEnt);
|
||
if (pPl3d != NULL)
|
||
{
|
||
AcGePoint3dArray arPts;
|
||
|
||
AcDbEntity *pVEnt = NULL;
|
||
AcDbObjectIterator *pIt = pPl3d->vertexIterator();
|
||
for (pIt->start(); !pIt->done(); pIt->step())
|
||
{
|
||
pVEnt = pIt->entity();
|
||
|
||
AcDb3dPolylineVertex *pVtex = AcDb3dPolylineVertex::cast(pVEnt);
|
||
if (pVtex != NULL)
|
||
{
|
||
arPts.append(pVtex->position());
|
||
}
|
||
}
|
||
}
|
||
|
||
AecDb3dRoadAxisLine *pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
pRoad->GetReferLineSegPoints(arPts, false);
|
||
}
|
||
|
||
AcDbArc *pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL)
|
||
{
|
||
AcDbArc *pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL)
|
||
{
|
||
double dLen = (pArc->endAngle() - pArc->startAngle()) * pArc->radius();
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CHFZDDlg dlg;
|
||
dlg.SetLen(dLen);
|
||
nRes = dlg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
bHasFit = false;
|
||
GetSamplePoints(pArc, dlg.GetSegCount(), arPts);
|
||
|
||
if (dlg.m_bEraseArc)
|
||
{
|
||
pEnt->upgradeOpen();
|
||
pEnt->erase();
|
||
pEnt->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoItOnPath(WPipe::eBridge,arPts, bHasFit);
|
||
}
|
||
}
|
||
|
||
//路径缆沟
|
||
void EL_LJLGCmdFnc()
|
||
{
|
||
//选择路径
|
||
ads_name ent1;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, _T("LINE,ARC,AEC_ROADAXISLINE,LWPOLYLINE,POLYLINE"), 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择路径(直线,圆弧,路径线,多义线):"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent1);
|
||
|
||
AcGePoint3d pt;
|
||
AcGePoint3dArray arPts;
|
||
bool bHasFit = true;
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
arPts.append(pLn->startPoint());
|
||
arPts.append(pLn->endPoint());
|
||
}
|
||
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pEnt);
|
||
if (pPl != NULL)
|
||
{
|
||
if (pPl->hasBulges())
|
||
{
|
||
pEnt->close();
|
||
acutPrintf(_T("\n选择的PLINE线不可以有圆弧!"));
|
||
return;
|
||
}
|
||
|
||
for (int i = 0; i < pPl->numVerts(); i++)
|
||
{
|
||
pPl->getPointAt(i, pt);
|
||
arPts.append(pt);
|
||
}
|
||
}
|
||
|
||
AcDb3dPolyline *pPl3d = AcDb3dPolyline::cast(pEnt);
|
||
if (pPl3d != NULL)
|
||
{
|
||
AcGePoint3dArray arPts;
|
||
|
||
AcDbEntity *pVEnt = NULL;
|
||
AcDbObjectIterator *pIt = pPl3d->vertexIterator();
|
||
for (pIt->start(); !pIt->done(); pIt->step())
|
||
{
|
||
pVEnt = pIt->entity();
|
||
|
||
AcDb3dPolylineVertex *pVtex = AcDb3dPolylineVertex::cast(pVEnt);
|
||
if (pVtex != NULL)
|
||
{
|
||
arPts.append(pVtex->position());
|
||
}
|
||
}
|
||
}
|
||
|
||
AecDb3dRoadAxisLine *pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
pRoad->GetReferLineSegPoints(arPts, false);
|
||
}
|
||
|
||
AcDbArc *pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL)
|
||
{
|
||
AcDbArc *pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL)
|
||
{
|
||
double dLen = (pArc->endAngle() - pArc->startAngle()) * pArc->radius();
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CHFZDDlg dlg;
|
||
dlg.SetLen(dLen);
|
||
nRes = dlg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
bHasFit = false;
|
||
GetSamplePoints(pArc, dlg.GetSegCount(), arPts);
|
||
|
||
if (dlg.m_bEraseArc)
|
||
{
|
||
pEnt->upgradeOpen();
|
||
pEnt->erase();
|
||
pEnt->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoItOnPath(WPipe::eTrench, arPts, bHasFit);
|
||
}
|
||
}
|
||
|
||
//多层桥架
|
||
void EL_PCQJCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CDCQJDlg dlg;
|
||
if ( IDOK == dlg.DoModal() )
|
||
{
|
||
AcArray<AecHvac::DuctParam*> arParamPtrs;
|
||
dlg.GetPipeParams(arParamPtrs);
|
||
|
||
AecDbECableJig* pJig = NULL;
|
||
AcArray<AecDbECableJig*> arJigPtrs;
|
||
AecHvac::DuctParam* pParam = NULL;
|
||
for (int i = 0;i < arParamPtrs.length();i++)
|
||
{
|
||
pParam = (AecHvac::DuctParam*)arParamPtrs.at(i);
|
||
pJig = new AecDbECableJig(pParam);
|
||
pJig->InitXYPlanStatusRecs();
|
||
arJigPtrs.append(pJig);
|
||
}
|
||
|
||
//单线Jig;
|
||
AcPolylineJig plJig;
|
||
plJig.InitStatusRecsForLineSegs();
|
||
if ( plJig.DoIt() )
|
||
{
|
||
AcDbObjectId id = plJig.GetRoadAxisLineId();
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
//获取一系列点
|
||
AcGePoint3dArray arPts;
|
||
AcDbPolyline* pPl = pRoad->ConvertTo2dPline();
|
||
if (pPl != NULL)
|
||
{
|
||
AcGePoint3d ptGe;
|
||
for (int i = 0;i < pPl->numVerts();i++)
|
||
{
|
||
pPl->getPointAt(i,ptGe);
|
||
arPts.append(ptGe);
|
||
}
|
||
delete pPl;
|
||
}
|
||
|
||
AcGePoint3d ptGe;
|
||
for (int ii = 0;ii < arJigPtrs.length();ii++)
|
||
{
|
||
pJig = arJigPtrs.at(ii);
|
||
pParam = (AecHvac::DuctParam*)arParamPtrs.at(ii);
|
||
|
||
for (int i = 0;i < arPts.length();i++)
|
||
{
|
||
ptGe = arPts.at(i);
|
||
ptGe.z = pParam->m_dEl;
|
||
|
||
pJig->SetPickPoint(ptGe);
|
||
pJig->AfterDrag();
|
||
pJig->EndDragRecord();
|
||
}
|
||
}
|
||
}
|
||
pEnt->erase();
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
for (int ii = 0;ii < arJigPtrs.length();ii++)
|
||
{
|
||
pJig = arJigPtrs.at(ii);
|
||
delete pJig;
|
||
}
|
||
}
|
||
}
|
||
|
||
void DBL_AEC_DBCABTRY()
|
||
{
|
||
AcDbObjectId id;
|
||
bool bIsOk = GetDoubleClickEnt(_T("DBL_AEC_DBCABTRY"),id);
|
||
|
||
if (bIsOk && id.isValid())
|
||
{
|
||
AcGePoint3d ptS;
|
||
AcGePoint3d ptE;
|
||
AcGeVector3d vt;
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
||
BOOL bGetParam = FALSE;
|
||
|
||
XHolder lHolder, rHolder;
|
||
memset(&lHolder, 0, sizeof(XHolder));
|
||
memset(&rHolder, 0, sizeof(XHolder));
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
||
{
|
||
AecDbECableTray* pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetDuctParam(param);
|
||
ptS = pPipe->StartPoint();
|
||
ptE = pPipe->EndPoint();
|
||
|
||
if (param.m_app == WPipe::eTrench)
|
||
{
|
||
pPipe->GetXHolder(kLeft, lHolder);
|
||
pPipe->GetXHolder(kRight, rHolder);
|
||
}
|
||
|
||
vt = ptE - ptS;
|
||
bGetParam = TRUE;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
bool bIsXElPipe = false;
|
||
double dElOld = param.m_dEl;
|
||
|
||
AcGeLine3d ln(ptS,vt);
|
||
if (!ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
bIsXElPipe = true;
|
||
}
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
if (param.m_app == WPipe::eTrench)
|
||
{
|
||
CHDLGDlg drawCnfgDLg;
|
||
drawCnfgDLg.EnableLoadLast(FALSE);
|
||
drawCnfgDLg.SetShowParam(param);
|
||
drawCnfgDLg.SetXHolder(lHolder,rHolder);
|
||
|
||
drawCnfgDLg.LockEl(bIsXElPipe);//锁定标高
|
||
drawCnfgDLg.SetAlignEnable(FALSE);//锁定对齐
|
||
|
||
int nRes = drawCnfgDLg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
drawCnfgDLg.GetPipeParam(¶m);
|
||
drawCnfgDLg.GetXHolder(lHolder, rHolder);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->SetDuctParam(¶m);
|
||
pPipe->SetXHolder(kLeft, lHolder);
|
||
pPipe->SetXHolder(kRight, rHolder);
|
||
}
|
||
pEnt->close();
|
||
|
||
if (fabs(param.m_dEl - dElOld) > 1.e-2)//标高改动
|
||
{
|
||
//发送管口改动消息
|
||
AcGeVector3d vtOffset(0, 0, param.m_dEl - dElOld);
|
||
|
||
GripMessage msg;
|
||
//reset
|
||
msg.nSegindex = -1;
|
||
msg.nType = -1;
|
||
msg.idHost.setNull();
|
||
msg.pParam = 0;
|
||
msg.nData = -1;
|
||
_tcscpy(msg.szLockId, _T("0"));//锁定id,如果有
|
||
msg.fData = 0;
|
||
msg.nSegindex = 0;
|
||
msg.nSubSegIndex = 0;
|
||
msg.vtOffset.set(0, 0, 0);
|
||
msg.ptGrip.set(0, 0, 0);
|
||
|
||
msg.nType = eMid;
|
||
msg.nData = -1;
|
||
msg.idHost = id;
|
||
msg.vtOffset = vtOffset;
|
||
|
||
PushGripMessage(msg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
CECableParamDlg drawCnfgDLg;
|
||
drawCnfgDLg.EnableLoadLast(FALSE);
|
||
drawCnfgDLg.SetShowParam(param);
|
||
drawCnfgDLg.LockEl(bIsXElPipe);//锁定标高
|
||
drawCnfgDLg.SetAlignEnable(FALSE);//锁定对齐
|
||
drawCnfgDLg.SetEditObj(id);
|
||
int nRes = drawCnfgDLg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
drawCnfgDLg.GetPipeParam(¶m);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->SetDuctParam(¶m);
|
||
}
|
||
pEnt->close();
|
||
|
||
if (fabs(param.m_dEl - dElOld) > 1.e-2)//标高改动
|
||
{
|
||
//发送管口改动消息
|
||
AcGeVector3d vtOffset(0, 0, param.m_dEl - dElOld);
|
||
|
||
GripMessage msg;
|
||
//reset
|
||
msg.nSegindex = -1;
|
||
msg.nType = -1;
|
||
msg.idHost.setNull();
|
||
msg.pParam = 0;
|
||
msg.nData = -1;
|
||
_tcscpy(msg.szLockId, _T("0"));//锁定id,如果有
|
||
msg.fData = 0;
|
||
msg.nSegindex = 0;
|
||
msg.nSubSegIndex = 0;
|
||
msg.vtOffset.set(0, 0, 0);
|
||
msg.ptGrip.set(0, 0, 0);
|
||
|
||
msg.nType = eMid;
|
||
msg.nData = -1;
|
||
msg.idHost = id;
|
||
msg.vtOffset = vtOffset;
|
||
|
||
PushGripMessage(msg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void DBL_AEC_DBECFIT()
|
||
{
|
||
AcDbObjectId id;
|
||
bool bIsOk = GetDoubleClickEnt(_T("DBL_AEC_DBECFIT"), id);
|
||
|
||
if (bIsOk && id.isValid())
|
||
{
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
BOOL bGetParam = FALSE;
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbEcFitting *pFit = AecDbEcFitting::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetDuctParam(param);
|
||
bGetParam = TRUE;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
if (param.m_app == WPipe::eTrench)//电缆沟
|
||
{
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
extern bool DLLIMPEXP GetPipeNetNodes(const AcDbObjectId &id1, AcDbObjectIdArray &arNetIds, const AcDbObjectId &id0, const AcDbObjectId &id2);
|
||
extern bool DLLIMPEXP GetPipeNetNodes(const AcDbObjectId &id1, AcDbObjectIdArray &arNetIds, BOOL bTeeStop, BOOL bCrossStop,BOOL bReducerStop);
|
||
void EL_QJBGCmdFnc()
|
||
{
|
||
//弹出对话框
|
||
CAcModuleResourceOverride myResources;
|
||
CGJXGDlg dlg;
|
||
if (IDOK != dlg.DoModal())
|
||
return;
|
||
|
||
//选择桥架,或电缆沟
|
||
ads_name ent;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_ONLY, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择桥架变更尺寸:"), ent, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent);
|
||
|
||
//获取管网
|
||
AcDbObjectIdArray arNetIds;
|
||
GetPipeNetNodes(id1, arNetIds, dlg.m_bTeeStop, dlg.m_bCrossStop,TRUE);
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
for (int i = 0; i < arNetIds.length(); i++)
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, arNetIds.at(i), AcDb::kForWrite))
|
||
{
|
||
pEnt->highlight();
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
TCHAR szDummy[133];
|
||
nRes = acedGetString(0, _T("\n按 <RETURN> 确认修改."), szDummy);
|
||
if (nRes != RTNORM)
|
||
{
|
||
for (int i = 0; i < arNetIds.length(); i++)
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, arNetIds.at(i), AcDb::kForRead))
|
||
{
|
||
pEnt->unhighlight();
|
||
pEnt->close();
|
||
}
|
||
}
|
||
acutRelRb(pRb);
|
||
|
||
//解锁所有的Fit
|
||
for (int i = 0; i < arNetIds.length(); i++)
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, arNetIds.at(i), AcDb::kForWrite))
|
||
{
|
||
AecDbEcFitting *pFit = AecDbEcFitting::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->LockInf(-1);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
|
||
AcDbObjectIdArray arFitIds, arPipeIds, arEquIds;
|
||
|
||
bool bFitPosLock = false;
|
||
AcGePoint3dArray arFitInfPts;
|
||
|
||
//acutPrintf(_T("\n%d:%s"),nRes,szDummy);
|
||
for (int i = 0; i < arNetIds.length(); i++)
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, arNetIds.at(i), AcDb::kForRead))
|
||
{
|
||
//分出管子和管件
|
||
AecDbECableTray *pWpipe = AecDbECableTray::cast(pEnt);
|
||
if (pWpipe != NULL)
|
||
{
|
||
arPipeIds.append(arNetIds.at(i));
|
||
}
|
||
|
||
AecDbEcFitting *pFit = AecDbEcFitting::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
arFitIds.append(arNetIds.at(i));
|
||
|
||
int nType = -1;
|
||
pFit->GetSpecialtyData()->GetAt(KEY_RUNTIME, nType);
|
||
|
||
EFittingType eType = (EFittingType)nType;
|
||
if (eType == eElbow ||
|
||
eType == eTee ||
|
||
eType == eWye ||
|
||
eType == eLateral ||
|
||
eType == eCross)
|
||
{
|
||
|
||
AcArray<AecInterface> arInfs;
|
||
pFit->GetInterface(arInfs);
|
||
|
||
for (int ii = 0; ii < arInfs.length(); ii++)
|
||
{
|
||
AecInterface &inf = arInfs.at(ii);
|
||
|
||
if (arFitInfPts.find(inf.ptPos) == -1)
|
||
{
|
||
arFitInfPts.append(inf.ptPos);
|
||
}
|
||
else
|
||
{
|
||
bFitPosLock = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//桥架,电缆沟上没有设备 如阀门之类 /////
|
||
/*AecDbEwEquipment *pEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pEqu != NULL)
|
||
{
|
||
arEquIds.append(arNetIds.at(i));
|
||
}*/
|
||
|
||
pEnt->unhighlight();
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
//判断弯头接弯头的定位位置锁定情况
|
||
if (bFitPosLock)
|
||
{
|
||
CAcModuleResourceOverride rcTmp;
|
||
CFITLockedDlg fitDlg;
|
||
fitDlg.DoModal();
|
||
//acedAlert(_T("选择的管线存在弯头三通四通相互连接定位位置锁定!不可管线变更!"));
|
||
return;
|
||
}
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id1, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetDuctParam(param);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
AecHvac::DuctParam paramNew;
|
||
memset(¶mNew, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
bool bGetParam = false;
|
||
if (param.m_app == WPipe::eTrench)
|
||
{
|
||
CHDLGDlg drawCnfgDLg;
|
||
drawCnfgDLg.EnableLoadLast(FALSE);
|
||
drawCnfgDLg.LockEl(true);//锁定标高
|
||
drawCnfgDLg.SetShowParam(param);
|
||
drawCnfgDLg.SetAlignEnable(FALSE);//锁定对齐
|
||
|
||
nRes = drawCnfgDLg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
drawCnfgDLg.GetPipeParam(¶mNew);
|
||
bGetParam = true;
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
CECableParamDlg drawCnfgDLg;
|
||
drawCnfgDLg.EnableLoadLast(FALSE);
|
||
drawCnfgDLg.LockEl(true);//锁定标高
|
||
drawCnfgDLg.SetShowParam(param);
|
||
drawCnfgDLg.SetAlignEnable(FALSE);//锁定对齐
|
||
|
||
nRes = drawCnfgDLg.DoModal();
|
||
if (nRes == IDOK)
|
||
{
|
||
drawCnfgDLg.GetPipeParam(¶mNew);
|
||
bGetParam = true;
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
AecPipeLineModify pipeModify;
|
||
pipeModify.m_bTeeStop = dlg.m_bTeeStop;
|
||
pipeModify.m_bCrossStop = dlg.m_bCrossStop;
|
||
pipeModify.m_bElLock = true;
|
||
pipeModify.SetPipeParamOld(¶m);
|
||
pipeModify.SetPipeNetIds(arNetIds);
|
||
|
||
//设置undo标记
|
||
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
||
if (pipeModify.ModifyPipeLineParam(arPipeIds, arFitIds, arEquIds, paramNew, FALSE))
|
||
{
|
||
pipeModify.AddjustTInfAssoc();
|
||
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
||
}
|
||
else
|
||
{
|
||
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("B"), RTNONE);
|
||
}
|
||
}
|
||
acutRelRb(pRb);
|
||
CoreTools::refreshGraphics();
|
||
}
|
||
}
|
||
|
||
void EL_cabtryaddCmdFnc()
|
||
{
|
||
GripMessage msg;
|
||
PickGripMessage(msg);
|
||
|
||
if (msg.nType >= eCommand0 && msg.nType <= eCommand20)
|
||
{
|
||
AcDbObjectId id = msg.idHost;
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenObject(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
CString sLayer = pEnt->layer();
|
||
|
||
AecDbECableTray* pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL) //管子拉伸命令
|
||
{
|
||
AecInterface intf;
|
||
pPipe->AecMInterfaces::GetInterface(msg.ptGrip, intf);
|
||
|
||
if (!pPipe->AecMInterfaces::HasInterface(msg.ptGrip, intf.vtDir))
|
||
{
|
||
//是中间夹点
|
||
AcGeVector3d vtDir = pPipe->EndPoint() - pPipe->StartPoint();
|
||
//vtDir.rotateBy(PI / 2.0, pPipe->normal()); //? Z
|
||
vtDir.rotateBy(PI / 2.0, AcGeVector3d::kZAxis); //? Z
|
||
intf.vtDir = vtDir;
|
||
intf.ptPos = msg.ptGrip;
|
||
}
|
||
|
||
//判断是否是管子sta点
|
||
AcGePoint3d ptSta = pPipe->StartPoint();
|
||
if (ptSta.distanceTo(intf.ptPos) < 1.e-1)
|
||
{
|
||
AcGeVector3d vtDir = intf.vtDir;
|
||
//vtDir.negate();//不需要反转
|
||
intf.vtDir = vtDir;
|
||
}
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pPipe->GetDuctParam(param);
|
||
|
||
AecUserInterface infu;
|
||
if (pPipe->GetUserInterface(intf.ptPos, infu))
|
||
{
|
||
if (infu.nPoints == 2)
|
||
{
|
||
param.dSize[0] = infu.ptGe[0].distanceTo(infu.ptGe[1]);
|
||
intf.vtDir = infu.vtDir;
|
||
intf.idOwner.setNull();
|
||
}
|
||
else if (infu.nPoints == 4)
|
||
{
|
||
param.dSize[0] = infu.ptGe[0].distanceTo(infu.ptGe[1]);
|
||
param.dSize[1] = infu.ptGe[1].distanceTo(infu.ptGe[2]);
|
||
intf.vtDir = infu.vtDir;
|
||
intf.idOwner.setNull();
|
||
}
|
||
}
|
||
|
||
param.m_dEl = intf.ptPos.z;
|
||
pEnt->close();
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoIt(&intf, ¶m);
|
||
return;
|
||
}
|
||
|
||
AecDbEcFitting* pWFit = AecDbEcFitting::cast(pEnt);
|
||
if (pWFit != NULL) //管件拉伸命令
|
||
{
|
||
AecInterface intf;
|
||
pWFit->AecMInterfaces::GetInterface(msg.ptGrip, intf);
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pWFit->GetDuctParam(param);
|
||
|
||
AecUserInterface infu;
|
||
if (pWFit->GetUserInterface(intf.ptPos, infu))
|
||
{
|
||
if (infu.nPoints == 2)
|
||
{
|
||
param.dSize[0] = infu.ptGe[0].distanceTo(infu.ptGe[1]);
|
||
intf.vtDir = infu.vtDir;
|
||
}
|
||
else if (infu.nPoints == 4)
|
||
{
|
||
param.dSize[0] = infu.ptGe[0].distanceTo(infu.ptGe[1]);
|
||
param.dSize[1] = infu.ptGe[1].distanceTo(infu.ptGe[2]);
|
||
intf.vtDir = infu.vtDir;
|
||
}
|
||
}
|
||
|
||
param.m_dEl = intf.ptPos.z;
|
||
pEnt->close();
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoIt(&intf, ¶m);
|
||
return;
|
||
}
|
||
|
||
AecDbEwEquipment* pWEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pWEqu != NULL) //设备元件拉伸命令
|
||
{
|
||
AecInterface intf;
|
||
pWEqu->AecMInterfaces::GetInterface(msg.ptGrip, intf);
|
||
pEnt->close();
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoIt(&intf, NULL); //需要选择管子的外径等规格
|
||
return;
|
||
}
|
||
|
||
AecDbX3dPartEntity* pXPart = AecDbX3dPartEntity::cast(pEnt);
|
||
if (pXPart != NULL)
|
||
{
|
||
AecInterface intf;
|
||
pXPart->AecMInterfaces::GetInterface(msg.ptGrip, intf);
|
||
pEnt->close();
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoIt(&intf, NULL); //需要选择管子的外径等规格
|
||
return;
|
||
}
|
||
|
||
//命令夹点拉伸命令
|
||
AecInfCmdGrip* pPt = AecInfCmdGrip::cast(pEnt);
|
||
if (pPt != NULL)
|
||
{
|
||
AecInterface intf;
|
||
pPt->GetInf(intf);
|
||
|
||
AecDbECableJig jig;
|
||
jig.DoIt(&intf, NULL); //需要选择管子的外径等规格
|
||
return;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void AddUserinfTee(AecDbECableTray* pPipeMaj, AecDbECableTray* pPipeMin, AcGeVector3d& vtMaj, AcGeVector3d& vtMin)
|
||
{
|
||
AecHvac::DuctParam paramM, paramN;
|
||
pPipeMaj->GetDuctParam(paramM);
|
||
pPipeMin->GetDuctParam(paramN);
|
||
|
||
AcGeLine3d lnM(pPipeMaj->StartPoint(),vtMaj);
|
||
if (lnM.isParallelTo(AcGePlane::kXYPlane) &&
|
||
vtMin.isParallelTo(AcGeVector3d::kZAxis) )//
|
||
{
|
||
//vtMin 投影到 Maj
|
||
AcDbVoidPtrArray arEntPtrs, arReslt;
|
||
pPipeMin->GetDraw2dables(0,arEntPtrs);
|
||
|
||
AcDbCurve* pCurve = KTCADUtilityEx::ConvertBoundCurve(arEntPtrs,arReslt);
|
||
if (pCurve != NULL)
|
||
{
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pCurve);
|
||
if (pPl != NULL)
|
||
{
|
||
//取其中4个角点
|
||
AecUserInterface uinf;
|
||
pPipeMin->objectId().handle().getIntoAsciiBuffer(uinf.szNo);
|
||
_tcscpy(uinf.szSys, paramN.szSys);
|
||
uinf.vtDir = vtMin;
|
||
|
||
AcGePoint3d ptS, ptE,ptM,ptTmp;
|
||
ptE = pPipeMin->EndPoint();
|
||
ptS = pPipeMin->StartPoint();
|
||
ptM = MidPoint(ptS, ptE);
|
||
pPipeMaj->getClosestPointTo(ptM, ptTmp);
|
||
|
||
AcGeVector3d vtTmp = ptM - ptTmp;
|
||
if (vtTmp.dotProduct(vtMin) < 0)
|
||
{
|
||
uinf.vtDir.negate();
|
||
}
|
||
uinf.vtDir.normalize();
|
||
|
||
//XY 面
|
||
if (pPl->numVerts() >= 4)
|
||
{
|
||
uinf.nPoints = 5;
|
||
for (int i = 0;i < 4;i++)
|
||
{
|
||
pPl->getPointAt(i, uinf.ptGe[i]);
|
||
}
|
||
uinf.ptGe[4] = uinf.ptGe[0];
|
||
|
||
AcGeVector3d vtZ(0, 0, 1);
|
||
vtZ *= paramM.m_dEl;
|
||
|
||
for (int i = 0;i < 5;i++)
|
||
{
|
||
uinf.ptGe[i] += vtZ;//到cen线
|
||
|
||
//到面
|
||
uinf.ptGe[i] += uinf.vtDir * 0.5 * paramM.dSize[1];
|
||
}
|
||
}
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶mM);
|
||
double dL = GetElbowL(¶mM);
|
||
double dLx = GetElbowLx(¶mM);
|
||
|
||
pipeLine.SplitWPipe(ptTmp, dL, pPipeMaj);
|
||
|
||
uinf.vtDir.normalize();
|
||
uinf.vtDir *= ( dL + dLx);
|
||
|
||
pipeLine.AddTee3(ptTmp,dL,vtMaj,vtMin,uinf);
|
||
|
||
//改变 pPipeMin 的长度
|
||
AcGePlane plan;
|
||
plan.set(uinf.ptGe[0], uinf.vtDir);
|
||
|
||
AcGePoint3d ptS1 = plan.closestPointTo(ptS);
|
||
AcGePoint3d ptE1 = plan.closestPointTo(ptE);
|
||
|
||
double dDis1 = ptS1.distanceTo(ptS);
|
||
double dDis2 = ptE1.distanceTo(ptE);
|
||
if (dDis1 < dDis2)
|
||
{
|
||
ptS1 += uinf.vtDir;
|
||
pPipeMin->SetStartPoint(ptS1);
|
||
}
|
||
else
|
||
{
|
||
ptE1 += uinf.vtDir;
|
||
pPipeMin->SetEndPoint(ptE1);
|
||
}
|
||
|
||
//TEST
|
||
//pPl->setColorIndex(1);
|
||
//CoreTools::AddToModelSpace(pPl);
|
||
delete pPl;
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
|
||
//调换添加
|
||
AcGeLine3d lnN(pPipeMin->StartPoint(), vtMin);
|
||
if (lnN.isParallelTo(AcGePlane::kXYPlane) &&
|
||
vtMaj.isParallelTo(AcGeVector3d::kZAxis) )//
|
||
{
|
||
//vtMaj 投影到 vtMin
|
||
AddUserinfTee(pPipeMin, pPipeMaj, vtMin, vtMaj);
|
||
return;
|
||
}
|
||
}
|
||
|
||
//添加三通
|
||
void EL_TJ3TCmdFnc()
|
||
{
|
||
ads_name ent1, ent2;
|
||
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择主桥架:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择支桥架:"), ent2, pRb);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity* pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipeMaj = AecDbECableTray::cast(pEnt1);
|
||
if (pPipeMaj != NULL)
|
||
{
|
||
AcDbEntity* pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipeMin = AecDbECableTray::cast(pEnt2);
|
||
if (pPipeMin != NULL)
|
||
{
|
||
AcGeLine3d ln1(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
AcGeLine3d ln2(pPipeMin->StartPoint(), pPipeMin->EndPoint());
|
||
|
||
AcGeVector3d vtMaj = pPipeMaj->EndPoint() - pPipeMaj->StartPoint();
|
||
AcGeVector3d vtMin = pPipeMin->EndPoint() - pPipeMin->StartPoint();
|
||
vtMaj.normalize();
|
||
vtMin.normalize();
|
||
|
||
AcGeVector3d vtNom = vtMaj.crossProduct(vtMin);
|
||
if (vtNom.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
//水平三通
|
||
AcGePoint3d ptMid, ptTemp1, ptTemp2;
|
||
if (ln1.intersectWith(ln2, ptMid)) //相交
|
||
{
|
||
AecHvac::DuctParam param2;
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
pPipeMaj->GetDuctParam(param2);
|
||
|
||
AecHvac::DuctParam param1;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
pPipeMin->GetDuctParam(param1);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以三通连接!"));
|
||
return;
|
||
}
|
||
|
||
if (param1.m_app == WPipe::eTrench)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是缆沟!不可以异形三通连接!"));
|
||
return;
|
||
}
|
||
|
||
double dRatio = param2.m_dRatio;
|
||
double dLx = GetElbowLx(¶m2);
|
||
double dL = GetElbowL(¶m2);
|
||
double dS = dL;
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m1);
|
||
|
||
//也可能加弯头,ptMid的两头有一在管子外
|
||
ptTemp1 = ptMid + vtMaj * dL;
|
||
ptTemp2 = ptMid - vtMaj * dL;
|
||
|
||
AcGeLineSeg3d lineGe(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
BOOL bAddTee = TRUE;
|
||
if (!lineGe.isOn(ptTemp1) || !lineGe.isOn(ptTemp2))
|
||
{
|
||
if (fabs(param1.dSize[0] - param2.dSize[0]) < 1.e-3) //==
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
|
||
bAddTee = FALSE;
|
||
if (pipeLine.AddElbow(id1, ptMid, id2))
|
||
{
|
||
}
|
||
return;
|
||
}
|
||
else// 只能加三通
|
||
{
|
||
bAddTee = TRUE;
|
||
}
|
||
}
|
||
|
||
if (bAddTee)
|
||
{
|
||
if (fabs(param1.dSize[1] - param2.dSize[1]) < 1.e-3)
|
||
{
|
||
int nPos = 1;//落在末端附近
|
||
double dDis1 = ptMid.distanceTo(pPipeMin->StartPoint());
|
||
double dDis2 = ptMid.distanceTo(pPipeMin->EndPoint());
|
||
if (dDis1 < dDis2)
|
||
nPos = 0; //落在开始端
|
||
|
||
//对方断为两个管子
|
||
pipeLine.SplitWPipe(ptMid, dL, pPipeMaj);
|
||
|
||
if (nPos == 1)
|
||
vtMin.negate();
|
||
|
||
//改变this管子的位置
|
||
pEnt2->close();
|
||
|
||
AcGePoint3d ptGe = ptMid + dS * vtMin;
|
||
pipeLine.ModifyWPipe(ptGe, id2, nPos);
|
||
|
||
pipeLine.AddTee(pPipeMaj, dL, ptMid, dS, vtMin);
|
||
pEnt1->close();
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两桥架高度不等,不能创建三通!"));
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的水平的两桥架标高不等,不能创建三通!"));
|
||
}
|
||
}
|
||
else //各种垂直三通
|
||
{
|
||
//acutPrintf(_T("\n各种垂直三通..."));
|
||
//并且交面有效
|
||
AddUserinfTee(pPipeMaj, pPipeMin,vtMaj,vtMin);
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void ModifyStartOrEnd(AecDbECableTray *pPipe,AcGePoint3d& ptMid, double dL, AcGeVector3d& vtMaj)
|
||
{
|
||
double dDis1 = pPipe->StartPoint().distanceTo(ptMid);
|
||
double dDis2 = pPipe->EndPoint().distanceTo(ptMid);
|
||
|
||
AcGeVector3d vt = pPipe->EndPoint() - pPipe->StartPoint();
|
||
vt.normalize();
|
||
|
||
AcGePoint3d pt;
|
||
if (dDis1 < dDis2)//靠近Start
|
||
{
|
||
pt = ptMid + vt * dL;
|
||
pPipe->SetStartPoint(pt);
|
||
vtMaj = vt;
|
||
}
|
||
else//靠近End
|
||
{
|
||
pt = ptMid - vt * dL;
|
||
pPipe->SetEndPoint(pt);
|
||
vtMaj = vt;
|
||
vtMaj.negate();
|
||
}
|
||
}
|
||
|
||
void ModifyStartOrEnd(AecDbECableTray *pPipe, AcGePoint3d& ptMid, AcGeVector3d& vtDir, double dL)
|
||
{
|
||
AcGePlane plan;
|
||
plan.set(ptMid, vtDir);
|
||
|
||
AcGePoint3d pt1 = plan.closestPointTo(pPipe->StartPoint());
|
||
AcGePoint3d pt2 = plan.closestPointTo(pPipe->EndPoint());
|
||
|
||
double dDis1 = pPipe->StartPoint().distanceTo(pt1);
|
||
double dDis2 = pPipe->EndPoint().distanceTo(pt2);
|
||
|
||
AcGeVector3d vt = pPipe->EndPoint() - pPipe->StartPoint();
|
||
vt.normalize();
|
||
|
||
AcGePoint3d pt;
|
||
if (dDis1 < dDis2)//靠近Start
|
||
{
|
||
pt = pt1 + vt * dL;
|
||
pPipe->SetStartPoint(pt);
|
||
}
|
||
else//靠近End
|
||
{
|
||
pt = pt2 - vt * dL;
|
||
pPipe->SetEndPoint(pt);
|
||
}
|
||
}
|
||
|
||
void AddUserinfTee(AcDbObjectId& id1, AcDbObjectId& id2, AcDbObjectId& id3)
|
||
{
|
||
AecHvac::DuctParam param1, param2, param3;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m3, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
if (pPipe1 != NULL)
|
||
{
|
||
pPipe1->GetDuctParam(param1);
|
||
|
||
AcDbEntity *pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
if (pPipe2 != NULL)
|
||
{
|
||
pPipe2->GetDuctParam(param2);
|
||
|
||
AcDbEntity *pEnt3 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt3, id3, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe3 = AecDbECableTray::cast(pEnt3);
|
||
if (pPipe3 != NULL)
|
||
{
|
||
pPipe3->GetDuctParam(param3);
|
||
|
||
AcGeLine3d ln1(pPipe1->StartPoint(), pPipe1->EndPoint());
|
||
AcGeLine3d ln2(pPipe2->StartPoint(), pPipe2->EndPoint());
|
||
|
||
KTTempTol tol(1.e-3);
|
||
AcGePoint3d ptMid;
|
||
if (!ln1.intersectWith(ln2, ptMid))
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
pEnt3->close();
|
||
acutPrintf(_T("\n水平的两桥架不相交!"));
|
||
return;
|
||
}
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m1);
|
||
|
||
double dL = GetElbowL(¶m1);
|
||
double dLx = GetElbowLx(¶m1);
|
||
|
||
AcDbVoidPtrArray arEntPtrs, arReslt;
|
||
pPipe3->GetDraw2dables(0, arEntPtrs);
|
||
|
||
AcDbCurve *pCurve = KTCADUtilityEx::ConvertBoundCurve(arEntPtrs, arReslt);
|
||
if (pCurve != NULL)
|
||
{
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pCurve);
|
||
if (pPl != NULL)
|
||
{
|
||
//取其中4个角点
|
||
AecUserInterface uinf;
|
||
id3.handle().getIntoAsciiBuffer(uinf.szNo);
|
||
_tcscpy(uinf.szSys, param3.szSys);
|
||
uinf.vtDir = pPipe3->EndPoint() - pPipe3->StartPoint();
|
||
uinf.vtDir.normalize();
|
||
|
||
AcGePoint3d ptS, ptE, ptM, ptTmp;
|
||
ptE = pPipe3->EndPoint();
|
||
ptS = pPipe3->StartPoint();
|
||
ptM = MidPoint(ptS, ptE);
|
||
pPipe1->getClosestPointTo(ptM, ptTmp);
|
||
|
||
AcGeVector3d vtTmp = ptM - ptTmp;
|
||
if (vtTmp.dotProduct(uinf.vtDir) < 0)
|
||
{
|
||
uinf.vtDir.negate();
|
||
}
|
||
uinf.vtDir.normalize();
|
||
|
||
//XY 面
|
||
if (pPl->numVerts() >= 4)
|
||
{
|
||
uinf.nPoints = 5;
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
pPl->getPointAt(i, uinf.ptGe[i]);
|
||
}
|
||
uinf.ptGe[4] = uinf.ptGe[0];
|
||
|
||
AcGeVector3d vtZ(0, 0, 1);
|
||
vtZ *= param1.m_dEl;
|
||
|
||
for (int i = 0; i < 5; i++)
|
||
{
|
||
uinf.ptGe[i] += vtZ;//到cen线
|
||
|
||
//到面
|
||
uinf.ptGe[i] += uinf.vtDir * 0.5 * param1.dSize[1];
|
||
}
|
||
}
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m1);
|
||
double dL = GetElbowL(¶m1);
|
||
double dLx = GetElbowLx(¶m1);
|
||
|
||
AcGeVector3d vtMaj, vtMin;
|
||
|
||
//改变pipe1,pipe2
|
||
ModifyStartOrEnd(pPipe1, ptMid, dL + dLx, vtMaj);
|
||
ModifyStartOrEnd(pPipe2, ptMid, dL + dLx, vtMin);
|
||
|
||
uinf.vtDir.normalize();
|
||
uinf.vtDir *= (dL + dLx);
|
||
|
||
vtMaj.normalize(); vtMin.normalize();
|
||
|
||
AcGePoint3d ptUinf = ptMid;
|
||
AcGeVector3d vtUinf = uinf.vtDir;
|
||
vtUinf.normalize();
|
||
ptUinf += vtUinf * 0.5 * param1.dSize[1];
|
||
ModifyStartOrEnd(pPipe3, ptUinf, uinf.vtDir, dL + dLx);
|
||
|
||
pipeLine.AddTee5(ptMid, dL, vtMaj, vtMin,uinf);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
pEnt3->close();
|
||
acutPrintf(_T("\n垂直桥架投影有获取失败!"));
|
||
return;
|
||
}
|
||
}
|
||
pEnt3->close();
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
|
||
//垂直三角三通
|
||
void EL_SJ3TCmdFnc()
|
||
{
|
||
ads_name ent1, ent2,ent3;
|
||
//平面 两垂直桥架+ Z向垂直桥架
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择水平桥架1:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择水平桥架2:"), ent2, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择垂直桥架3:"), ent3, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1, id2, id3;
|
||
acdbGetObjectId(id1, ent1);
|
||
acdbGetObjectId(id2, ent2);
|
||
acdbGetObjectId(id3, ent3);
|
||
|
||
AecHvac::DuctParam param1,param2,param3;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m3, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
AcGeVector3d vt1, vt2, vt3;
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
if (pPipe1 != NULL)
|
||
{
|
||
pPipe1->GetDuctParam(param1);
|
||
vt1 = pPipe1->EndPoint() - pPipe1->StartPoint();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
|
||
AcDbEntity *pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
if (pPipe2 != NULL)
|
||
{
|
||
pPipe2->GetDuctParam(param2);
|
||
vt2 = pPipe2->EndPoint() - pPipe2->StartPoint();
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
|
||
AcDbEntity *pEnt3 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt3, id3, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pPipe3 = AecDbECableTray::cast(pEnt3);
|
||
if (pPipe3 != NULL)
|
||
{
|
||
pPipe3->GetDuctParam(param3);
|
||
vt3 = pPipe3->EndPoint() - pPipe3->StartPoint();
|
||
}
|
||
pEnt3->close();
|
||
}
|
||
|
||
//param1=param2!=param3 参数相等
|
||
//
|
||
if (fabs(param1.dSize[0] - param2.dSize[0]) < 1.e-1 &&
|
||
fabs(param1.dSize[1] - param2.dSize[1]) < 1.e-1)
|
||
{
|
||
//...
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的桥架1,2 参数不等!"));
|
||
return;
|
||
}
|
||
|
||
AcGeLine3d ln1(AcGePoint3d::kOrigin, vt1);
|
||
AcGeLine3d ln2(AcGePoint3d::kOrigin, vt2);
|
||
if (vt3.isParallelTo(AcGeVector3d::kZAxis))
|
||
{
|
||
//
|
||
}
|
||
else
|
||
{
|
||
//...
|
||
acutPrintf(_T("\n选择的桥架3 不是Z向桥架!"));
|
||
return;
|
||
}
|
||
|
||
if ( ln1.isParallelTo(AcGePlane::kXYPlane) &&
|
||
ln2.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
AddUserinfTee(id1,id2,id3);
|
||
}
|
||
else
|
||
{
|
||
//...
|
||
acutPrintf(_T("\n选择的桥架1,2 不是水平桥架!"));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
acutRelRb(pRb);
|
||
}
|
||
|
||
//添加四通
|
||
void EL_TJ4TCmdFnc()
|
||
{
|
||
ads_name ent1, ent2;
|
||
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择主桥架:"), ent1, pRb, NULL);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择支桥架:"), ent2, pRb, NULL);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity* pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipeMaj = AecDbECableTray::cast(pEnt1);
|
||
if (pPipeMaj != NULL)
|
||
{
|
||
AcDbEntity* pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipeMin = AecDbECableTray::cast(pEnt2);
|
||
if (pPipeMin != NULL)
|
||
{
|
||
|
||
AcGeLine3d ln1(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
AcGeLine3d ln2(pPipeMin->StartPoint(), pPipeMin->EndPoint());
|
||
|
||
AcGeVector3d vtMaj = pPipeMaj->EndPoint() - pPipeMaj->StartPoint();
|
||
AcGeVector3d vtMin = pPipeMin->EndPoint() - pPipeMin->StartPoint();
|
||
vtMaj.normalize();
|
||
vtMin.normalize();
|
||
|
||
if (!vtMaj.isPerpendicularTo(vtMin))
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两桥架不垂直,无法加四通连结!请选择相互垂直的桥架!"));
|
||
return;
|
||
}
|
||
|
||
AcGePoint3d ptMid, ptTemp1, ptTemp2;
|
||
if (ln1.intersectWith(ln2, ptMid)) //相交
|
||
{
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1,0,sizeof(AecHvac::DuctParam));
|
||
memset(¶m2,0,sizeof(AecHvac::DuctParam));
|
||
|
||
pPipeMaj->GetDuctParam(param1);
|
||
pPipeMin->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以四通连接!"));
|
||
return;
|
||
}
|
||
|
||
AecHvac::DuctParam paramMaj,paramMin;
|
||
if (param1.dSize[0] > param2.dSize[0])
|
||
{
|
||
memcpy(¶mMaj,¶m1,sizeof(AecHvac::DuctParam));
|
||
memcpy(¶mMin,¶m2,sizeof(AecHvac::DuctParam));
|
||
}
|
||
else
|
||
{
|
||
memcpy(¶mMaj,¶m2,sizeof(AecHvac::DuctParam));
|
||
memcpy(¶mMin,¶m1,sizeof(AecHvac::DuctParam));
|
||
}
|
||
|
||
if ( fabs(param1.dSize[1] - param2.dSize[1]) < 1.e-3)
|
||
{
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶mMin);
|
||
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
pipeLine.AddCross(id1, ptMid, id2);
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两桥架高度不同,不能创建四通!"));
|
||
}
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//添加弯头
|
||
void EL_TJWTCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_name ent;
|
||
ads_point pt;
|
||
|
||
KTCADSysVar<int> var(_T("orthomode"), 1);
|
||
|
||
int nRes = acedEntSel(_T("\n选择桥架末端添加弯头:"), ent, pt);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
ads_point ptw;
|
||
acdbUcs2Wcs(pt, ptw, false);
|
||
AcGePoint3d ptGe = asPnt3d(ptw);
|
||
|
||
double dDis1 = ptGe.distanceTo(pPipe->StartPoint());
|
||
double dDis2 = ptGe.distanceTo(pPipe->EndPoint());
|
||
|
||
AcGeVector3d vtMaj = pPipe->EndPoint() - pPipe->StartPoint();
|
||
AcGePoint3d ptFrom = pPipe->EndPoint();
|
||
if (dDis1 < dDis2) //靠近start
|
||
{
|
||
ptFrom = pPipe->StartPoint();
|
||
}
|
||
else
|
||
{
|
||
vtMaj.negate();
|
||
}
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
||
pPipe->GetDuctParam(param);
|
||
|
||
vtMaj.normalize();
|
||
|
||
acdbWcs2Ucs(asDblArray(ptFrom), pt, false);
|
||
|
||
ads_point ptRes;
|
||
AcGePoint3d ptEnd, ptMid;
|
||
AcGeVector3d vtMin;
|
||
|
||
acedInitGet(RSG_OTHER, _T("U D"));
|
||
nRes = acedGetPoint(pt, _T("\n选择弯头的出口方向或另外桥架末端[向上(U)/向下(D)]:"), ptRes);
|
||
if (nRes == RTNORM)
|
||
{
|
||
//判断是否落在其他管子上,且直径相同
|
||
ads_name ss, ent;
|
||
ads_point pt1, pt2;
|
||
|
||
ads_point_set(ptRes, pt1);
|
||
ads_point_set(ptRes, pt2);
|
||
pt1[X] -= CoreTools::PixelToWcs(10);
|
||
pt1[Y] -= CoreTools::PixelToWcs(10);
|
||
pt2[X] += CoreTools::PixelToWcs(10);
|
||
pt2[Y] += CoreTools::PixelToWcs(10);
|
||
|
||
TCHAR szBuf[17];
|
||
struct resbuf eb1;
|
||
eb1.restype = 0;
|
||
_tcscpy(szBuf, DXF_PIPE);
|
||
eb1.resval.rstring = szBuf;
|
||
eb1.rbnext = NULL;
|
||
|
||
acedSSGet(_T("C"), pt1, pt2, &eb1, ss);
|
||
Adesk::Int32 lLen = 0;
|
||
acedSSLength(ss, &lLen);
|
||
|
||
BOOL bHitPipeok = FALSE;
|
||
if (lLen > 0)
|
||
{
|
||
acedSSName(ss, 0, ent);
|
||
acedSSFree(ss);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent);
|
||
AcDbEntity* pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pWPipe = AecDbECableTray::cast(pEnt2);
|
||
if (pWPipe != NULL)
|
||
{
|
||
AecHvac::DuctParam param2;
|
||
memset(¶m2,0,sizeof(AecHvac::DuctParam));
|
||
pWPipe->GetDuctParam(param2);
|
||
|
||
|
||
if ((int)param2.dSize[0] == (int)param.dSize[0])
|
||
{
|
||
AcGeLine3d ln1(pPipe->StartPoint(), pPipe->EndPoint());
|
||
AcGeLine3d ln2(pWPipe->StartPoint(), pWPipe->EndPoint());
|
||
if (ln2.intersectWith(ln1, ptMid))
|
||
{
|
||
//找距离ptmid最远的
|
||
int nDir1 = 1;//
|
||
vtMaj = ptMid - pPipe->StartPoint();
|
||
double dDis1 = ptMid.distanceTo(pPipe->StartPoint());
|
||
double dDis2 = ptMid.distanceTo(pPipe->EndPoint());
|
||
if (dDis1 - dDis2 < 1.e-10)//距离end远,修改Start
|
||
{
|
||
vtMaj = ptMid - pPipe->EndPoint();
|
||
nDir1 = 0;
|
||
}
|
||
vtMaj.normalize();
|
||
|
||
//找距离ptmid最远的
|
||
int nDir2 = 1;//
|
||
vtMin = ptMid - pWPipe->StartPoint();
|
||
dDis1 = ptMid.distanceTo(pWPipe->StartPoint());
|
||
dDis2 = ptMid.distanceTo(pWPipe->EndPoint());
|
||
if (dDis1 - dDis2 < 1.e-10)//距离end远,修改Start
|
||
{
|
||
vtMin = ptMid - pWPipe->EndPoint();
|
||
nDir2 = 0;
|
||
}
|
||
vtMin.normalize();
|
||
vtMin.negate();
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeline(&jig);
|
||
pipeline.SetPipeParam(¶m);
|
||
AcDbObjectId idElbow = pipeline.CreateElbow(vtMaj, ptMid, vtMin, ¶m, TRUE);
|
||
|
||
//延长两个管子
|
||
pPipe->upgradeOpen();
|
||
if (nDir1 == 0)
|
||
pPipe->SetStartPoint(pipeline.m_intf0.ptPos);
|
||
else
|
||
pPipe->SetEndPoint(pipeline.m_intf0.ptPos);
|
||
pPipe->downgradeOpen();
|
||
|
||
if (nDir2 == 0)
|
||
pWPipe->SetStartPoint(pipeline.m_intf1.ptPos);
|
||
else
|
||
pWPipe->SetEndPoint(pipeline.m_intf1.ptPos);
|
||
|
||
bHitPipeok = TRUE;
|
||
pEnt->close();
|
||
pEnt2->close();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
|
||
if (!bHitPipeok)
|
||
{
|
||
ads_point ptResw;
|
||
acdbUcs2Wcs(ptRes, ptResw, false);
|
||
ptEnd = asPnt3d(ptResw);
|
||
vtMin = ptEnd - ptFrom;
|
||
vtMin.normalize();
|
||
}
|
||
}
|
||
else if (nRes == RTKWORD)
|
||
{
|
||
TCHAR szKey[3];
|
||
acedGetInput(szKey);
|
||
if (_tcsicmp(_T("U"), szKey) == 0)
|
||
{
|
||
vtMin = AcGeVector3d::kZAxis;
|
||
}
|
||
else if (_tcsicmp(_T("D"), szKey) == 0)
|
||
{
|
||
vtMin = -AcGeVector3d::kZAxis;
|
||
}
|
||
|
||
//2024-1-15
|
||
//double dTmp = param.dSize[0];
|
||
//param.dSize[0] = param.dSize[1];
|
||
//param.dSize[1] = dTmp;
|
||
}
|
||
|
||
if (vtMin.isParallelTo(vtMaj))
|
||
{
|
||
acutPrintf(_T("\n弯头的出口方向不能和主方向平行!"));
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
|
||
double dr = GetElbowL(¶m);
|
||
|
||
AcGeVector3d vtToCen = vtMin.orthoProject(vtMaj);
|
||
vtToCen.normalize();
|
||
AcGePoint3d ptCen = ptFrom + dr * vtToCen;
|
||
|
||
double dAng = vtMin.angleTo(vtMaj);//0-180
|
||
double dDot = vtMin.dotProduct(vtMaj);
|
||
if (dDot < -1.e-10 && dAng - PI / 2.0 < 1.e-10)
|
||
{
|
||
dAng = PI - dAng;
|
||
}
|
||
|
||
if (dAng - PI / 2.0 > 1.e-6)
|
||
{
|
||
acutPrintf(_T("弯头中心角度必须不大于90度"));
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
|
||
if (dAng - PI < 1.e-10)
|
||
dAng = PI - dAng;
|
||
|
||
double dCord = dr * cos((PI - dAng) / 2.0);
|
||
AcGeVector3d vtCord = vtMaj + vtMin;
|
||
vtCord.normalize();
|
||
ptMid = ptCen - vtCord * dCord;
|
||
AcGeVector3d vtToM = ptMid - ptCen;
|
||
vtToM.normalize();
|
||
|
||
ptMid = ptCen + dr / cos((PI - dAng) / 2.0) * vtToM;
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeline(&jig);
|
||
pipeline.SetPipeParam(¶m);
|
||
pipeline.CreateElbow(vtMaj, ptMid, vtMin, ¶m, TRUE);
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的实体不是管线!"));
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
//弯头连接
|
||
void EL_WTLJCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_name ent1, ent2;
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n在桥架末端选择桥架1:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n在桥架末端选择桥架2:"), ent2, pRb);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1, id2;
|
||
acdbGetObjectId(id1, ent1);
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity* pEnt1 = NULL;
|
||
AcDbEntity* pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray* pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pPipe1 != NULL && pPipe2 != NULL)
|
||
{
|
||
AcGeVector3d vtDir1 = pPipe1->EndPoint() - pPipe1->StartPoint();
|
||
AcGeVector3d vtDir2 = pPipe2->EndPoint() - pPipe2->StartPoint();
|
||
|
||
if (vtDir1.isParallelTo(vtDir2))
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架平行,不能加弯头连接!"));
|
||
return;
|
||
}
|
||
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1,0,sizeof(AecHvac::DuctParam));
|
||
memset(¶m2,0,sizeof(AecHvac::DuctParam));
|
||
|
||
pPipe1->GetDuctParam(param1);
|
||
pPipe2->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以弯头连接!"));
|
||
return;
|
||
}
|
||
|
||
/*if ((int)param1.dSize[0] != (int)param2.dSize[0])
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架主尺寸不相同,不能加弯头连接!"));
|
||
return;
|
||
}*/
|
||
|
||
//判断点在位置
|
||
AcGeLine3d ln1(pPipe1->StartPoint(), pPipe1->EndPoint());
|
||
AcGeLine3d ln2(pPipe2->StartPoint(), pPipe2->EndPoint());
|
||
|
||
AcGePoint3d ptMid;
|
||
if (ln1.intersectWith(ln2, ptMid) == Adesk::kTrue)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m2);
|
||
pipeLine.PushPipeParam();
|
||
pipeLine.AddElbow(id1, ptMid, id2);
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n两桥架底不能延长相交,不能弯头连接!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
AcGeVector3d GetLineInfDir(const AcGePoint3d& ptSta,const AcGePoint3d& ptEnd,const AcGePoint3d& ptHit)
|
||
{
|
||
double dDis1 = ptHit.distanceTo(ptSta);
|
||
double dDis2 = ptHit.distanceTo(ptEnd);
|
||
|
||
AcGeVector3d vt = ptEnd - ptSta;
|
||
if (dDis1 < dDis2)//sta
|
||
{
|
||
vt.negate();
|
||
}
|
||
return vt;
|
||
}
|
||
|
||
void ModifyECableTray(AecDbECableTray* pPipe,AecInterface& inf)
|
||
{
|
||
AcGePoint3d ptSta = pPipe->StartPoint();
|
||
AcGePoint3d ptEnd = pPipe->EndPoint();
|
||
|
||
double dDis1 = inf.ptPos.distanceTo(ptSta);
|
||
double dDis2 = inf.ptPos.distanceTo(ptEnd);
|
||
|
||
if (dDis1 < dDis2)//sta
|
||
{
|
||
pPipe->SetStartPoint(inf.ptPos);
|
||
}
|
||
else
|
||
{
|
||
pPipe->SetEndPoint(inf.ptPos);
|
||
}
|
||
}
|
||
|
||
//添加乙字弯
|
||
void EL_TJZWCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_point pt1,pt2;
|
||
ads_name ent1, ent2;
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请在桥架末端选择平行桥架1:"), ent1, pRb,pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n请在桥架末端选择平行桥架2:"), ent2, pRb,pt2);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1, id2;
|
||
acdbGetObjectId(id1, ent1);
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
ads_point pt11,pt22;
|
||
acdbUcs2Wcs(pt1,pt11,false);
|
||
acdbUcs2Wcs(pt2,pt22,false);
|
||
|
||
AcDbEntity* pEnt1 = NULL;
|
||
AcDbEntity* pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray* pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pPipe1 != NULL && pPipe2 != NULL)
|
||
{
|
||
AcGeVector3d vtDir1 = pPipe1->EndPoint() - pPipe1->StartPoint();
|
||
AcGeVector3d vtDir2 = pPipe2->EndPoint() - pPipe2->StartPoint();
|
||
|
||
AcGePoint3d pt111,pt222;
|
||
pPipe1->getClosestPointTo(asPnt3d(pt11),pt111,Adesk::kTrue);
|
||
pPipe2->getClosestPointTo(asPnt3d(pt22),pt222,Adesk::kTrue);
|
||
|
||
AcGePoint3d ptMid = MidPoint(pt111,pt222);
|
||
|
||
if (vtDir1.isParallelTo(vtDir2))//平行
|
||
{
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1,0,sizeof(AecHvac::DuctParam));
|
||
memset(¶m2,0,sizeof(AecHvac::DuctParam));
|
||
|
||
pPipe1->GetDuctParam(param1);
|
||
pPipe2->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
if ((int)param1.dSize[0] != (int)param2.dSize[0] )
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架主尺寸不相同,不能加乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
if ((int)param1.dSize[1] != (int)param2.dSize[1] )
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架主尺寸不相同,不能加乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
//判断是否共面 XY 或立面叠加
|
||
if ( fabs(param1.m_dEl - param2.m_dEl) < 1.e-10)//等标高
|
||
{
|
||
/*
|
||
m_mapSpecXData.GetAt(KEY_MAJBR, vtMaj);//进口方向
|
||
m_mapSpecXData.GetAt(KEY_MINBR, vtMin);//出口方向
|
||
m_mapSpecXData.GetAt(KEY_OFFSETDIR,vtOffset);//偏移方向
|
||
//vtMaj == vtMin
|
||
|
||
m_mapSpecXData.GetAt(KEY_NORMAL,vtNorm);
|
||
m_mapSpecXData.GetAt(KEY_MID, ptMid);//中间点
|
||
m_mapSpecXData.GetAt(KEY_Offset,dOffsetH);
|
||
|
||
m_mapSpecXData.GetAt(HELB_RadRatio, dRatio);
|
||
m_mapSpecXData.GetAt(PIPE_ELBOWANG,dSweepAngle);
|
||
m_mapSpecXData.GetAt(PIPE_THICK, dThick);
|
||
m_mapSpecXData.GetAt(HELB_LX, dLx);//直边长度
|
||
*/
|
||
|
||
//是否 不共线
|
||
AcGePoint3d pt2;
|
||
pPipe1->getClosestPointTo(pPipe2->EndPoint(),pt2,Adesk::kTrue);
|
||
|
||
AcGeVector3d vt = pt2 - pPipe2->EndPoint();
|
||
if (!vt.isZeroLength())//平面 不共线
|
||
{
|
||
if (!vtDir1.isCodirectionalTo(vtDir2))
|
||
vtDir2.negate();
|
||
|
||
AcGeVector3d vtOffset = vt;
|
||
vtOffset.negate();
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
COffSetDlg dlg;
|
||
dlg.m_dOffsetH = vt.length();
|
||
if (IDOK == dlg.DoModal() )
|
||
{
|
||
AecDbEcFitting* pFit = new AecDbEcFitting;
|
||
|
||
AecDbObjXDataMap* pXDataMap = pFit->GetSpecialtyData(AcDb::kForWrite);
|
||
|
||
pFit->SetDuctParam(param1);
|
||
|
||
vtDir1 = GetLineInfDir(pPipe1->StartPoint(),pPipe1->EndPoint(),asPnt3d(pt11));
|
||
vtDir2 = GetLineInfDir(pPipe2->StartPoint(),pPipe2->EndPoint(),asPnt3d(pt22));
|
||
vtDir2.negate();
|
||
|
||
pXDataMap->SetAt(KEY_RUNTIME,eOffset);
|
||
pXDataMap->SetAt(KEY_MAJBR, vtDir1);
|
||
pXDataMap->SetAt(KEY_MINBR, vtDir2);
|
||
pXDataMap->SetAt(KEY_OFFSETDIR,vtOffset);
|
||
pXDataMap->SetAt(KEY_MID,ptMid);
|
||
pXDataMap->SetAt(KEY_NORMAL,AcGeVector3d::kZAxis);
|
||
pXDataMap->SetAt(KEY_Offset,dlg.m_dOffsetH);
|
||
|
||
pXDataMap->SetAt(HELB_RadRatio, param1.m_dRatio);
|
||
pXDataMap->SetAt(PIPE_ELBOWANG,dlg.m_dAngle);
|
||
|
||
pXDataMap->SetAt(PIPE_THICK, param1.dSize[2]);
|
||
pXDataMap->SetAt(HELB_LX,50.0);
|
||
pXDataMap->SetAt(KEY_CENNODRAW,!param1.m_bCenDraw);
|
||
|
||
AecInterface inf0,inf1;
|
||
pFit->GetInterface(0,inf0);
|
||
pFit->GetInterface(1,inf1);
|
||
|
||
//修改桥架的位置
|
||
ModifyECableTray(pPipe1,inf0);
|
||
ModifyECableTray(pPipe2,inf1);
|
||
|
||
//设置图层
|
||
//设置图层
|
||
AecHvac::DuctParam *pParam = ¶m1;
|
||
AcDbObjectId idLay = KTSetting::InitLayer((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
int nColor = KTSetting::GetLayerColor((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
AcDbObjectId idCenLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_CEN : LAY_TRENCH_CEN, pParam->szSys, 4, _T("center2"), NULL);
|
||
AcDbObjectId idOutLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT, pParam->szSys, nColor, _T("Continuous"), NULL);
|
||
AcDbObjectId idSingle = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_SIG : LAY_TRENCH_SIG, pParam->szSys, 7, _T("Continuous"), NULL);
|
||
|
||
pFit->setLayer(idOutLay);
|
||
pFit->SetDoubleLayer(idOutLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
|
||
AcDbObjectId id = CoreTools::AddToModelSpace(pFit);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//叠加
|
||
AcGePoint3d pt2;
|
||
pPipe1->getClosestPointTo(pPipe2->EndPoint(),pt2,Adesk::kTrue);
|
||
AcGeVector3d vt = pt2 - pPipe2->EndPoint();
|
||
|
||
AcGeTol tol;
|
||
tol.setEqualVector(1.e-3);
|
||
tol.setEqualPoint(1.e-3);
|
||
if (vt.isParallelTo(AcGeVector3d::kZAxis,tol))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
COffSetDlg dlg;
|
||
dlg.m_dOffsetH = vt.length();
|
||
if (IDOK == dlg.DoModal() )
|
||
{
|
||
AcGeVector3d vtOffset = vt;
|
||
vtOffset.negate();
|
||
|
||
AcGeVector3d vtNorm = vtDir1;
|
||
vtNorm.rotateBy(PI/2.0,AcGeVector3d::kZAxis);
|
||
|
||
AecDbEcFitting* pFit = new AecDbEcFitting;
|
||
AecDbObjXDataMap* pXDataMap = pFit->GetSpecialtyData(AcDb::kForWrite);
|
||
|
||
pFit->SetDuctParam(param1);
|
||
|
||
vtDir1 = GetLineInfDir(pPipe1->StartPoint(),pPipe1->EndPoint(),asPnt3d(pt11));
|
||
vtDir2 = GetLineInfDir(pPipe2->StartPoint(),pPipe2->EndPoint(),asPnt3d(pt22));
|
||
vtDir2.negate();
|
||
|
||
pXDataMap->SetAt(KEY_RUNTIME,eOffset);
|
||
pXDataMap->SetAt(KEY_MAJBR, vtDir1);
|
||
pXDataMap->SetAt(KEY_MINBR, vtDir2);
|
||
pXDataMap->SetAt(KEY_OFFSETDIR,vtOffset);
|
||
pXDataMap->SetAt(KEY_MID,ptMid);
|
||
pXDataMap->SetAt(KEY_NORMAL,vtNorm);
|
||
pXDataMap->SetAt(KEY_Offset,dlg.m_dOffsetH);
|
||
|
||
pXDataMap->SetAt(HELB_RadRatio, param1.m_dRatio);
|
||
pXDataMap->SetAt(PIPE_ELBOWANG,dlg.m_dAngle);
|
||
|
||
pXDataMap->SetAt(PIPE_THICK, param1.dSize[2]);
|
||
pXDataMap->SetAt(HELB_LX,50.0);
|
||
pXDataMap->SetAt(KEY_CENNODRAW,!param1.m_bCenDraw);
|
||
|
||
AecInterface inf0,inf1;
|
||
pFit->GetInterface(0,inf0);
|
||
pFit->GetInterface(1,inf1);
|
||
|
||
//修改桥架的位置
|
||
ModifyECableTray(pPipe1,inf0);
|
||
ModifyECableTray(pPipe2,inf1);
|
||
|
||
//设置图层
|
||
//设置图层
|
||
AecHvac::DuctParam *pParam = ¶m1;
|
||
AcDbObjectId idLay = KTSetting::InitLayer((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
int nColor = KTSetting::GetLayerColor((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
AcDbObjectId idCenLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_CEN : LAY_TRENCH_CEN, pParam->szSys, 4, _T("center2"), NULL);
|
||
AcDbObjectId idOutLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT, pParam->szSys, nColor, _T("Continuous"), NULL);
|
||
AcDbObjectId idSingle = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_SIG : LAY_TRENCH_SIG, pParam->szSys, 7, _T("Continuous"), NULL);
|
||
|
||
pFit->setLayer(idOutLay);
|
||
pFit->SetDoubleLayer(idOutLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
|
||
AcDbObjectId id = CoreTools::AddToModelSpace(pFit);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个桥架不在叠加方向!不可加乙字弯连接!"));
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个桥架不平行!不可加乙字弯连接!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//桥架避让
|
||
void EL_QJBRCmdFnc()
|
||
{
|
||
//在管子上选择起始位置
|
||
|
||
ads_name ent1;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_ONLY, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择要加U型避让的桥架:"), ent1, pRb);
|
||
acutRelRb(pRb);
|
||
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
ads_point pt1, pt2;
|
||
AcGePoint3d ptGe[4], ptT;
|
||
bool bSet = false;
|
||
AcGeVector3d vtPipe;
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
|
||
nRes = acedGetPoint(NULL, _T("\n在桥架上选择U型避让的起点:"), pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n在桥架上选择U型避让的终点:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false);
|
||
acdbUcs2Wcs(pt2, pt22, false);
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id1, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
pPipe->GetDuctParam(param);
|
||
if (param.m_app == WPipe::eTrench)
|
||
{
|
||
acutPrintf(_T("\n选择的实体是电缆沟,不可以避让!"));
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
|
||
pPipe->getClosestPointTo(asPnt3d(pt11), ptGe[1]);
|
||
pPipe->getClosestPointTo(asPnt3d(pt22), ptGe[2]);
|
||
ptGe[0] = pPipe->StartPoint();
|
||
ptGe[3] = pPipe->EndPoint();
|
||
|
||
AcGeVector3d vt1 = ptGe[3] - ptGe[0];
|
||
vt1.normalize();
|
||
vtPipe = vt1;
|
||
|
||
AcGeVector3d vt2 = ptGe[2] - ptGe[1];
|
||
vt2.normalize();
|
||
|
||
if (vt1.dotProduct(vt2) < 0)//方向相反
|
||
{
|
||
ptT = ptGe[1];
|
||
ptGe[1] = ptGe[2];
|
||
ptGe[2] = ptT;
|
||
}
|
||
bSet = true;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bSet)
|
||
{
|
||
AcGePoint3d ptMid = MidPoint(ptGe[1], ptGe[2]);
|
||
AcGeLine3d ln;
|
||
ln.set(ptMid, vtPipe);
|
||
bool bUpDw = false;
|
||
|
||
//默认
|
||
AcGeVector3d vtDir = vtPipe.perpVector();
|
||
|
||
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
||
{
|
||
vtDir = AcGeVector3d::kZAxis;
|
||
//bUpDw = true;
|
||
}
|
||
else
|
||
{
|
||
if (vtPipe.isParallelTo(AcGeVector3d::kZAxis))
|
||
vtDir = AcGeVector3d::kXAxis;
|
||
}
|
||
|
||
ads_point ptm, ptmm;
|
||
acdbWcs2Ucs(asDblArray(ptMid), ptm, false);
|
||
|
||
TCHAR szTip[256];
|
||
_tcscpy(szTip, _T("\n请拾取一点指定水平避让方向:"));
|
||
|
||
if (bUpDw)
|
||
{
|
||
acedInitGet(RSG_OTHER, _T("U D"));
|
||
_tcscpy(szTip, _T("\n请拾取一点指定避让方向[向上(U)/向下(D):"));
|
||
}
|
||
|
||
nRes = acedGetPoint(ptm, szTip, ptm);
|
||
if (nRes == RTNORM)
|
||
{
|
||
acdbUcs2Wcs(ptm, ptmm, false);
|
||
AcGeVector3d vt = asPnt3d(ptmm) - ptMid;
|
||
vtDir = vt.orthoProject(vtPipe);
|
||
vtDir.normalize();
|
||
|
||
if (vtDir.isZeroLength())
|
||
{
|
||
acutPrintf(_T("\n当前避让方向零长度,方向无效!"));
|
||
return;
|
||
}
|
||
}
|
||
/*else if (nRes == RTKWORD)
|
||
{
|
||
TCHAR szKey[3];
|
||
acedGetInput(szKey);
|
||
if (_tcsicmp(_T("U"), szKey) == 0)
|
||
{
|
||
vtDir = AcGeVector3d::kZAxis;
|
||
}
|
||
else if (_tcsicmp(_T("D"), szKey) == 0)
|
||
{
|
||
vtDir = -AcGeVector3d::kZAxis;
|
||
}
|
||
}*/
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
//空间间距
|
||
nRes = RTNORM;
|
||
if (nRes == RTNORM)
|
||
{
|
||
double dSpace = 0;
|
||
nRes = acedGetReal(_T("\n请输入避让以管线中心为基准的空间间距<1000>:"), &dSpace);
|
||
if (nRes == RTNONE)
|
||
{
|
||
dSpace = 1000.0;
|
||
}
|
||
else if (nRes == RTCAN)
|
||
{
|
||
return;
|
||
}
|
||
|
||
vtDir *= dSpace;
|
||
|
||
AcGePoint3dArray arPts;
|
||
arPts.append(ptGe[0]);
|
||
arPts.append(ptGe[1]);
|
||
|
||
ptGe[1] += vtDir;
|
||
arPts.append(ptGe[1]);
|
||
|
||
ptGe[2] += vtDir;
|
||
arPts.append(ptGe[2]);
|
||
|
||
ptGe[2] -= vtDir;
|
||
arPts.append(ptGe[2]);
|
||
|
||
arPts.append(ptGe[3]);
|
||
|
||
//设置回退记录
|
||
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id1, AcDb::kForWrite))
|
||
{
|
||
pEnt->erase();
|
||
pEnt->close();
|
||
}
|
||
|
||
AecDbECableJig jig(¶m);
|
||
jig.DoItOnPath(WPipe::eBridge, arPts, true,false);
|
||
|
||
CoreTools::refreshGraphics();
|
||
|
||
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//引线开口
|
||
void EL_YXKKCmdFnc()
|
||
{
|
||
//桥架,桥架件 任意侧面开口 口大小 系统 方向
|
||
|
||
ads_name ent1;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_FIT, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择桥架或桥架付件:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pETray = AecDbECableTray::cast(pEnt1);
|
||
if (pETray != NULL)
|
||
{
|
||
pETray->GetDuctParam(param);
|
||
}
|
||
|
||
AecDbEcFitting *pEFit = AecDbEcFitting::cast(pEnt1);
|
||
if (pEFit != NULL)
|
||
{
|
||
pEFit->GetDuctParam(param);
|
||
}
|
||
|
||
if (param.m_app == WPipe::eTrench)
|
||
{
|
||
acedAlert(_T("选择的实体是缆沟,不可以引线开口!"));
|
||
pEnt1->close();
|
||
return;
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
|
||
if (param.m_app == WPipe::eBridge)//是桥架
|
||
{
|
||
//弹出界面,用户选择面和位置方向尺寸系统
|
||
CAcModuleResourceOverride myResources;
|
||
CYXKKDlg dlg;
|
||
dlg.SetObject(id1);
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AecUserInterface inf;
|
||
dlg.GetUserInf(inf);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pETray = AecDbECableTray::cast(pEnt1);
|
||
if (pETray != NULL)
|
||
{
|
||
pETray->AddUserInterface(inf);
|
||
}
|
||
|
||
AecDbEcFitting *pEFit = AecDbEcFitting::cast(pEnt1);
|
||
if (pEFit != NULL)
|
||
{
|
||
pEFit->AddUserInterface(inf);
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//绘制缆沟
|
||
void EL_HZLGCmdFnc_old()
|
||
{
|
||
//和绘制水槽一致
|
||
//添加相关属性
|
||
CAcModuleResourceOverride myResources;
|
||
CHDLGDlg dlg;
|
||
if (IDOK == dlg.DoModal() )
|
||
{
|
||
DlgData data;
|
||
AcArray<RegionAndEl> arRegEl;
|
||
|
||
dlg.GetDLGData(data,arRegEl);
|
||
|
||
AcPolylineJig wallJig;
|
||
wallJig.InitStatusRecsForWall(0.0,0.0);
|
||
|
||
if ( wallJig.DoIt() )
|
||
{
|
||
AcDbObjectId idLayerWall = KTSetting::InitLayer(_T("LAY_WALL"),true);
|
||
AcDbObjectId idLayerSlab = KTSetting::InitLayer(_T("LAY_SLAB"),true);
|
||
|
||
AcDbObjectId idRoadLn = wallJig.GetRoadAxisLineId();
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,idRoadLn,AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
for (int i = 0;i < arRegEl.length();i++)
|
||
{
|
||
RegionAndEl& rel = arRegEl.at(i);
|
||
|
||
if (rel.nType == 2)// 墙体
|
||
{
|
||
AcDbPolyline* pPl = pRoad->ConvertTo2dPline();
|
||
if (pPl != NULL)
|
||
{
|
||
AcDbVoidPtrArray arOff;
|
||
pPl->getOffsetCurves(rel.m_dX,arOff);
|
||
if ( !arOff.isEmpty() )
|
||
{
|
||
delete pPl;
|
||
AcDbCurve* pPlCrv = (AcDbCurve*)arOff.first();
|
||
|
||
AcDbVoidPtrArray arCurPtrs;
|
||
pPlCrv->explode(arCurPtrs);
|
||
|
||
//去处0长度线
|
||
double dEnd = 0.0,dEndL = 0.0;
|
||
AcDbCurve* pCurveT = NULL;
|
||
for (int n = 0;n < arCurPtrs.length();n++)
|
||
{
|
||
pCurveT = (AcDbCurve*)arCurPtrs.at(n);
|
||
pCurveT->getEndParam(dEnd);
|
||
pCurveT->getDistAtParam(dEnd,dEndL);
|
||
if (dEndL < 1.e-2)
|
||
{
|
||
arCurPtrs.removeAt(n);
|
||
n -= 1;
|
||
delete pCurveT;
|
||
}
|
||
}
|
||
|
||
//创建墙体
|
||
CString sSubNo;
|
||
AecDbXWall* pWall = NULL;
|
||
for (int ii = 0;ii < arCurPtrs.length();ii++)
|
||
{
|
||
sSubNo.Format(_T("WALL-%d"),ii+1);
|
||
|
||
pCurveT = (AcDbCurve*)arCurPtrs.at(ii);
|
||
|
||
pWall = new AecDbXWall;
|
||
pWall->SetBaseCurve(pCurveT);
|
||
pWall->GetSpecialtyData()->SetAt(KEY_NO,sSubNo);
|
||
pWall->GetSpecialtyData()->SetAt(KEY_MATERIAL,rel.m_szMat);
|
||
pWall->SetWallData(rel.dSize[0],rel.dSize[1],rel.m_dZ - 0.5 * rel.dSize[1],kMid);
|
||
pWall->setLayer(idLayerWall);
|
||
|
||
CKTCadUtility::AddToBlockTableRecord(pWall);
|
||
AcDbObjectId idNew = pWall->objectId();
|
||
pWall->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
delete pPl;
|
||
}
|
||
}
|
||
}
|
||
else if (rel.nType == 1)//板
|
||
{
|
||
AcDbPolyline* pPl = pRoad->ConvertTo2dPline();
|
||
if (pPl != NULL)
|
||
{
|
||
pPl->setElevation(rel.m_dZ);
|
||
|
||
TCHAR szHand[33];
|
||
idRoadLn.handle().getIntoAsciiBuffer(szHand);
|
||
|
||
CString sNo;
|
||
sNo.Format(_T("板_%s"),szHand);
|
||
|
||
AecDbXSlab* pSlab = new AecDbXSlab;
|
||
pSlab->SetSection(rel.dSize[0],rel.dSize[1],0.0);
|
||
pSlab->setLayer(idLayerSlab);
|
||
pSlab->SetBaseCurve(pPl);
|
||
pSlab->GetSpecialtyData()->SetAt(KEY_2DSTYLE,2);
|
||
|
||
pSlab->GetSpecialtyData()->SetAt(KEY_MATERIAL,rel.m_szMat);
|
||
pSlab->GetSpecialtyData()->SetAt(KEY_NO,sNo);
|
||
pSlab->SetHatch(_T("AR-CONC"),0.0,1.0);
|
||
|
||
CKTCadUtility::AddToBlockTableRecord(pSlab);
|
||
pSlab->close();
|
||
}
|
||
}
|
||
|
||
//暂时不用
|
||
//delete rel.pReg;
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void EL_HZLGCmdFnc()
|
||
{
|
||
AecDbECableJig jig;
|
||
jig.DoIt(WPipe::eTrench);
|
||
}
|
||
|
||
//合并缆沟
|
||
void EL_HBLGCmdFnc()
|
||
{
|
||
ads_name ss, ent1, ent2;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
|
||
int nRes = CKTCadUtility::SelectEntities(_T("\n请框选两个平行共线同属性的电缆沟:"), ss, pRb);
|
||
acutRelRb(pRb);
|
||
|
||
if (RTNORM == nRes)
|
||
{
|
||
Adesk::Int32 nLen = 0;
|
||
acedSSLength(ss, &nLen);
|
||
|
||
if (nLen == 2)
|
||
{
|
||
AcDbObjectId id1, id2;
|
||
|
||
acedSSName(ss, 0, ent1);
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
acedSSName(ss, 1, ent2);
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
AcDbEntity *pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pDuct1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray *pDuct2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pDuct1 != NULL && pDuct2 != NULL)
|
||
{
|
||
AcGeVector3d vt1 = pDuct1->GetTailDir();
|
||
AcGeVector3d vt2 = pDuct2->GetTailDir();
|
||
|
||
AecHvac::DuctParam data1, data2;
|
||
memset(&data1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(&data2, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pDuct1->GetDuctParam(data1);
|
||
pDuct2->GetDuctParam(data2);
|
||
|
||
if (vt1.isParallelTo(vt2) && //平行
|
||
fabs(data1.m_dEl - data2.m_dEl) < 1.e-3 && //标高
|
||
fabs(data1.dSize[0] - data2.dSize[0]) < 1.e-3 && //尺寸
|
||
fabs(data1.dSize[1] - data2.dSize[1]) < 1.e-3)
|
||
{
|
||
AcGePoint3d ptS1 = pDuct1->StartPoint();
|
||
AcGePoint3d ptE1 = pDuct1->EndPoint();
|
||
|
||
AcGePoint3d ptS2 = pDuct2->StartPoint();
|
||
AcGePoint3d ptE2 = pDuct2->EndPoint();
|
||
|
||
AcGePoint3dArray arPts;
|
||
arPts.append(ptS1);
|
||
arPts.append(ptE1);
|
||
|
||
if (arPts.find(ptS2) == -1)
|
||
arPts.append(ptS2);
|
||
|
||
if (arPts.find(ptE2) == -1)
|
||
arPts.append(ptE2);
|
||
|
||
AcDbLine ln(ptS1, ptE1);
|
||
SortPoints(arPts, &ln);
|
||
|
||
pDuct1->SetStartPoint(arPts.first());
|
||
pDuct1->SetEndPoint(arPts.last());
|
||
|
||
pDuct2->erase();
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个电缆沟实体几何属性不一致!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n必须选择两个电缆沟实体!"));
|
||
}
|
||
}
|
||
acedSSFree(ss);
|
||
}
|
||
|
||
//三通贯通
|
||
void EL_STGTCmdFnc()
|
||
{
|
||
ads_name ent1, ent2;
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择主电缆沟:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择支电缆沟:"), ent2, pRb);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipeMaj = AecDbECableTray::cast(pEnt1);
|
||
if (pPipeMaj != NULL)
|
||
{
|
||
AcDbEntity *pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
|
||
AecDbECableTray *pPipeMin = AecDbECableTray::cast(pEnt2);
|
||
if (pPipeMin != NULL)
|
||
{
|
||
AcGeLine3d ln1(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
AcGeLine3d ln2(pPipeMin->StartPoint(), pPipeMin->EndPoint());
|
||
|
||
AcGePoint3d ptMid, ptTemp1, ptTemp2;
|
||
if (ln1.intersectWith(ln2, ptMid)) //相交
|
||
{
|
||
AecHvac::DuctParam param2;
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
pPipeMaj->GetDuctParam(param2);
|
||
|
||
AecHvac::DuctParam param1;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
pPipeMin->GetDuctParam(param1);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以三通连接!"));
|
||
return;
|
||
}
|
||
|
||
double dRatio = param2.m_dRatio;
|
||
double dLx = GetElbowLx(¶m2);
|
||
double dL = GetElbowL(¶m2);
|
||
double dS = dL;
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m1);
|
||
|
||
AcGeVector3d vtMaj = pPipeMaj->EndPoint() - pPipeMaj->StartPoint();
|
||
AcGeVector3d vtMin = pPipeMin->EndPoint() - pPipeMin->StartPoint();
|
||
vtMaj.normalize();
|
||
vtMin.normalize();
|
||
|
||
//也可能加弯头,ptMid的两头有一在管子外
|
||
ptTemp1 = ptMid + vtMaj * dL;
|
||
ptTemp2 = ptMid - vtMaj * dL;
|
||
|
||
AcGeLineSeg3d lineGe(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
BOOL bAddTee = TRUE;
|
||
if (!lineGe.isOn(ptTemp1) || !lineGe.isOn(ptTemp2))
|
||
{
|
||
if (fabs(param1.dSize[0] - param2.dSize[0]) < 1.e-3) //==
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
|
||
bAddTee = FALSE;
|
||
if (pipeLine.AddElbow(id1, ptMid, id2))
|
||
{
|
||
}
|
||
return;
|
||
}
|
||
else// 只能加三通
|
||
{
|
||
bAddTee = TRUE;
|
||
}
|
||
}
|
||
|
||
if (bAddTee)
|
||
{
|
||
if (fabs(param1.dSize[1] - param2.dSize[1]) < 1.e-3)
|
||
{
|
||
int nPos = 1;//落在末端附近
|
||
double dDis1 = ptMid.distanceTo(pPipeMin->StartPoint());
|
||
double dDis2 = ptMid.distanceTo(pPipeMin->EndPoint());
|
||
if (dDis1 < dDis2)
|
||
nPos = 0; //落在开始端
|
||
|
||
//对方断为两个管子
|
||
pipeLine.SplitWPipe(ptMid, dL, pPipeMaj);
|
||
|
||
if (nPos == 1)
|
||
vtMin.negate();
|
||
|
||
//改变this管子的位置
|
||
pEnt2->close();
|
||
|
||
AcGePoint3d ptGe = ptMid + dS * vtMin;
|
||
pipeLine.ModifyWPipe(ptGe, id2, nPos);
|
||
|
||
pipeLine.AddTee(pPipeMaj, dL, ptMid, dS, vtMin);
|
||
pEnt1->close();
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acedAlert(_T("\n选择的两桥架高度不同,不能贯通!"));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//四通贯通
|
||
void EL_4TGTCmdFnc()
|
||
{
|
||
ads_name ent1, ent2;
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n选择主电缆沟:"), ent1, pRb, NULL);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n选择支电缆沟:"), ent2, pRb, NULL);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipeMaj = AecDbECableTray::cast(pEnt1);
|
||
if (pPipeMaj != NULL)
|
||
{
|
||
AcDbEntity *pEnt2 = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipeMin = AecDbECableTray::cast(pEnt2);
|
||
if (pPipeMin != NULL)
|
||
{
|
||
|
||
AcGeLine3d ln1(pPipeMaj->StartPoint(), pPipeMaj->EndPoint());
|
||
AcGeLine3d ln2(pPipeMin->StartPoint(), pPipeMin->EndPoint());
|
||
|
||
AcGeVector3d vtMaj = pPipeMaj->EndPoint() - pPipeMaj->StartPoint();
|
||
AcGeVector3d vtMin = pPipeMin->EndPoint() - pPipeMin->StartPoint();
|
||
vtMaj.normalize();
|
||
vtMin.normalize();
|
||
|
||
if (!vtMaj.isPerpendicularTo(vtMin))
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两桥架不垂直,无法加四通连结!请选择相互垂直的桥架!"));
|
||
return;
|
||
}
|
||
|
||
AcGePoint3d ptMid, ptTemp1, ptTemp2;
|
||
if (ln1.intersectWith(ln2, ptMid)) //相交
|
||
{
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pPipeMaj->GetDuctParam(param1);
|
||
pPipeMin->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以四通连接!"));
|
||
return;
|
||
}
|
||
|
||
AecHvac::DuctParam paramMaj, paramMin;
|
||
if (param1.dSize[0] > param2.dSize[0])
|
||
{
|
||
memcpy(¶mMaj, ¶m1, sizeof(AecHvac::DuctParam));
|
||
memcpy(¶mMin, ¶m2, sizeof(AecHvac::DuctParam));
|
||
}
|
||
else
|
||
{
|
||
memcpy(¶mMaj, ¶m2, sizeof(AecHvac::DuctParam));
|
||
memcpy(¶mMin, ¶m1, sizeof(AecHvac::DuctParam));
|
||
}
|
||
|
||
if (fabs(param1.dSize[1] - param2.dSize[1]) < 1.e-3)
|
||
{
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶mMin);
|
||
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
pipeLine.AddCross(id1, ptMid, id2);
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两桥架高度不同,不能创建四通!"));
|
||
}
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//弯头贯通
|
||
void EL_WTGTCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_name ent1, ent2;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n在电缆沟末端选择电缆沟1:"), ent1, pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n在电缆沟末端选择电缆沟2:"), ent2, pRb);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1, id2;
|
||
acdbGetObjectId(id1, ent1);
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
AcDbEntity *pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray *pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pPipe1 != NULL && pPipe2 != NULL)
|
||
{
|
||
AcGeVector3d vtDir1 = pPipe1->EndPoint() - pPipe1->StartPoint();
|
||
AcGeVector3d vtDir2 = pPipe2->EndPoint() - pPipe2->StartPoint();
|
||
|
||
if (vtDir1.isParallelTo(vtDir2))
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架平行,不能加弯头连接!"));
|
||
return;
|
||
}
|
||
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pPipe1->GetDuctParam(param1);
|
||
pPipe2->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以弯头连接!"));
|
||
return;
|
||
}
|
||
|
||
/*if ((int)param1.dSize[0] != (int)param2.dSize[0])
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根桥架主尺寸不相同,不能加弯头连接!"));
|
||
return;
|
||
}*/
|
||
|
||
//判断点在位置
|
||
AcGeLine3d ln1(pPipe1->StartPoint(), pPipe1->EndPoint());
|
||
AcGeLine3d ln2(pPipe2->StartPoint(), pPipe2->EndPoint());
|
||
|
||
AcGePoint3d ptMid;
|
||
if (ln1.intersectWith(ln2, ptMid) == Adesk::kTrue)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeLine(&jig);
|
||
pipeLine.SetPipeParam(¶m2);
|
||
pipeLine.PushPipeParam();
|
||
pipeLine.AddElbow(id1, ptMid, id2);
|
||
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两电缆沟在延长线上不相交!请检查标高是否一致!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//单加弯头
|
||
void EL_DJWTCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_name ent;
|
||
ads_point pt;
|
||
|
||
KTCADSysVar<int> var(_T("orthomode"), 1);
|
||
|
||
int nRes = acedEntSel(_T("\n选择电缆沟末端添加弯头:"), ent, pt);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe = AecDbECableTray::cast(pEnt);
|
||
if (pPipe != NULL)
|
||
{
|
||
ads_point ptw;
|
||
acdbUcs2Wcs(pt, ptw, false);
|
||
AcGePoint3d ptGe = asPnt3d(ptw);
|
||
|
||
double dDis1 = ptGe.distanceTo(pPipe->StartPoint());
|
||
double dDis2 = ptGe.distanceTo(pPipe->EndPoint());
|
||
|
||
AcGeVector3d vtMaj = pPipe->EndPoint() - pPipe->StartPoint();
|
||
AcGePoint3d ptFrom = pPipe->EndPoint();
|
||
if (dDis1 < dDis2) //靠近start
|
||
{
|
||
ptFrom = pPipe->StartPoint();
|
||
}
|
||
else
|
||
{
|
||
vtMaj.negate();
|
||
}
|
||
|
||
AecHvac::DuctParam param;
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pPipe->GetDuctParam(param);
|
||
|
||
vtMaj.normalize();
|
||
|
||
acdbWcs2Ucs(asDblArray(ptFrom), pt, false);
|
||
|
||
ads_point ptRes;
|
||
AcGePoint3d ptEnd, ptMid;
|
||
AcGeVector3d vtMin;
|
||
|
||
acedInitGet(RSG_OTHER, _T("U D"));
|
||
nRes = acedGetPoint(pt, _T("\n选择弯头的出口方向或另外电缆沟末端[向上(U)/向下(D)]:"), ptRes);
|
||
if (nRes == RTNORM)
|
||
{
|
||
//判断是否落在其他管子上,且直径相同
|
||
ads_name ss, ent;
|
||
ads_point pt1, pt2;
|
||
|
||
ads_point_set(ptRes, pt1);
|
||
ads_point_set(ptRes, pt2);
|
||
pt1[X] -= CoreTools::PixelToWcs(10);
|
||
pt1[Y] -= CoreTools::PixelToWcs(10);
|
||
pt2[X] += CoreTools::PixelToWcs(10);
|
||
pt2[Y] += CoreTools::PixelToWcs(10);
|
||
|
||
TCHAR szBuf[17];
|
||
struct resbuf eb1;
|
||
eb1.restype = 0;
|
||
_tcscpy(szBuf, DXF_PIPE);
|
||
eb1.resval.rstring = szBuf;
|
||
eb1.rbnext = NULL;
|
||
|
||
acedSSGet(_T("C"), pt1, pt2, &eb1, ss);
|
||
Adesk::Int32 lLen = 0;
|
||
acedSSLength(ss, &lLen);
|
||
|
||
BOOL bHitPipeok = FALSE;
|
||
if (lLen > 0)
|
||
{
|
||
acedSSName(ss, 0, ent);
|
||
acedSSFree(ss);
|
||
|
||
AcDbObjectId id2;
|
||
acdbGetObjectId(id2, ent);
|
||
AcDbEntity *pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pWPipe = AecDbECableTray::cast(pEnt2);
|
||
if (pWPipe != NULL)
|
||
{
|
||
AecHvac::DuctParam param2;
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
pWPipe->GetDuctParam(param2);
|
||
|
||
|
||
if ((int)param2.dSize[0] == (int)param.dSize[0])
|
||
{
|
||
AcGeLine3d ln1(pPipe->StartPoint(), pPipe->EndPoint());
|
||
AcGeLine3d ln2(pWPipe->StartPoint(), pWPipe->EndPoint());
|
||
if (ln2.intersectWith(ln1, ptMid))
|
||
{
|
||
//找距离ptmid最远的
|
||
int nDir1 = 1;//
|
||
vtMaj = ptMid - pPipe->StartPoint();
|
||
double dDis1 = ptMid.distanceTo(pPipe->StartPoint());
|
||
double dDis2 = ptMid.distanceTo(pPipe->EndPoint());
|
||
if (dDis1 - dDis2 < 1.e-10)//距离end远,修改Start
|
||
{
|
||
vtMaj = ptMid - pPipe->EndPoint();
|
||
nDir1 = 0;
|
||
}
|
||
vtMaj.normalize();
|
||
|
||
//找距离ptmid最远的
|
||
int nDir2 = 1;//
|
||
vtMin = ptMid - pWPipe->StartPoint();
|
||
dDis1 = ptMid.distanceTo(pWPipe->StartPoint());
|
||
dDis2 = ptMid.distanceTo(pWPipe->EndPoint());
|
||
if (dDis1 - dDis2 < 1.e-10)//距离end远,修改Start
|
||
{
|
||
vtMin = ptMid - pWPipe->EndPoint();
|
||
nDir2 = 0;
|
||
}
|
||
vtMin.normalize();
|
||
vtMin.negate();
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeline(&jig);
|
||
pipeline.SetPipeParam(¶m);
|
||
AcDbObjectId idElbow = pipeline.CreateElbow(vtMaj, ptMid, vtMin, ¶m, TRUE);
|
||
|
||
//延长两个管子
|
||
//pPipe->upgradeOpen();
|
||
if (nDir1 == 0)
|
||
pPipe->SetStartPoint(pipeline.m_intf0.ptPos);
|
||
else
|
||
pPipe->SetEndPoint(pipeline.m_intf0.ptPos);
|
||
//pPipe->downgradeOpen();
|
||
|
||
if (nDir2 == 0)
|
||
pWPipe->SetStartPoint(pipeline.m_intf1.ptPos);
|
||
else
|
||
pWPipe->SetEndPoint(pipeline.m_intf1.ptPos);
|
||
|
||
bHitPipeok = TRUE;
|
||
pEnt->close();
|
||
pEnt2->close();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
}
|
||
|
||
if (!bHitPipeok)
|
||
{
|
||
ads_point ptResw;
|
||
acdbUcs2Wcs(ptRes, ptResw, false);
|
||
ptEnd = asPnt3d(ptResw);
|
||
vtMin = ptEnd - ptFrom;
|
||
vtMin.normalize();
|
||
}
|
||
}
|
||
else if (nRes == RTKWORD)
|
||
{
|
||
TCHAR szKey[3];
|
||
acedGetInput(szKey);
|
||
if (_tcsicmp(_T("U"), szKey) == 0)
|
||
{
|
||
vtMin = AcGeVector3d::kZAxis;
|
||
}
|
||
else if (_tcsicmp(_T("D"), szKey) == 0)
|
||
{
|
||
vtMin = -AcGeVector3d::kZAxis;
|
||
}
|
||
double dTmp = param.dSize[0];
|
||
param.dSize[0] = param.dSize[1];
|
||
param.dSize[1] = dTmp;
|
||
}
|
||
|
||
if (vtMin.isParallelTo(vtMaj))
|
||
{
|
||
acutPrintf(_T("\n弯头的出口方向不能和主方向平行!"));
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
|
||
double dr = GetElbowL(¶m);
|
||
|
||
AcGeVector3d vtToCen = vtMin.orthoProject(vtMaj);
|
||
vtToCen.normalize();
|
||
AcGePoint3d ptCen = ptFrom + dr * vtToCen;
|
||
|
||
double dAng = vtMin.angleTo(vtMaj);//0-180
|
||
double dDot = vtMin.dotProduct(vtMaj);
|
||
if (dDot < -1.e-10 && dAng - PI / 2.0 < 1.e-10)
|
||
{
|
||
dAng = PI - dAng;
|
||
}
|
||
|
||
if (dAng - PI / 2.0 > 1.e-6)
|
||
{
|
||
acutPrintf(_T("弯头中心角度必须不大于90度"));
|
||
pEnt->close();
|
||
return;
|
||
}
|
||
|
||
if (dAng - PI < 1.e-10)
|
||
dAng = PI - dAng;
|
||
|
||
double dCord = dr * cos((PI - dAng) / 2.0);
|
||
AcGeVector3d vtCord = vtMaj + vtMin;
|
||
vtCord.normalize();
|
||
ptMid = ptCen - vtCord * dCord;
|
||
AcGeVector3d vtToM = ptMid - ptCen;
|
||
vtToM.normalize();
|
||
|
||
ptMid = ptCen + dr / cos((PI - dAng) / 2.0) * vtToM;
|
||
|
||
AecDbECableJig jig;
|
||
AecDbECableLine pipeline(&jig);
|
||
pipeline.SetPipeParam(¶m);
|
||
pipeline.CreateElbow(vtMaj, ptMid, vtMin, ¶m, TRUE);
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的实体不是管线!"));
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
//加乙字弯
|
||
void EL_JYZWCmdFnc()
|
||
{
|
||
//选择管线末点加弯头
|
||
ads_point pt1, pt2;
|
||
ads_name ent1, ent2;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请在电缆沟末端选择平行电缆沟1:"), ent1, pRb, pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = CKTCadUtility::SelectEntity(_T("\n请在电缆沟末端选择平行电缆沟2:"), ent2, pRb, pt2);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id1, id2;
|
||
acdbGetObjectId(id1, ent1);
|
||
acdbGetObjectId(id2, ent2);
|
||
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false);
|
||
acdbUcs2Wcs(pt2, pt22, false);
|
||
|
||
AcDbEntity *pEnt1 = NULL;
|
||
AcDbEntity *pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1, id1, AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2, id2, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pPipe1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray *pPipe2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pPipe1 != NULL && pPipe2 != NULL)
|
||
{
|
||
AcGeVector3d vtDir1 = pPipe1->EndPoint() - pPipe1->StartPoint();
|
||
AcGeVector3d vtDir2 = pPipe2->EndPoint() - pPipe2->StartPoint();
|
||
|
||
AcGePoint3d pt111, pt222;
|
||
pPipe1->getClosestPointTo(asPnt3d(pt11), pt111, Adesk::kTrue);
|
||
pPipe2->getClosestPointTo(asPnt3d(pt22), pt222, Adesk::kTrue);
|
||
|
||
AcGePoint3d ptMid = MidPoint(pt111, pt222);
|
||
|
||
if (vtDir1.isParallelTo(vtDir2))//平行
|
||
{
|
||
AecHvac::DuctParam param1, param2;
|
||
memset(¶m1, 0, sizeof(AecHvac::DuctParam));
|
||
memset(¶m2, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
pPipe1->GetDuctParam(param1);
|
||
pPipe2->GetDuctParam(param2);
|
||
|
||
if (param1.m_app != param2.m_app)
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的实体是桥架和缆沟!类型不一致,不可以乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
if ((int)param1.dSize[0] != (int)param2.dSize[0])
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根电缆沟主尺寸不相同,不能加乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
if ((int)param1.dSize[1] != (int)param2.dSize[1])
|
||
{
|
||
pEnt1->close();
|
||
pEnt2->close();
|
||
acutPrintf(_T("\n选择的两根电缆沟主尺寸不相同,不能加乙字弯连接!"));
|
||
return;
|
||
}
|
||
|
||
//判断是否共面 XY 或立面叠加
|
||
if (fabs(param1.m_dEl - param2.m_dEl) < 1.e-10)//等标高
|
||
{
|
||
/*
|
||
m_mapSpecXData.GetAt(KEY_MAJBR, vtMaj);//进口方向
|
||
m_mapSpecXData.GetAt(KEY_MINBR, vtMin);//出口方向
|
||
m_mapSpecXData.GetAt(KEY_OFFSETDIR,vtOffset);//偏移方向
|
||
//vtMaj == vtMin
|
||
|
||
m_mapSpecXData.GetAt(KEY_NORMAL,vtNorm);
|
||
m_mapSpecXData.GetAt(KEY_MID, ptMid);//中间点
|
||
m_mapSpecXData.GetAt(KEY_Offset,dOffsetH);
|
||
|
||
m_mapSpecXData.GetAt(HELB_RadRatio, dRatio);
|
||
m_mapSpecXData.GetAt(PIPE_ELBOWANG,dSweepAngle);
|
||
m_mapSpecXData.GetAt(PIPE_THICK, dThick);
|
||
m_mapSpecXData.GetAt(HELB_LX, dLx);//直边长度
|
||
*/
|
||
|
||
//是否 不共线
|
||
AcGePoint3d pt2;
|
||
pPipe1->getClosestPointTo(pPipe2->EndPoint(), pt2, Adesk::kTrue);
|
||
|
||
AcGeVector3d vt = pt2 - pPipe2->EndPoint();
|
||
if (!vt.isZeroLength())//平面 不共线
|
||
{
|
||
if (!vtDir1.isCodirectionalTo(vtDir2))
|
||
vtDir2.negate();
|
||
|
||
AcGeVector3d vtOffset = vt;
|
||
vtOffset.negate();
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
COffSetDlg dlg;
|
||
dlg.m_dOffsetH = vt.length();
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AecDbEcFitting *pFit = new AecDbEcFitting;
|
||
|
||
AecDbObjXDataMap *pXDataMap = pFit->GetSpecialtyData(AcDb::kForWrite);
|
||
|
||
pFit->SetDuctParam(param1);
|
||
|
||
vtDir1 = GetLineInfDir(pPipe1->StartPoint(), pPipe1->EndPoint(), asPnt3d(pt11));
|
||
vtDir2 = GetLineInfDir(pPipe2->StartPoint(), pPipe2->EndPoint(), asPnt3d(pt22));
|
||
vtDir2.negate();
|
||
|
||
pXDataMap->SetAt(KEY_RUNTIME, eOffset);
|
||
pXDataMap->SetAt(KEY_MAJBR, vtDir1);
|
||
pXDataMap->SetAt(KEY_MINBR, vtDir2);
|
||
pXDataMap->SetAt(KEY_OFFSETDIR, vtOffset);
|
||
pXDataMap->SetAt(KEY_MID, ptMid);
|
||
pXDataMap->SetAt(KEY_NORMAL, AcGeVector3d::kZAxis);
|
||
pXDataMap->SetAt(KEY_Offset, dlg.m_dOffsetH);
|
||
|
||
pXDataMap->SetAt(HELB_RadRatio, param1.m_dRatio);
|
||
pXDataMap->SetAt(PIPE_ELBOWANG, dlg.m_dAngle);
|
||
|
||
pXDataMap->SetAt(PIPE_THICK, param1.dSize[2]);
|
||
pXDataMap->SetAt(HELB_LX, 50.0);
|
||
pXDataMap->SetAt(KEY_CENNODRAW, !param1.m_bCenDraw);
|
||
|
||
AecInterface inf0, inf1;
|
||
pFit->GetInterface(0, inf0);
|
||
pFit->GetInterface(1, inf1);
|
||
|
||
//修改桥架的位置
|
||
ModifyECableTray(pPipe1, inf0);
|
||
ModifyECableTray(pPipe2, inf1);
|
||
|
||
//设置图层
|
||
AecHvac::DuctParam *pParam = ¶m1;
|
||
AcDbObjectId idLay = KTSetting::InitLayer((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
int nColor = KTSetting::GetLayerColor((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
AcDbObjectId idCenLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_CEN : LAY_TRENCH_CEN, pParam->szSys, 4, _T("center2"), NULL);
|
||
AcDbObjectId idOutLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT, pParam->szSys, nColor, _T("Continuous"), NULL);
|
||
AcDbObjectId idSingle = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_SIG : LAY_TRENCH_SIG, pParam->szSys, 7, _T("Continuous"), NULL);
|
||
|
||
pFit->setLayer(idOutLay);
|
||
pFit->SetDoubleLayer(idOutLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
|
||
AcDbObjectId id = CoreTools::AddToModelSpace(pFit);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//叠加
|
||
AcGePoint3d pt2;
|
||
pPipe1->getClosestPointTo(pPipe2->EndPoint(), pt2, Adesk::kTrue);
|
||
AcGeVector3d vt = pt2 - pPipe2->EndPoint();
|
||
|
||
AcGeTol tol;
|
||
tol.setEqualVector(1.e-3);
|
||
tol.setEqualPoint(1.e-3);
|
||
if (vt.isParallelTo(AcGeVector3d::kZAxis, tol))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
COffSetDlg dlg;
|
||
dlg.m_dOffsetH = vt.length();
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AcGeVector3d vtOffset = vt;
|
||
vtOffset.negate();
|
||
|
||
AcGeVector3d vtNorm = vtDir1;
|
||
vtNorm.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
||
|
||
AecDbEcFitting *pFit = new AecDbEcFitting;
|
||
AecDbObjXDataMap *pXDataMap = pFit->GetSpecialtyData(AcDb::kForWrite);
|
||
|
||
pFit->SetDuctParam(param1);
|
||
|
||
vtDir1 = GetLineInfDir(pPipe1->StartPoint(), pPipe1->EndPoint(), asPnt3d(pt11));
|
||
vtDir2 = GetLineInfDir(pPipe2->StartPoint(), pPipe2->EndPoint(), asPnt3d(pt22));
|
||
vtDir2.negate();
|
||
|
||
pXDataMap->SetAt(KEY_RUNTIME, eOffset);
|
||
pXDataMap->SetAt(KEY_MAJBR, vtDir1);
|
||
pXDataMap->SetAt(KEY_MINBR, vtDir2);
|
||
pXDataMap->SetAt(KEY_OFFSETDIR, vtOffset);
|
||
pXDataMap->SetAt(KEY_MID, ptMid);
|
||
pXDataMap->SetAt(KEY_NORMAL, vtNorm);
|
||
pXDataMap->SetAt(KEY_Offset, dlg.m_dOffsetH);
|
||
|
||
pXDataMap->SetAt(HELB_RadRatio, param1.m_dRatio);
|
||
pXDataMap->SetAt(PIPE_ELBOWANG, dlg.m_dAngle);
|
||
|
||
pXDataMap->SetAt(PIPE_THICK, param1.dSize[2]);
|
||
pXDataMap->SetAt(HELB_LX, 50.0);
|
||
pXDataMap->SetAt(KEY_CENNODRAW, param1.m_bCenDraw ? FALSE : TRUE);
|
||
|
||
AecInterface inf0, inf1;
|
||
pFit->GetInterface(0, inf0);
|
||
pFit->GetInterface(1, inf1);
|
||
|
||
//修改桥架的位置
|
||
ModifyECableTray(pPipe1, inf0);
|
||
ModifyECableTray(pPipe2, inf1);
|
||
|
||
//设置图层
|
||
AecHvac::DuctParam *pParam = ¶m1;
|
||
AcDbObjectId idLay = KTSetting::InitLayer((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
int nColor = KTSetting::GetLayerColor((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT);
|
||
AcDbObjectId idCenLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_CEN : LAY_TRENCH_CEN, pParam->szSys, 4, _T("center2"), NULL);
|
||
AcDbObjectId idOutLay = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_OUT : LAY_TRENCH_OUT, pParam->szSys, nColor, _T("Continuous"), NULL);
|
||
AcDbObjectId idSingle = CablelineTools::AecInitLayerEx((pParam->m_app == WPipe::eBridge) ? LAY_CABTRY_SIG : LAY_TRENCH_SIG, pParam->szSys, 7, _T("Continuous"), NULL);
|
||
|
||
pFit->setLayer(idOutLay);
|
||
pFit->SetDoubleLayer(idOutLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
pFit->SetCenterLayer(idCenLay);
|
||
|
||
AcDbObjectId id = CoreTools::AddToModelSpace(pFit);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个电缆沟不在叠加方向!不可加乙字弯连接!"));
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个电缆沟不平行!不可加乙字弯连接!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//缆沟支架
|
||
void EL_LGZJCmdFnc()
|
||
{
|
||
acedPostCommand(_T("PL_LGZJ "));
|
||
}
|
||
|
||
typedef struct XHolder_ // 支架
|
||
{
|
||
// 支架行数,或非等距支架行数
|
||
Adesk::Int32 N;
|
||
|
||
//等距电缆沟用
|
||
BOOL bNoEquDis;
|
||
|
||
// 支架垂直间距(m)
|
||
double V;
|
||
|
||
//或非等距支架,最多64行
|
||
Adesk::Int32 nDists[128];//间距
|
||
Adesk::Int32 nSyss[128];//系统序号
|
||
|
||
// 支架臂长度(mm)
|
||
double L;
|
||
|
||
// 角钢宽度(mm)
|
||
double W;
|
||
|
||
// 角钢厚度(mm)
|
||
double t;
|
||
|
||
//相对位置标高
|
||
double dBomEl;
|
||
|
||
// 材质
|
||
TCHAR szMat[33];
|
||
|
||
//编号
|
||
TCHAR szNo[33];
|
||
|
||
// 用途
|
||
TCHAR szUsage[33];
|
||
|
||
//预留
|
||
double dResv[6];
|
||
int nResv[6];
|
||
TCHAR szResv[MAX_PATH];
|
||
|
||
}XHolder_;
|
||
|
||
#include "CWTXXDlg.h"
|
||
void EL_TESTCmdFnc()
|
||
{
|
||
ads_name ent;
|
||
ads_point pt;
|
||
int nRes = acedEntSel(_T("\npick an ent:"), ent, pt);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
XHolder_ hld;
|
||
memset(&hld, 0, sizeof(XHolder_));
|
||
|
||
hld.N = 128;
|
||
hld.bNoEquDis = 1;
|
||
hld.V = 233;
|
||
|
||
for (int i = 0; i < 128; i++)
|
||
{
|
||
hld.nDists[i] = i + 1;
|
||
hld.nSyss[i] = i;
|
||
}
|
||
hld.L = 330;
|
||
hld.W = 50;
|
||
hld.t = 5;
|
||
hld.dBomEl = -178;
|
||
|
||
_tcscpy(hld.szMat, _T("Q235-A"));
|
||
_tcscpy(hld.szNo, _T("Q235-A-100-009"));
|
||
_tcscpy(hld.szUsage, _T("高压电缆支吊架"));
|
||
|
||
AecDbObjXDataMap xData;
|
||
xData.SetAt(_T("HOLDER"),&hld,sizeof(XHolder_));
|
||
nRes = xData.Write(id, _T("XDATA_"));
|
||
if (!nRes)
|
||
acutPrintf(_T("\nFailed write large xdata!!"));
|
||
|
||
AecDbObjXDataMap xData2;
|
||
xData2.Read(id, _T("XDATA_"));
|
||
|
||
int nSize = sizeof(XHolder_);
|
||
|
||
void *pData = NULL;
|
||
xData2.GetAt(_T("HOLDER"), pData, nSize);
|
||
|
||
XHolder_ *pHolder = NULL;
|
||
if (pData != NULL)
|
||
{
|
||
pHolder = (XHolder_ *)pData;
|
||
acutPrintf(_T("\nSuccess read large xdata!!"));
|
||
}
|
||
}
|
||
}
|
||
|
||
//布置支架
|
||
void EL_BZZJCmdFnc()
|
||
{
|
||
acedPostCommand(_T("PL_FZZJ "));
|
||
}
|
||
|
||
void DBL_AEC_EWCABLE()
|
||
{
|
||
AcDbObjectId id;
|
||
bool bIsOk = GetDoubleClickEnt(_T("DBL_AEC_EWCABLE"), id);
|
||
|
||
if (bIsOk && id.isValid())
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CPSDLDlg dlg;
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbEwCable *pCableNew = AecDbEwCable::cast(pEnt);
|
||
if (pCableNew != NULL)
|
||
{
|
||
pCableNew->GetSpecialtyData()->GetAt(_T("COLOR"), dlg.m_data.m_nClr);
|
||
|
||
AcDbObjectId idLt = pCableNew->GetSingleLineType();
|
||
|
||
AcDbSymbolTableRecordPointer<AcDbLinetypeTableRecord> rcLt(idLt,AcDb::kForRead);
|
||
if (rcLt.openStatus() == Acad::eOk)
|
||
{
|
||
LPCTSTR pszName = NULL;
|
||
rcLt->getName(pszName);
|
||
if (pszName != NULL)
|
||
{
|
||
dlg.m_data.m_linetype = pszName;
|
||
}
|
||
}
|
||
|
||
pCableNew->GetSpecialtyData()->GetAt(CABLE_D, dlg.m_data.m_dD);
|
||
pCableNew->GetSpecialtyData()->GetAt(CABLE_MODEL, dlg.m_data.m_sModel);
|
||
pCableNew->GetSpecialtyData()->GetAt(CABLE_FACTORY, dlg.m_data.m_sFactory);
|
||
pCableNew->GetSpecialtyData()->GetAt(CABLE_RATIO, dlg.m_data.m_dDn);
|
||
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
pCableNew->GetSpecialtyData()->SetAt(_T("COLOR"), dlg.m_data.m_nClr);
|
||
|
||
pCableNew->SetSingleLineType(KTSetting::InitLineStyle(dlg.m_data.m_linetype));
|
||
pCableNew->SetDoubleLineType(KTSetting::InitLineStyle(dlg.m_data.m_linetype));
|
||
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_D, dlg.m_data.m_dD);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_MODEL, dlg.m_data.m_sModel);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_FACTORY, dlg.m_data.m_sFactory);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_RATIO, dlg.m_data.m_dDn);
|
||
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
//铺设电缆
|
||
void EL_HZDLCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CPSDLDlg dlg;
|
||
if (IDOK == dlg.DoModal() )
|
||
{
|
||
AcPolylineJig wallJig;
|
||
wallJig.InitStatusRecsFor3dRoadAxisLine();
|
||
|
||
if ( wallJig.DoIt() )
|
||
{
|
||
AcDbObjectId idLayCable = KTSetting::InitLayer(_T("LAY_CABLE"),true);
|
||
|
||
AcDbObjectId idRoadLn = wallJig.GetRoadAxisLineId();
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,idRoadLn,AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
//第一段必须是直线段
|
||
AcGeVector3d vtOff(0, 1, 0);
|
||
vtOff.normalize();
|
||
AcDbCurve* pFirst = pRoad->GetCurveSeg(0);
|
||
if (pFirst != NULL)
|
||
{
|
||
AcDbVoidPtrArray arCurOff;
|
||
pFirst->getOffsetCurves(dlg.m_data.m_dSpace, arCurOff);
|
||
|
||
if (!arCurOff.isEmpty())
|
||
{
|
||
AcDbCurve *pFirst2 = (AcDbCurve *)arCurOff.first();
|
||
if (pFirst2 != NULL)
|
||
{
|
||
AcGePoint3d ptS, ptS2;
|
||
pFirst->getStartPoint(ptS);
|
||
pFirst2->getStartPoint(ptS2);
|
||
vtOff = ptS2 - ptS;
|
||
vtOff.normalize();
|
||
}
|
||
}
|
||
}
|
||
vtOff *= (dlg.m_data.m_dSpace + dlg.m_data.m_dD);
|
||
|
||
pRoad->SaveDandRatio(dlg.m_data.m_dD, dlg.m_data.m_dDn);
|
||
//pRoad->Create3dRoadAxisLine(dlg.m_data.m_dD, dlg.m_data.m_dDn);
|
||
|
||
AcGeMatrix3d xMove;
|
||
for (int i = 0;i < dlg.m_nLines;i++)
|
||
{
|
||
AecDbEwCable* pCableNew = new AecDbEwCable;
|
||
|
||
AecDb3dRoadAxisLine *pRoadAxLnCln = (AecDb3dRoadAxisLine *)pRoad->clone();
|
||
pCableNew->SetBaseCurve(pRoadAxLnCln);
|
||
|
||
pCableNew->SetSection(dlg.m_data.m_dD,0.0);
|
||
|
||
pCableNew->setColorIndex(dlg.m_data.m_nClr);
|
||
pCableNew->GetSpecialtyData()->SetAt(_T("COLOR"), dlg.m_data.m_nClr);
|
||
|
||
pCableNew->SetSingleLayer(idLayCable);
|
||
pCableNew->SetDoubleLayer(idLayCable);
|
||
|
||
pCableNew->SetSingleLineType(KTSetting::InitLineStyle(dlg.m_data.m_linetype));
|
||
pCableNew->SetDoubleLineType(KTSetting::InitLineStyle(dlg.m_data.m_linetype));
|
||
|
||
pCableNew->setLayer(idLayCable);
|
||
|
||
pCableNew->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 1);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_D, dlg.m_data.m_dD);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_MODEL, dlg.m_data.m_sModel);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_FACTORY, dlg.m_data.m_sFactory);
|
||
pCableNew->GetSpecialtyData()->SetAt(CABLE_RATIO, dlg.m_data.m_dDn);
|
||
|
||
CKTCadUtility::AddToBlockTableRecord(pCableNew);
|
||
pCableNew->close();
|
||
|
||
xMove.setToTranslation(vtOff);
|
||
pRoad->transformBy(xMove);
|
||
//pRoad->offset(dlg.m_dSpace);
|
||
}
|
||
pRoad->erase();
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
static double getPScale()
|
||
{
|
||
double dPScale(100.);
|
||
CString sScale(_T("1:100"));
|
||
AecDbObjXDataMap xDataMap;
|
||
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
|
||
xDataMap.GetAt(DOC_SCALE, sScale);
|
||
|
||
int idx = sScale.Find(':');
|
||
if (idx != -1)
|
||
{
|
||
sScale = sScale.Right(sScale.GetLength() - idx - 1);
|
||
dPScale = _ttof(sScale);
|
||
}
|
||
|
||
return dPScale;
|
||
}
|
||
|
||
static void GetDuctParam(AecDbObjXDataMap& xData,AecHvac::DuctParam &data)
|
||
{
|
||
memset(&data, 0, sizeof(AecHvac::DuctParam));
|
||
|
||
int nType = 0;
|
||
xData.GetAt(KEY_SECSHAPE, nType);
|
||
|
||
int nCenNDraw = 0;
|
||
ESection eType = (ESection)nType;
|
||
data.eType = eType;
|
||
|
||
data.m_app = WPipe::eBridge;
|
||
int nApp = 7;
|
||
xData.GetAt(KEY_APP, nApp);
|
||
data.m_app = WPipe::EApp(nApp);
|
||
if (nApp == 0)
|
||
data.m_app = WPipe::eBridge;
|
||
|
||
switch (eType)
|
||
{
|
||
case eRect:
|
||
{
|
||
xData.GetAt(KEY_SIZE1, data.dSize[0]); //L
|
||
xData.GetAt(KEY_SIZE2, data.dSize[1]); //w
|
||
xData.GetAt(PIPE_THICK, data.dSize[2]);//t
|
||
xData.GetAt(KEY_CENNODRAW, nCenNDraw);//中心线
|
||
data.m_bCenDraw = nCenNDraw ? 0 : 1;
|
||
break;
|
||
}
|
||
case eCircle:
|
||
{
|
||
xData.GetAt(KEY_SIZE1, data.dSize[0]); //D
|
||
data.dSize[1] = 0.0;
|
||
xData.GetAt(PIPE_THICK, data.dSize[2]);//t
|
||
xData.GetAt(KEY_CENNODRAW, nCenNDraw);//中心线
|
||
data.m_bCenDraw = nCenNDraw ? 0 : 1;
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
//假设是平行XY
|
||
//data.m_dEl = StartPoint().z;
|
||
|
||
data.m_nAlign = 1;//居中
|
||
xData.GetAt(KEY_WELLW, data.dSize[4]);
|
||
xData.GetAt(KEY_NORMAL, data.m_vtNrom);
|
||
xData.GetAt(KEY_RRATIO, data.m_dRatio);
|
||
|
||
xData.GetAt(KEY_FULLPER, data.m_dFullPer);
|
||
data.m_dFillUsed = 0;
|
||
xData.GetAt(KEY_FILLUSED, data.m_dFillUsed);
|
||
|
||
xData.GetAt(KEY_FULLPER2, data.m_dFullPer2);
|
||
data.m_dFillUsed2 = 0;
|
||
xData.GetAt(KEY_FILLUSED2, data.m_dFillUsed2);
|
||
|
||
CString sTemp = _T("");
|
||
xData.GetAt(KEY_SN, sTemp);
|
||
_tcscpy(data.szNo, (LPCTSTR)sTemp);
|
||
|
||
sTemp = _T("");
|
||
xData.GetAt(KEY_TYPE, sTemp);
|
||
_tcscpy(data.szType, (LPCTSTR)sTemp);
|
||
|
||
sTemp = _T("");
|
||
xData.GetAt(KEY_EXT, sTemp);
|
||
_tcscpy(data.szExt, (LPCTSTR)sTemp);
|
||
|
||
sTemp = _T("");
|
||
xData.GetAt(PIPE_SYS, sTemp);
|
||
_tcscpy(data.szSys, (LPCTSTR)sTemp);
|
||
|
||
xData.GetAt(KEY_COVER, data.m_bCover);
|
||
xData.GetAt(KEY_SPART, data.m_bSpart);
|
||
xData.GetAt(KEY_SYSSPLT, data.m_nSysSplit);
|
||
//...
|
||
xData.GetAt(KEY_MATERIAL, sTemp);
|
||
_tcscpy(data.szMat, (LPCTSTR)sTemp);
|
||
|
||
xData.GetAt(KEY_FACTORY, sTemp);
|
||
_tcscpy(data.szFat, (LPCTSTR)sTemp);
|
||
|
||
xData.GetAt(KEY_REM, sTemp);
|
||
_tcscpy(data.szRem, (LPCTSTR)sTemp);
|
||
|
||
//提取预留数据 电缆沟等用
|
||
CString sKey;
|
||
for (int i = 5; i < 33; i++)//
|
||
{
|
||
sKey.Format(_T("%s_%d"), KEY_SIZE, i);
|
||
xData.GetAt(sKey, data.dSize[i]);
|
||
}
|
||
}
|
||
|
||
//桥架标1 -- AecDbEwPipeDim方式
|
||
void EL_QJBZCmdFnc1()
|
||
{
|
||
ads_name ent1;
|
||
ads_point pt1, pt2;
|
||
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE_FIT_DIM, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择要标注的桥架:"), ent1, pRb, pt1);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n请选择位置:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false);
|
||
acdbUcs2Wcs(pt2, pt22, false);
|
||
|
||
AcGePoint3d ptFr = asPnt3d(pt11);
|
||
AcGePoint3d ptTo = asPnt3d(pt22);
|
||
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
//
|
||
AecHvac::DuctParam param;
|
||
BOOL bGetParam = FALSE;
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id1,AcDb::kForRead))
|
||
{
|
||
AecDbECableTray* pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
pTray->GetDuctParam(param);
|
||
bGetParam = TRUE;
|
||
}
|
||
|
||
AecDbEcFitting* pFit = AecDbEcFitting::cast(pEnt);
|
||
if (pFit != NULL)
|
||
{
|
||
pFit->GetDuctParam(param);
|
||
bGetParam = TRUE;
|
||
}
|
||
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
AecDbObjXDataMap xData;
|
||
if (xData.Read(pEnt, BIMDATA_APP))
|
||
{
|
||
GetDuctParam(xData, param); bGetParam = TRUE;
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
CString sDimUp;
|
||
sDimUp.Format(_T("%s %dx%d %s %s %s"),param.szType,(int)(param.dSize[0]+0.5),(int)(param.dSize[1]+0.5),param.szSys,param.szNo,param.szMat);
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim* pDim = new AecDbEwPipeDim;
|
||
pDim->AddAecDbWEntity(id1);
|
||
|
||
pDim->SetDimStyle(0);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->SetPScale(getPScale());
|
||
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
|
||
pDim->AddDimText(sDimUp,_T(""));
|
||
|
||
pDim->SetTextHeight(2.5);
|
||
pDim->SetTextWidthScale(0.75);
|
||
|
||
pDim->AppendPoint(ptFr);
|
||
pDim->AppendPoint(ptTo);
|
||
|
||
pDim->SetDimupdownSpace(0.0);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
CoreTools::AddToModelSpace(pDim);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
bool SortDuctParamBydR(AecHvac::DuctParam& pm1, AecHvac::DuctParam& pm2)
|
||
{
|
||
if (pm1.m_dR <= pm2.m_dR)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
//标注文字放在 DuctParam.szRem 中 临时
|
||
static bool GetCableTrayDimTxt(AecHvac::DuctParam &pm)
|
||
{
|
||
//szType 类型 : 槽式,梯式,托盘式
|
||
//1、槽式桥架代号:C ; 2、梯式桥架代号:T ; 3、托盘式桥架代号:P ; 4、组合式桥架代号:ZH
|
||
//槽式;托盘式;梯式;组合式;大跨距式;钢制式;铝制式
|
||
|
||
CString sPre = _T("");
|
||
if ( NULL != _tcsstr(pm.szType, _T("槽式") ) )
|
||
{
|
||
sPre = _T(" C");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("梯式")))
|
||
{
|
||
sPre = _T(" T");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("托盘")))
|
||
{
|
||
sPre = _T(" P");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("组合式")))
|
||
{
|
||
sPre = _T(" ZH");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("大跨距")))
|
||
{
|
||
sPre = _T(" DJ");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("钢制")))
|
||
{
|
||
sPre = _T(" G");
|
||
}
|
||
else if (NULL != _tcsstr(pm.szType, _T("铝制")))
|
||
{
|
||
sPre = _T(" L");
|
||
}
|
||
else
|
||
{
|
||
sPre = _T("C");
|
||
}
|
||
|
||
CString sSize;
|
||
sSize.Format(_T("电缆桥架 %dX%d(%s)"),(int)(pm.dSize[0]+0.5),(int)(pm.dSize[1]+0.5),pm.szSys);
|
||
|
||
CString sDimTxt;
|
||
sDimTxt += sPre;
|
||
sDimTxt += _T("-");
|
||
sDimTxt += sSize;
|
||
|
||
_tcscpy(pm.szRem, sDimTxt);
|
||
|
||
return true;
|
||
}
|
||
|
||
CQJBZDlg *pQJBZDlg = NULL;
|
||
CAutoWndDel autoDel3;
|
||
|
||
//桥架标2 -- AecDbEwPipeDim方式
|
||
void EL_QJBZCmdFnc2()
|
||
{
|
||
//扫线标注选择桥架
|
||
//弹出对话框,可以多行
|
||
ads_point pt1, pt2;
|
||
int nRes = acedGetPoint(NULL, _T("\n请拾取桥架标注起点:"), pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n请拾取桥架标注扫掠线末点:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false); pt11[Z] = 0.0;
|
||
acdbUcs2Wcs(pt2, pt22, false); pt22[Z] = 0.0;
|
||
AcDbLine ln(asPnt3d(pt11), asPnt3d(pt22));
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_DIM_ONLY, 0);
|
||
AcAxDocLock lock;
|
||
AcGePoint3d ptS, ptE;
|
||
ads_name ss, ent;
|
||
nRes = acedSSGet(_T("C"), pt1, pt2, pRb, ss);
|
||
if (nRes == RTNORM)
|
||
{
|
||
Adesk::Int32 nLen = 0;
|
||
acedSSLength(ss, &nLen);
|
||
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL;
|
||
AecHvac::DuctParam param;
|
||
AcDbLine ln1;
|
||
|
||
std::vector<AecHvac::DuctParam> arPams;
|
||
|
||
for (int i = 0;i < nLen;i++)
|
||
{
|
||
acedSSName(ss, i, ent);
|
||
acdbGetObjectId(id, ent);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pTray->GetDuctParam(param);
|
||
|
||
ptS = pTray->StartPoint();
|
||
ptE = pTray->EndPoint();
|
||
|
||
ln1.setStartPoint(ptS); ln1.setEndPoint(ptE);
|
||
|
||
AcGePoint3dArray pts;
|
||
ln1.intersectWith(&ln, AcDb::kExtendBoth, AcGePlane::kXYPlane,pts);
|
||
|
||
GetCableTrayDimTxt(param);
|
||
if (pts.length() == 1)//must
|
||
{
|
||
ln.getParamAtPoint(pts.first(), param.m_dR);
|
||
arPams.push_back(param);
|
||
}
|
||
}
|
||
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
AecDbObjXDataMap xData;
|
||
if (xData.Read(pEnt, BIMDATA_APP))
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
GetDuctParam(xData, param);
|
||
|
||
ptS = pLn->startPoint();
|
||
ptE = pLn->endPoint();
|
||
|
||
ln1.setStartPoint(ptS); ln1.setEndPoint(ptE);
|
||
|
||
AcGePoint3dArray pts;
|
||
ln1.intersectWith(&ln, AcDb::kExtendBoth, AcGePlane::kXYPlane, pts);
|
||
|
||
GetCableTrayDimTxt(param);
|
||
if (pts.length() == 1)//must
|
||
{
|
||
ln.getParamAtPoint(pts.first(), param.m_dR);
|
||
arPams.push_back(param);
|
||
}
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
//按照pt1--pt2 排序
|
||
std::sort(arPams.begin(),arPams.end(), SortDuctParamBydR);
|
||
acedSSFree(ss);
|
||
|
||
//弹出界面
|
||
if (pQJBZDlg == NULL)
|
||
{
|
||
pQJBZDlg = new CQJBZDlg;
|
||
autoDel3.m_pWnd = pQJBZDlg;
|
||
}
|
||
|
||
if (!IsWindow(pQJBZDlg->m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
pQJBZDlg->Create(CQJBZDlg::IDD);
|
||
}
|
||
|
||
pQJBZDlg->RemoveAllDimTxt();
|
||
for (int ii = 0;ii < arPams.size();ii++)
|
||
{
|
||
AecHvac::DuctParam &pm = arPams.at(ii);
|
||
pQJBZDlg->AppendDimTxt(pm.szRem);
|
||
}
|
||
|
||
CRect rcW;
|
||
pQJBZDlg->GetWindowRect(rcW);
|
||
int nH = rcW.Height();
|
||
int nW = rcW.Width();
|
||
|
||
CRect rc;
|
||
acedGetAcadDwgView()->GetWindowRect(rc);
|
||
|
||
rcW.left = rc.left;
|
||
rcW.right = rcW.left + nW;
|
||
rcW.top = rc.top;
|
||
rcW.bottom = rcW.top + nH;
|
||
pQJBZDlg->MoveWindow(rcW);
|
||
|
||
pQJBZDlg->ShowWindow(SW_SHOW);
|
||
|
||
ads_point pt3,pt33;
|
||
nRes = acedGetPoint(pt2, _T("\n请拾取桥架标注放置方向点:"), pt3);
|
||
if (nRes == RTNORM)
|
||
{
|
||
acdbUcs2Wcs(pt3, pt33, false);
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
|
||
pDim->SetDimStyle(4);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->SetPScale(getPScale());
|
||
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
|
||
CStringArray arDimTxt;
|
||
pQJBZDlg->GetDimTxts(arDimTxt);
|
||
for (int ii = 0; ii < arDimTxt.GetSize(); ii++)
|
||
{
|
||
pDim->AddDimText(arDimTxt.GetAt(ii), _T(""));
|
||
}
|
||
|
||
pDim->SetTextHeight(2.5);
|
||
pDim->SetTextWidthScale(0.75);
|
||
|
||
pDim->AppendPoint(asPnt3d(pt11));
|
||
pDim->AppendPoint(asPnt3d(pt22));
|
||
pDim->AppendPoint(asPnt3d(pt33));
|
||
|
||
pDim->SetDimupdownSpace(0.0);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
CoreTools::AddToModelSpace(pDim);
|
||
}
|
||
pQJBZDlg->ShowWindow(SW_HIDE);
|
||
}
|
||
acutRelRb(pRb);
|
||
}
|
||
}
|
||
}
|
||
|
||
void EL_QJBHCmdFnc()
|
||
{
|
||
//DXF_PIPE_FIT
|
||
//扫线标注选择桥架
|
||
//弹出对话框,可以多行
|
||
ads_point pt1, pt2;
|
||
int nRes = acedGetPoint(NULL, _T("\n请拾取桥架标注引出起点:"), pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n请拾取桥架标注引出末点:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false); pt11[Z] = 0.0;
|
||
acdbUcs2Wcs(pt2, pt22, false); pt22[Z] = 0.0;
|
||
AcDbLine ln(asPnt3d(pt11), asPnt3d(pt22));
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_FIT_DIM_ONLY, 0);
|
||
|
||
AcAxDocLock lock;
|
||
AcGePoint3d ptS, ptE;
|
||
ads_name ss, ent;
|
||
nRes = acedSSGet(_T("C"), pt1, pt2, pRb, ss);
|
||
if (nRes == RTNORM)
|
||
{
|
||
Adesk::Int32 nLen = 0;
|
||
acedSSLength(ss, &nLen);
|
||
|
||
if (nLen > 0)
|
||
{
|
||
acedSSName(ss, 0, ent);
|
||
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
TCHAR szHd[17];
|
||
id.handle().getIntoAsciiBuffer(szHd);
|
||
|
||
bool bGetParam = false;
|
||
AecHvac::DuctParam param;
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbECableTray *pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pTray->GetDuctParam(param);
|
||
bGetParam = true;
|
||
}
|
||
|
||
AecDbEcFitting *pEFit = AecDbEcFitting::cast(pEnt);
|
||
if (pEFit != NULL)
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
pEFit->GetDuctParam(param);
|
||
bGetParam = true;
|
||
}
|
||
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
if (pLn != NULL)
|
||
{
|
||
AecDbObjXDataMap xData;
|
||
if (xData.Read(pEnt, BIMDATA_APP))
|
||
{
|
||
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
||
GetDuctParam(xData, param);
|
||
bGetParam = true;
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
CString sDimTxt;
|
||
sDimTxt.Format(_T("%s_%s"),szHd,param.szNo);
|
||
|
||
//...
|
||
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false); pt11[Z] = 0.0;
|
||
acdbUcs2Wcs(pt2, pt22, false); pt22[Z] = 0.0;
|
||
|
||
//弹出界面
|
||
if (pQJBZDlg == NULL)
|
||
{
|
||
pQJBZDlg = new CQJBZDlg;
|
||
autoDel3.m_pWnd = pQJBZDlg;
|
||
}
|
||
|
||
if (!IsWindow(pQJBZDlg->m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
pQJBZDlg->Create(CQJBZDlg::IDD);
|
||
}
|
||
|
||
pQJBZDlg->RemoveAllDimTxt();
|
||
pQJBZDlg->AppendDimTxt(sDimTxt);
|
||
|
||
CRect rcW;
|
||
pQJBZDlg->GetWindowRect(rcW);
|
||
int nH = rcW.Height();
|
||
int nW = rcW.Width();
|
||
|
||
CRect rc;
|
||
acedGetAcadDwgView()->GetWindowRect(rc);
|
||
|
||
rcW.left = rc.left;
|
||
rcW.right = rcW.left + nW;
|
||
rcW.top = rc.top;
|
||
rcW.bottom = rcW.top + nH;
|
||
pQJBZDlg->MoveWindow(rcW);
|
||
|
||
pQJBZDlg->ShowWindow(SW_SHOW);
|
||
|
||
ads_point pt3, pt33;
|
||
nRes = acedGetPoint(pt2, _T("\n请拾取桥架标注放置方向点:"), pt3);
|
||
if (nRes == RTNORM)
|
||
{
|
||
acdbUcs2Wcs(pt3, pt33, false);
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim *pDim = new AecDbEwPipeDim;
|
||
|
||
pDim->SetDimStyle(0);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->SetPScale(getPScale());
|
||
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
|
||
CStringArray arDimTxt;
|
||
pQJBZDlg->GetDimTxts(arDimTxt);
|
||
for (int ii = 0; ii < arDimTxt.GetSize(); ii++)
|
||
{
|
||
pDim->AddDimText(arDimTxt.GetAt(ii), _T(""));
|
||
}
|
||
|
||
pDim->SetTextHeight(2.5);
|
||
pDim->SetTextWidthScale(0.75);
|
||
|
||
pDim->AppendPoint(asPnt3d(pt11));
|
||
pDim->AppendPoint(asPnt3d(pt22));
|
||
pDim->AppendPoint(asPnt3d(pt33));
|
||
|
||
pDim->SetDimupdownSpace(0.0);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
CoreTools::AddToModelSpace(pDim);
|
||
}
|
||
pQJBZDlg->ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
acedSSFree(ss);
|
||
}
|
||
acutRelRb(pRb);
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
typedef struct PSDLData
|
||
{
|
||
double m_dBomEl; // 底部标高
|
||
int m_nCount; // 敷设几条
|
||
int m_nClr; // 颜色
|
||
double m_dDn; // 曲率半径
|
||
double m_dSpace; // 线缆间距
|
||
double m_dD; // 外径
|
||
CString m_linetype; // 线型
|
||
CString m_sModel; // 型号
|
||
CString m_sFactory; // 厂家
|
||
}PSDLDATA;
|
||
*/
|
||
|
||
//电缆标注
|
||
void EL_DLBZCmdFnc()
|
||
{
|
||
ads_name ent1;
|
||
ads_point pt1, pt2;
|
||
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_ECABLE, 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择要标注的电缆:"), ent1, pRb, pt1);
|
||
acutRelRb(pRb);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n请选择位置:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false);
|
||
acdbUcs2Wcs(pt2, pt22, false);
|
||
|
||
AcGePoint3d ptFr = asPnt3d(pt11);
|
||
AcGePoint3d ptTo = asPnt3d(pt22);
|
||
|
||
AcDbObjectId id1;
|
||
acdbGetObjectId(id1, ent1);
|
||
|
||
PSDLData param;
|
||
BOOL bGetParam = FALSE;
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id1,AcDb::kForRead))
|
||
{
|
||
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
||
if (pCable != NULL)
|
||
{
|
||
pCable->GetSpecialtyData(AcDb::kForRead)->GetAt(CABLE_D, param.m_dD);
|
||
pCable->GetSpecialtyData(AcDb::kForRead)->GetAt(CABLE_MODEL, param.m_sModel);
|
||
pCable->GetSpecialtyData(AcDb::kForRead)->GetAt(CABLE_FACTORY, param.m_sFactory);
|
||
pCable->GetSpecialtyData(AcDb::kForRead)->GetAt(CABLE_RATIO, param.m_dDn);
|
||
|
||
bGetParam = TRUE;
|
||
}
|
||
pEnt->close();
|
||
}
|
||
|
||
if (bGetParam)
|
||
{
|
||
CString sDimUp,sTmp;
|
||
sDimUp.Format(_T("%s"),param.m_sModel);
|
||
sDimUp += _T("Ø");
|
||
sTmp.Format(_T("%d 曲率半径:%d"),(int)(param.m_dD+0.5),(int)(param.m_dDn+0.5));
|
||
sDimUp += sTmp;
|
||
|
||
AcDbObjectId idDimLay = KTSetting::InitLayer(gLayer_Pipe_Dim);
|
||
AcDbObjectId idTSty = CKTCadUtility::InitTextStyle(gTextStyle_Pipe_Dim);
|
||
|
||
AecDbEwPipeDim* pDim = new AecDbEwPipeDim;
|
||
pDim->AddAecDbWEntity(id1);
|
||
|
||
pDim->SetDimStyle(0);
|
||
pDim->SetDimDir(0);
|
||
pDim->SetDimTextUporDownFlag(1);
|
||
|
||
pDim->SetTextStyleId(idTSty);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
pDim->SetPScale(100.0);
|
||
|
||
pDim->SetDimTextUporDownFlag(0);
|
||
|
||
pDim->AddDimText(sDimUp,_T(""));
|
||
|
||
pDim->SetTextHeight(2.5);
|
||
pDim->SetTextWidthScale(0.75);
|
||
|
||
pDim->AppendPoint(ptFr);
|
||
pDim->AppendPoint(ptTo);
|
||
|
||
pDim->SetDimupdownSpace(0.0);
|
||
pDim->SetTextLayerId(idDimLay);
|
||
|
||
CoreTools::AddToModelSpace(pDim);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//合并桥架
|
||
void EL_HBQJCmdFnc()
|
||
{
|
||
ads_name ss,ent1,ent2;
|
||
struct resbuf* pRb = acutBuildList(RTDXF0, DXF_PIPE, 0);
|
||
|
||
int nRes = CKTCadUtility::SelectEntities(_T("\n请框选两个平行共线同属性的桥架:"), ss,pRb);
|
||
acutRelRb(pRb);
|
||
|
||
if ( RTNORM == nRes)
|
||
{
|
||
Adesk::Int32 nLen = 0;
|
||
acedSSLength(ss,&nLen);
|
||
|
||
if (nLen == 2)
|
||
{
|
||
AcDbObjectId id1,id2;
|
||
|
||
acedSSName(ss,0,ent1);
|
||
acdbGetObjectId(id1,ent1);
|
||
|
||
acedSSName(ss,1,ent2);
|
||
acdbGetObjectId(id2,ent2);
|
||
|
||
AcDbEntity* pEnt1 = NULL;
|
||
AcDbEntity* pEnt2 = NULL;
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt1,id1,AcDb::kForWrite))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2,id2,AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray* pDuct1 = AecDbECableTray::cast(pEnt1);
|
||
AecDbECableTray* pDuct2 = AecDbECableTray::cast(pEnt2);
|
||
|
||
if (pDuct1 != NULL && pDuct2 != NULL)
|
||
{
|
||
AcGeVector3d vt1 = pDuct1->GetTailDir();
|
||
AcGeVector3d vt2 = pDuct2->GetTailDir();
|
||
|
||
AecHvac::DuctParam data1,data2;
|
||
memset(&data1,0,sizeof(AecHvac::DuctParam));
|
||
memset(&data2,0,sizeof(AecHvac::DuctParam));
|
||
|
||
pDuct1->GetDuctParam(data1);
|
||
pDuct2->GetDuctParam(data2);
|
||
|
||
if ( vt1.isParallelTo(vt2) && //平行
|
||
fabs(data1.m_dEl - data2.m_dEl) < 1.e-3 && //标高
|
||
fabs(data1.dSize[0] - data2.dSize[0]) < 1.e-3 && //尺寸
|
||
fabs(data1.dSize[1] - data2.dSize[1]) < 1.e-3 )
|
||
{
|
||
AcGePoint3d ptS1 = pDuct1->StartPoint();
|
||
AcGePoint3d ptE1 = pDuct1->EndPoint();
|
||
|
||
AcGePoint3d ptS2 = pDuct2->StartPoint();
|
||
AcGePoint3d ptE2 = pDuct2->EndPoint();
|
||
|
||
AcGePoint3dArray arPts;
|
||
arPts.append(ptS1);
|
||
arPts.append(ptE1);
|
||
|
||
if (arPts.find(ptS2) == -1)
|
||
arPts.append(ptS2);
|
||
|
||
if (arPts.find(ptE2) == -1)
|
||
arPts.append(ptE2);
|
||
|
||
AcDbLine ln(ptS1,ptE1);
|
||
SortPoints(arPts,&ln);
|
||
|
||
pDuct1->SetStartPoint(arPts.first());
|
||
pDuct1->SetEndPoint(arPts.last());
|
||
|
||
pDuct2->erase();
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n选择的两个桥架实体几何属性不一致!"));
|
||
}
|
||
}
|
||
pEnt2->close();
|
||
}
|
||
pEnt1->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
acutPrintf(_T("\n必须选择两个桥架实体!"));
|
||
}
|
||
}
|
||
acedSSFree(ss);
|
||
}
|
||
|
||
//路径曲线
|
||
void EL_LJQXCmdFnc()
|
||
{
|
||
//弹出用途界面
|
||
CAcModuleResourceOverride myResources;
|
||
CLJQXDlg dlg;
|
||
if (IDOK != dlg.DoModal())
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbObjectId idLay;
|
||
switch (dlg.m_nForUse)
|
||
{
|
||
case 0://pipe
|
||
{
|
||
idLay = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
break;
|
||
}
|
||
case 1://桥架
|
||
{
|
||
idLay = KTSetting::InitLayer(LAY_CABTRY_OUT);
|
||
break;
|
||
}
|
||
case 2://缆沟
|
||
{
|
||
idLay = KTSetting::InitLayer(LAY_TRENCH_OUT);
|
||
break;
|
||
}
|
||
case 3://线管
|
||
{
|
||
idLay = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
break;
|
||
}
|
||
case 4://预埋
|
||
{
|
||
idLay = KTSetting::InitLayer(LAY_CABTRY_SIG);
|
||
break;
|
||
}
|
||
default:
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
AcPolylineJig jig;
|
||
jig.InitStatusRecsForLineSegs();
|
||
if (jig.DoIt())
|
||
{
|
||
AcDbObjectId id = jig.GetRoadAxisLineId();
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
//设置桥架图层
|
||
pEnt->setLayer(idLay);
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
typedef struct Clos2Point
|
||
{
|
||
AcGePoint3d pt1;
|
||
AcGePoint3d pt2;
|
||
}CLOS2POINT;
|
||
|
||
bool CompareC2P(Clos2Point& cpt1, Clos2Point& cpt2)
|
||
{
|
||
double d1 = cpt1.pt1.distanceTo(cpt1.pt2);
|
||
double d2 = cpt2.pt1.distanceTo(cpt2.pt2);
|
||
if (d1 < d2)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
static void GetClosestPointToEcFit(AcGePoint3d& pt, const AcGePoint3d& ptMid, AcArray<AecInterface>& arInfs, AcGePoint3d& ptOn)
|
||
{
|
||
//计算距离那条中心线最近
|
||
AcGePoint3d ptTmp;
|
||
AcDbLine ln;
|
||
|
||
Clos2Point c2p;
|
||
std::vector<Clos2Point> c2ps;
|
||
|
||
for (int i = 0;i < arInfs.length();i++)
|
||
{
|
||
AecInterface &inf = arInfs.at(i);
|
||
|
||
ln.setStartPoint(ptMid);
|
||
ln.setEndPoint(inf.ptPos);
|
||
|
||
ln.getClosestPointTo(pt, ptTmp, Adesk::kFalse);
|
||
c2p.pt1 = pt;
|
||
c2p.pt2 = ptTmp;
|
||
c2ps.push_back(c2p);
|
||
}
|
||
|
||
std::sort(c2ps.begin(), c2ps.end(), CompareC2P);
|
||
|
||
ptOn = (*c2ps.begin()).pt2;
|
||
}
|
||
|
||
//设备接点
|
||
void EL_ZLJBCmdFnc()
|
||
{
|
||
//选择设备
|
||
ads_name ent;
|
||
ads_point pt, pt2;
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, _T("INSERT,AEC_DBWEQUIPMENT,AEC_DBCABTRY,AEC_DBECFIT"), 0);
|
||
int nRes = CKTCadUtility::SelectEntity(_T("\n请选择设备或桥架添加接线点:"), ent, pRb, pt);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcGePoint3d ptOn, ptMid;
|
||
bool bIsEqu = false;
|
||
CString sEqu1,sEqu2,sEqu;
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDbEwEquipment *pEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pEqu != NULL)
|
||
{
|
||
acdbUcs2Wcs(pt, pt2, false);
|
||
ptOn = asPnt3d(pt2);
|
||
pEqu->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NO, sEqu1);
|
||
pEqu->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NAME,sEqu2);
|
||
bIsEqu = true;
|
||
}
|
||
|
||
AecDbECableTray *pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
pTray->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NO, sEqu1);
|
||
pTray->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NAME, sEqu2);
|
||
|
||
acdbUcs2Wcs(pt, pt2, false);
|
||
pTray->getClosestPointTo(asPnt3d(pt2), ptOn, false);
|
||
}
|
||
|
||
AecDbEcFitting *pEcFit = AecDbEcFitting::cast(pEnt);
|
||
if (pEcFit != NULL)
|
||
{
|
||
pEcFit->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NO, sEqu1);
|
||
pEcFit->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NAME, sEqu2);
|
||
pEcFit->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_MID, ptMid);
|
||
acdbUcs2Wcs(pt, pt2, false);
|
||
AcArray<AecInterface> arInfs;
|
||
pEcFit->GetInterface(arInfs);
|
||
|
||
GetClosestPointToEcFit(asPnt3d(pt2), ptMid,arInfs, ptOn);
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
|
||
sEqu.Format(_T("%s_%s"),sEqu1,sEqu2);
|
||
CAcModuleResourceOverride myResources;
|
||
CXYCDDlg dlg;
|
||
dlg.m_dEl = ptOn.z;
|
||
dlg.m_sEqu = sEqu;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
ads_point pt1;
|
||
acdbUcs2Wcs(dlg.m_pt, pt1, false);
|
||
pt1[Z] = dlg.m_dEl;
|
||
|
||
TCHAR szHd[17];
|
||
id.handle().getIntoAsciiBuffer(szHd);
|
||
|
||
//创建一个
|
||
AcDbObjectId idLay = KTSetting::InitLayer(LAY_CABTRY_OUT);
|
||
AecDbDirPosition *pDirPt = new AecDbDirPosition;
|
||
pDirPt->SetPosition(asPnt3d(pt1));
|
||
pDirPt->SetSys(dlg.m_sSys);
|
||
pDirPt->SetOnEqu(dlg.m_sEqu);
|
||
pDirPt->SetIsEqu(bIsEqu);
|
||
pDirPt->SetAssocEnt(szHd);
|
||
|
||
pDirPt->setLayer(idLay);
|
||
AcDbObjectId idPt = CoreTools::AddToModelSpace(pDirPt);
|
||
}
|
||
}
|
||
}
|
||
|
||
void DBL_AEC_DIRPS()
|
||
{
|
||
AcDbObjectId id;
|
||
bool bIsOk = GetDoubleClickEnt(_T("DBL_AEC_DIRPS"), id);
|
||
|
||
if (bIsOk && id.isValid())
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbDirPosition *pDirPt = AecDbDirPosition::cast(pEnt);
|
||
if (pDirPt != NULL)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CXYCDDlg dlg;
|
||
AcGePoint3d ptOn;
|
||
|
||
ptOn = pDirPt->GetPosition();
|
||
dlg.m_dEl = ptOn.z;
|
||
dlg.m_sPt.Format(_T("%.3f,%.3f,%.3f"),ptOn.x,ptOn.y,ptOn.z);
|
||
pDirPt->GetSys(dlg.m_sSys);
|
||
pDirPt->GetOnEqu(dlg.m_sEqu);
|
||
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
pDirPt->SetPosition(ptOn);
|
||
pDirPt->SetSys(dlg.m_sSys);
|
||
pDirPt->SetOnEqu(dlg.m_sEqu);
|
||
}
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
//设备统编
|
||
CSBTBDlg g_wndSBTBDlg;
|
||
void EL_SBTBCmdFnc()
|
||
{
|
||
if (!IsWindow(g_wndSBTBDlg.m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
g_wndSBTBDlg.Create(CSBTBDlg::IDD);
|
||
g_wndSBTBDlg.CenterWindow();
|
||
g_wndSBTBDlg.ShowWindow(SW_SHOW);
|
||
}
|
||
else
|
||
{
|
||
g_wndSBTBDlg.ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
|
||
//必经路径
|
||
void EL_BJLJCmdFnc()
|
||
{
|
||
//移到清册起始设备选择上
|
||
//移到手动敷设起始设备选择上
|
||
//....
|
||
}
|
||
|
||
//清册敷设
|
||
CDLFSDlg g_wndDLFSDlg;
|
||
void EL_DLFSCmdFnc()
|
||
{
|
||
if (!IsWindow(g_wndDLFSDlg.m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
g_wndDLFSDlg.Create(CDLFSDlg::IDD);
|
||
g_wndDLFSDlg.CenterWindow();
|
||
g_wndDLFSDlg.ShowWindow(SW_SHOW);
|
||
}
|
||
else
|
||
{
|
||
g_wndDLFSDlg.ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
|
||
//手动敷设
|
||
CSDFSDlg *g_pSDlg = NULL;
|
||
CAutoWndDel autoDel0;
|
||
void EL_SDFSCmdFnc()
|
||
{
|
||
//弹出界面
|
||
if (g_pSDlg == NULL)
|
||
{
|
||
g_pSDlg = new CSDFSDlg;
|
||
autoDel0.m_pWnd = g_pSDlg;
|
||
}
|
||
|
||
if ( !IsWindow(g_pSDlg->m_hWnd) )
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
g_pSDlg->Create(CSDFSDlg::IDD);
|
||
}
|
||
g_pSDlg->ShowWindow(SW_SHOW);
|
||
g_pSDlg->CenterWindow();
|
||
}
|
||
|
||
void EL_XTCLCmdFnc()
|
||
{
|
||
int nShow = 0;
|
||
int nRes = acedGetInt(_T("\n请输入选项[显示填充率(1)/关闭填充率(0)]<0>:"), &nShow);
|
||
|
||
struct resbuf rb,rb2;
|
||
rb.resval.rint = 0;
|
||
acedGetVar(_T("USERI3"), &rb);
|
||
acedGetVar(_T("USERI3"), &rb2);
|
||
|
||
if (nShow > 0)
|
||
{
|
||
rb2.resval.rint = 1395;
|
||
acedSetVar(_T("USERI3"), &rb2);
|
||
}
|
||
else
|
||
{
|
||
rb2.resval.rint = 0;
|
||
acedSetVar(_T("USERI3"), &rb2);
|
||
}
|
||
acedPostCommand(_T("regen "));
|
||
}
|
||
|
||
void EL_LTCLCmdFnc()
|
||
{
|
||
ads_name ss, ent;
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_PIPE_FIT, 0);
|
||
int nRes = acedSSGet(_T("A"), NULL, NULL, pRb, ss);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL;
|
||
|
||
Adesk::Int32 nLen = 0;
|
||
acedSSLength(ss, &nLen);
|
||
|
||
for (int i = 0;i < nLen;i++)
|
||
{
|
||
acedSSName(ss, i, ent);
|
||
acdbGetObjectId(id, ent);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbECableTray *pTray = AecDbECableTray::cast(pEnt);
|
||
if (pTray != NULL)
|
||
{
|
||
pTray->GetSpecialtyData(AcDb::kForWrite)->SetAt(KEY_FILLUSED, 0.0);
|
||
pTray->GetSpecialtyData(AcDb::kForWrite)->SetAt(KEY_FILLUSED2, 0.0);
|
||
}
|
||
|
||
AecDbEcFitting *pEcFit = AecDbEcFitting::cast(pEnt);
|
||
if (pEcFit != NULL)
|
||
{
|
||
pEcFit->GetSpecialtyData(AcDb::kForWrite)->SetAt(KEY_FILLUSED, 0.0);
|
||
pEcFit->GetSpecialtyData(AcDb::kForWrite)->SetAt(KEY_FILLUSED2, 0.0);
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
acedSSFree(ss);
|
||
}
|
||
}
|
||
|
||
#define DXF_CABPATH _T("AEC_ROADAXISLINE")
|
||
|
||
//敷设汇总--报表
|
||
void EL_FSHZCmdFnc()
|
||
{
|
||
//汇总列,模板
|
||
CString sSysPath = FilePath::GetSysDir();
|
||
CString sIniFile, sXlsFile;
|
||
sIniFile.Format(_T("%s\\%s"), sSysPath, _T("电缆汇总.ini"));
|
||
|
||
CFileFind find;
|
||
if (find.FindFile(sIniFile))
|
||
{
|
||
/*
|
||
* A = 序号
|
||
B = 电缆及规格
|
||
C = 截面
|
||
D = 全长
|
||
E = 电缆外径
|
||
F = 电缆系统
|
||
G = 备注
|
||
*/
|
||
CString sTip;
|
||
TCHAR szVal[MAX_PATH];
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
|
||
if (0 == ::GetPrivateProfileString(_T("File"), _T("Templ"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
sXlsFile.Format(_T("%s\\%s"), sSysPath, szVal);
|
||
if (!find.FindFile(sXlsFile))
|
||
{
|
||
sTip.Format(_T("汇总模板文件[%s]不存在!"), sXlsFile);
|
||
AfxMessageBox(sTip);
|
||
return;
|
||
}
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Row"), _T("RowFrom"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
int nRowFrom = _ttoi(szVal);
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Row"), _T("Cells"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
//继续读 cells
|
||
CStringArray arCells;
|
||
CoreTools::SplitStrintToArray(szVal, arCells, _T(','));
|
||
|
||
//写入的位置
|
||
CString sCell, sName, sTitle;
|
||
CMapStringToString mapCellToName;
|
||
for (int i = 0; i < arCells.GetSize(); i++)
|
||
{
|
||
sCell = arCells.GetAt(i);
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Cell"), sCell, _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
mapCellToName.SetAt(sCell, szVal);
|
||
}
|
||
|
||
int nUnit = 1000;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnit = 1;
|
||
}
|
||
|
||
std::vector < CableSum > vtCableSumms;
|
||
CableSum cabData;
|
||
memset(&cabData, 0, sizeof(CableSum));
|
||
|
||
//选择所有电缆
|
||
ads_name ss, ent;
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL;
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_CABPATH, 0);
|
||
int nRet = acedSSGet(_T("A"), NULL, NULL, pRb,ss);
|
||
acutRelRb(pRb);
|
||
|
||
Adesk::Int32 nLen = 0;
|
||
if (nRet == RTNORM)
|
||
{
|
||
acedSSLength(ss, &nLen);
|
||
|
||
for (int i = 0;i < nLen;i++)
|
||
{
|
||
acedSSName(ss, i, ent);
|
||
acdbGetObjectId(id, ent);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDb3dRoadAxisLine *pRd = AecDb3dRoadAxisLine::cast(pEnt);
|
||
AecDbObjXDataMap xData;
|
||
if (xData.Read(pEnt, KEY_APP))
|
||
{
|
||
xData.GetAt(KEY_SPEC, cabData.szSpec);
|
||
xData.GetAt(KEY_SYS, cabData.szSys);
|
||
xData.GetAt(KEY_SECNAME, cabData.szSect);
|
||
xData.GetAt(PIPE_OD, cabData.dOD);
|
||
cabData.dLen = pRd->getLength();
|
||
cabData.dLen /= nUnit;
|
||
vtCableSumms.push_back(cabData);
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
acedSSFree(ss);
|
||
}
|
||
|
||
if (nLen == 0)
|
||
{
|
||
acutPrintf(_T("\n图中没有电缆实体!不需要汇总!"));
|
||
return;
|
||
}
|
||
|
||
|
||
CString sSpec, sSect, sSys, sOD, sLen, sKey;
|
||
CableSum *pData = NULL;
|
||
CMapStringToPtr mapSumm2Data;
|
||
std::vector<CableSum *> vtCableSumPtrs;
|
||
|
||
acedSetStatusBarProgressMeter(_T("正在汇总..."), 0, vtCableSumms.size());
|
||
for (int i = 0;i < vtCableSumms.size();i++)
|
||
{
|
||
acedSetStatusBarProgressMeterPos(i);
|
||
CableSum &data = vtCableSumms.at(i);
|
||
|
||
sKey.Format(_T("%s-%s"), data.szSpec, data.szSect);
|
||
if (mapSumm2Data.Lookup(sKey, (void *&)pData))
|
||
{
|
||
//汇总
|
||
pData->dLen += data.dLen;
|
||
}
|
||
else
|
||
{
|
||
pData = new CableSum;
|
||
memcpy(pData, &data, sizeof(CableSum));
|
||
|
||
mapSumm2Data.SetAt(sKey, pData);
|
||
vtCableSumPtrs.push_back(pData);
|
||
}
|
||
}
|
||
acedRestoreStatusBar();
|
||
|
||
//std::sort(vtCableSumPtrs.begin(), vtCableSumPtrs.end(), CableSumCmpFnc);
|
||
//...
|
||
|
||
CWaitCursor wait;
|
||
|
||
::CoInitialize(NULL);
|
||
|
||
_Application excelApp;
|
||
Workbooks excelBooks;
|
||
_Workbook excelBook;
|
||
Worksheets excelSheets;
|
||
_Worksheet excelSheet;
|
||
|
||
COleVariant vResult;
|
||
COleVariant covTrue((short)TRUE), covFalse((short)FALSE);
|
||
|
||
Range range;
|
||
Range iCell;
|
||
Validation vald;
|
||
|
||
BOOL bSuccess = excelApp.CreateDispatch(_T("excel.application"));
|
||
if (bSuccess)
|
||
{
|
||
LPDISPATCH pLpDisp = NULL;
|
||
|
||
excelBooks.AttachDispatch(excelApp.GetWorkbooks());
|
||
|
||
COleVariant vOp((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||
|
||
COleVariant vResult;
|
||
COleVariant covTrue((short)TRUE), covFalse((short)FALSE);
|
||
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||
|
||
pLpDisp = excelBooks.Open(sXlsFile, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, covOptional, covOptional,
|
||
covOptional);
|
||
|
||
if (pLpDisp == NULL)
|
||
{
|
||
AfxMessageBox(_T("启动excel 服务失败!请确认系统是否安装Excel!"));
|
||
return;
|
||
}
|
||
|
||
excelBook.AttachDispatch(pLpDisp);
|
||
|
||
//得到Worksheets
|
||
excelSheets.AttachDispatch(excelBook.GetWorksheets());
|
||
|
||
//获取sheet 数量
|
||
bool bModified = false;
|
||
short nSheetIndex = 1;
|
||
|
||
COleVariant varIndex(nSheetIndex);
|
||
pLpDisp = excelSheets.GetItem(varIndex);
|
||
if (pLpDisp != NULL)
|
||
{
|
||
excelSheet.AttachDispatch(pLpDisp);
|
||
|
||
CUIntArray arAZPos;
|
||
CString sCell, sVal, sKey, sItem;
|
||
|
||
int nRow = nRowFrom;
|
||
|
||
//
|
||
for (int i = 0; i < vtCableSumPtrs.size(); i++)
|
||
{
|
||
pData = vtCableSumPtrs.at(i);
|
||
|
||
for (POSITION ps = mapCellToName.GetStartPosition(); ps != NULL;)
|
||
{
|
||
mapCellToName.GetNextAssoc(ps, sKey, sName);
|
||
|
||
/*
|
||
* A = 序号
|
||
B = 电缆及规格
|
||
C = 截面
|
||
D = 全长
|
||
E = 电缆外径
|
||
F = 电缆系统
|
||
G = 备注
|
||
*/
|
||
|
||
//CableSum 的 文本 涵盖 sName
|
||
|
||
//电缆及规格
|
||
if (sName.Find(_T("电缆及规格")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(pData->szSpec);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//截面
|
||
if (sName.Find(_T("截面")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(pData->szSect);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//电缆系统
|
||
if (sName.Find(_T("电缆系统")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(pData->szSys);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//电缆外径
|
||
if (sName.Find(_T("电缆外径")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(pData->dOD);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//全长
|
||
if (sName.Find(_T("全长")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(pData->dLen);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//序号
|
||
if (sName.Find(_T("序号")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal((long)(nRow - nRowFrom + 1));
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//...
|
||
}
|
||
|
||
nRow += 1;
|
||
}
|
||
bModified = TRUE;
|
||
}
|
||
|
||
CString sSaveAsFileName = sXlsFile;
|
||
if (bModified)
|
||
{
|
||
//另外保存新文件
|
||
|
||
//年月 日 分 秒 文件记录
|
||
CString sAdd;
|
||
CTime tNow = CTime::GetCurrentTime();
|
||
sAdd = tNow.Format("_%Y-%m-%d_%H.%M.%S");
|
||
sAdd += _T(".xls");
|
||
|
||
sSaveAsFileName.MakeLower();
|
||
|
||
if (sSaveAsFileName.Find(_T(".xlsx")) != -1)
|
||
sSaveAsFileName.Replace(_T(".xlsx"), sAdd);
|
||
else
|
||
sSaveAsFileName.Replace(_T(".xls"), sAdd);
|
||
|
||
COleVariant varNewEFile(sSaveAsFileName);
|
||
excelBook.SaveAs(varNewEFile, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, 0, covOptional, covOptional,
|
||
covOptional, covOptional);
|
||
}
|
||
|
||
excelBooks.Close();
|
||
excelApp.Quit();
|
||
|
||
//open
|
||
if (bModified)
|
||
{
|
||
ShellExecute(AfxGetMainWnd()->m_hWnd, _T("open"), sSaveAsFileName, _T(""), _T(""), SW_SHOWNORMAL);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
static bool CableSummSort(CableSum& cls1, CableSum& cls2)
|
||
{
|
||
if (cls1.dOD <= cls2.dOD)
|
||
return true;
|
||
return false;
|
||
}
|
||
|
||
static void GetEquNameFromHd(TCHAR* szHd)
|
||
{
|
||
AcDbHandle hd(szHd);
|
||
|
||
AcDbObjectId id;
|
||
if (Acad::eOk == acdbCurDwg()->getAcDbObjectId(id, false, hd))
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
// AEC_DBWEQUIPMENT
|
||
AecDbEwEquipment *pEqu = AecDbEwEquipment::cast(pEnt);
|
||
if (pEqu != NULL)
|
||
{
|
||
CString sNo = _T(""), sName = _T(""), sTmp;
|
||
pEqu->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NO,sNo);
|
||
pEqu->GetSpecialtyData(AcDb::kForRead)->GetAt(KEY_NAME, sName);
|
||
|
||
sTmp = sName + sNo;
|
||
_tcscpy(szHd, (LPCTSTR)sTmp);
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
void EL_TQQCCmdFnc()
|
||
{
|
||
//汇总列,模板
|
||
CString sSysPath = FilePath::GetSysDir();
|
||
CString sIniFile, sXlsFile;
|
||
sIniFile.Format(_T("%s\\%s"), sSysPath, _T("电缆敷设清单.ini"));
|
||
|
||
CFileFind find;
|
||
if (find.FindFile(sIniFile))
|
||
{
|
||
/*
|
||
A = 序号
|
||
B = 起点设备
|
||
C = 终点设备
|
||
D = 电缆及规格
|
||
E = 截面
|
||
F = 全长
|
||
G = 电缆外径
|
||
H = 电缆系统
|
||
I = 备注
|
||
*/
|
||
CString sTip;
|
||
TCHAR szVal[MAX_PATH];
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
|
||
if (0 == ::GetPrivateProfileString(_T("File"), _T("Templ"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
sXlsFile.Format(_T("%s\\%s"), sSysPath, szVal);
|
||
if (!find.FindFile(sXlsFile))
|
||
{
|
||
sTip.Format(_T("电缆敷设清单[%s]不存在!"), sXlsFile);
|
||
AfxMessageBox(sTip);
|
||
return;
|
||
}
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Row"), _T("RowFrom"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
int nRowFrom = _ttoi(szVal);
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Row"), _T("Cells"), _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
//继续读 cells
|
||
CStringArray arCells;
|
||
CoreTools::SplitStrintToArray(szVal, arCells, _T(','));
|
||
|
||
//写入的位置
|
||
CString sCell, sName, sTitle;
|
||
CMapStringToString mapCellToName;
|
||
for (int i = 0; i < arCells.GetSize(); i++)
|
||
{
|
||
sCell = arCells.GetAt(i);
|
||
|
||
memset(szVal, 0, sizeof(TCHAR) * MAX_PATH);
|
||
if (0 == ::GetPrivateProfileString(_T("Cell"), sCell, _T(""), szVal, MAX_PATH, sIniFile))
|
||
return;
|
||
|
||
mapCellToName.SetAt(sCell, szVal);
|
||
}
|
||
|
||
int nUnit = 1000;//默认毫米
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
nUnit = 1;
|
||
}
|
||
|
||
std::vector < CableSum > vtCableSumms;
|
||
CableSum cabData;
|
||
memset(&cabData, 0, sizeof(CableSum));
|
||
|
||
//选择所有电缆
|
||
ads_name ss, ent;
|
||
AcDbObjectId id;
|
||
AcDbEntity *pEnt = NULL;
|
||
|
||
struct resbuf *pRb = acutBuildList(RTDXF0, DXF_CABPATH, 0);
|
||
int nRet = acedSSGet(_T("A"), NULL, NULL, pRb, ss);
|
||
acutRelRb(pRb);
|
||
//acrxClassDictionary
|
||
Adesk::Int32 nLen = 0;
|
||
if (nRet == RTNORM)
|
||
{
|
||
acedSSLength(ss, &nLen);
|
||
|
||
for (int i = 0; i < nLen; i++)
|
||
{
|
||
acedSSName(ss, i, ent);
|
||
acdbGetObjectId(id, ent);
|
||
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
|
||
{
|
||
AecDb3dRoadAxisLine *pRd = AecDb3dRoadAxisLine::cast(pEnt);
|
||
AecDbObjXDataMap xData;
|
||
if (xData.Read(pEnt, KEY_APP))
|
||
{
|
||
memset(&cabData, 0, sizeof(CableSum));
|
||
|
||
xData.GetAt(KEY_START, cabData.szFr);
|
||
xData.GetAt(KEY_END, cabData.szTo);
|
||
|
||
GetEquNameFromHd(cabData.szFr);
|
||
GetEquNameFromHd(cabData.szTo);
|
||
|
||
xData.GetAt(KEY_SPEC, cabData.szSpec);
|
||
xData.GetAt(KEY_SYS, cabData.szSys);
|
||
xData.GetAt(KEY_SECNAME, cabData.szSect);
|
||
xData.GetAt(PIPE_OD, cabData.dOD);
|
||
cabData.dLen = pRd->getLength();
|
||
cabData.dLen /= nUnit;
|
||
vtCableSumms.push_back(cabData);
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
acedSSFree(ss);
|
||
}
|
||
|
||
if (nLen == 0)
|
||
{
|
||
acutPrintf(_T("\n图中没有电缆实体!不需要汇总!"));
|
||
return;
|
||
}
|
||
|
||
//按照外径排序
|
||
std::sort(vtCableSumms.begin(), vtCableSumms.end(), CableSummSort);
|
||
|
||
CWaitCursor wait;
|
||
|
||
::CoInitialize(NULL);
|
||
|
||
_Application excelApp;
|
||
Workbooks excelBooks;
|
||
_Workbook excelBook;
|
||
Worksheets excelSheets;
|
||
_Worksheet excelSheet;
|
||
|
||
COleVariant vResult;
|
||
COleVariant covTrue((short)TRUE), covFalse((short)FALSE);
|
||
|
||
Range range;
|
||
Range iCell;
|
||
Validation vald;
|
||
|
||
BOOL bSuccess = excelApp.CreateDispatch(_T("excel.application"));
|
||
if (bSuccess)
|
||
{
|
||
LPDISPATCH pLpDisp = NULL;
|
||
|
||
excelBooks.AttachDispatch(excelApp.GetWorkbooks());
|
||
|
||
COleVariant vOp((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||
|
||
COleVariant vResult;
|
||
COleVariant covTrue((short)TRUE), covFalse((short)FALSE);
|
||
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||
|
||
pLpDisp = excelBooks.Open(sXlsFile, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, covOptional, covOptional,
|
||
covOptional);
|
||
|
||
if (pLpDisp == NULL)
|
||
{
|
||
AfxMessageBox(_T("启动excel 服务失败!请确认系统是否安装Excel!"));
|
||
return;
|
||
}
|
||
|
||
excelBook.AttachDispatch(pLpDisp);
|
||
|
||
//得到Worksheets
|
||
excelSheets.AttachDispatch(excelBook.GetWorksheets());
|
||
|
||
//获取sheet 数量
|
||
bool bModified = false;
|
||
short nSheetIndex = 1;
|
||
|
||
COleVariant varIndex(nSheetIndex);
|
||
pLpDisp = excelSheets.GetItem(varIndex);
|
||
if (pLpDisp != NULL)
|
||
{
|
||
excelSheet.AttachDispatch(pLpDisp);
|
||
|
||
CUIntArray arAZPos;
|
||
CString sCell, sVal, sKey, sItem;
|
||
|
||
int nRow = nRowFrom;
|
||
|
||
//
|
||
for (int i = 0; i < vtCableSumms.size(); i++)
|
||
{
|
||
CableSum& data = vtCableSumms.at(i);
|
||
|
||
for (POSITION ps = mapCellToName.GetStartPosition(); ps != NULL;)
|
||
{
|
||
mapCellToName.GetNextAssoc(ps, sKey, sName);
|
||
|
||
/*
|
||
A = 序号
|
||
B = 起点设备
|
||
C = 终点设备
|
||
D = 电缆及规格
|
||
E = 截面
|
||
F = 全长
|
||
G = 电缆外径
|
||
H = 电缆系统
|
||
I = 备注
|
||
*/
|
||
|
||
//CableSum 的 文本 涵盖 sName
|
||
|
||
if (sName.Find(_T("起点设备")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.szFr);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
if (sName.Find(_T("终点设备")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.szTo);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//电缆及规格
|
||
if (sName.Find(_T("电缆及规格")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.szSpec);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//截面
|
||
if (sName.Find(_T("截面")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.szSect);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//电缆系统
|
||
if (sName.Find(_T("电缆系统")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.szSys);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//电缆外径
|
||
if (sName.Find(_T("电缆外径")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.dOD);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//全长
|
||
if (sName.Find(_T("全长")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal(data.dLen);
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//序号
|
||
if (sName.Find(_T("序号")) != -1)
|
||
{
|
||
//A1 B1 C1
|
||
sCell.Format(_T("%s%d"), sKey, nRow);
|
||
|
||
COleVariant varCell(sCell);
|
||
range = excelSheet.GetRange(varCell, varCell);
|
||
|
||
COleVariant varVal((long)(nRow - nRowFrom + 1));
|
||
range.SetValue(varVal);
|
||
continue;
|
||
}
|
||
|
||
//...
|
||
}
|
||
|
||
nRow += 1;
|
||
}
|
||
bModified = TRUE;
|
||
}
|
||
|
||
CString sSaveAsFileName = sXlsFile;
|
||
if (bModified)
|
||
{
|
||
//年月 日 分 秒 文件记录
|
||
CString sAdd;
|
||
CTime tNow = CTime::GetCurrentTime();
|
||
sAdd = tNow.Format("_%Y-%m-%d_%H.%M.%S");
|
||
sAdd += _T(".xls");
|
||
|
||
sSaveAsFileName.MakeLower();
|
||
|
||
if (sSaveAsFileName.Find(_T(".xlsx")) != -1)
|
||
sSaveAsFileName.Replace(_T(".xlsx"), sAdd);
|
||
else
|
||
sSaveAsFileName.Replace(_T(".xls"), sAdd);
|
||
|
||
COleVariant varNewEFile(sSaveAsFileName);
|
||
excelBook.SaveAs(varNewEFile, covOptional, covOptional, covOptional,
|
||
covOptional, covOptional, 0, covOptional, covOptional,
|
||
covOptional, covOptional);
|
||
}
|
||
|
||
excelBooks.Close();
|
||
excelApp.Quit();
|
||
|
||
//open
|
||
if (bModified)
|
||
{
|
||
ShellExecute(AfxGetMainWnd()->m_hWnd, _T("open"), sSaveAsFileName, _T(""), _T(""), SW_SHOWNORMAL);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
CDLCKDLG *g_pDlckDlg = NULL;
|
||
CAutoWndDel autoDel1;
|
||
void EL_DLCKCmdFnc()
|
||
{
|
||
//弹出截面,显示电缆,非模式
|
||
if (g_pDlckDlg == NULL)
|
||
{
|
||
g_pDlckDlg = new CDLCKDLG;
|
||
autoDel1.m_pWnd = g_pDlckDlg;
|
||
}
|
||
|
||
if (!IsWindow(g_pDlckDlg->m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
g_pDlckDlg->Create(CDLCKDLG::IDD);
|
||
}
|
||
g_pDlckDlg->ShowAllCables();
|
||
g_pDlckDlg->ShowWindow(SW_SHOW);
|
||
g_pDlckDlg->CenterWindow();
|
||
}
|
||
|
||
//设备编码
|
||
CSBBMDlg *g_pSBBMDlg = NULL;
|
||
CAutoWndDel autoDel2;
|
||
void EL_SBBMCmdFnc()
|
||
{
|
||
//...
|
||
//弹出截面,显示电缆,非模式
|
||
if (g_pSBBMDlg == NULL)
|
||
{
|
||
g_pSBBMDlg = new CSBBMDlg;
|
||
autoDel2.m_pWnd = g_pSBBMDlg;
|
||
}
|
||
|
||
if (!IsWindow(g_pSBBMDlg->m_hWnd))
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
g_pSBBMDlg->Create(CSBBMDlg::IDD);
|
||
}
|
||
g_pSBBMDlg->ShowAllEqus();
|
||
g_pSBBMDlg->ShowWindow(SW_SHOW);
|
||
g_pSBBMDlg->CenterWindow();
|
||
}
|
||
|
||
void EL_ZJXGCmdFnc()
|
||
{
|
||
ads_point pt1, pt2;
|
||
int nRes = acedGetPoint(NULL,_T("\n请在桥架上选择出口引出点:"),pt1);
|
||
if (nRes == RTNORM)
|
||
{
|
||
nRes = acedGetPoint(pt1, _T("\n请选择电气设备的接线点:"), pt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
ads_point pt11, pt22;
|
||
acdbUcs2Wcs(pt1, pt11, false);
|
||
acdbUcs2Wcs(pt2, pt22, false);
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
CHZXGDlg dlg;
|
||
dlg.SetSelectRoad(FALSE);
|
||
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
XGPipeData data;
|
||
memset(&data, 0, sizeof(XGPipeData));
|
||
|
||
if (dlg.GetXGPipeData(data))
|
||
{
|
||
AcDbLine *pLn1 = new AcDbLine(asPnt3d(pt11), AcGePoint3d(pt11[X], pt11[Y], pt22[Z]));
|
||
AecDb3dRoadAxisLine *pRd = new AecDb3dRoadAxisLine;
|
||
pRd->AppendCurveSeg(pLn1);
|
||
delete pLn1;
|
||
|
||
AcDbLine *pLn2 = new AcDbLine(AcGePoint3d(pt11[X], pt11[Y], pt22[Z]), asPnt3d(pt22));
|
||
pRd->AppendCurveSeg(pLn2);
|
||
delete pLn2;
|
||
|
||
double dRatio = data.dDR / data.dOD;
|
||
pRd->SaveDandRatio(data.dOD, dRatio);
|
||
//pRd->Create3dRoadAxisLine(data.dOD, dRatio);
|
||
|
||
AecDbEwFlexiblePipe *pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRd);
|
||
pFlexiblePipe->SetSection(data.dOD, data.dt);//
|
||
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, data.szPName);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_MATERIAL, data.szMaterial);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, data.dOD);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_THICK, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_DN, data.dDN);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, dRatio);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DTEMPER, data.szWorkTmp);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DPRESS, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FLAMER, data.szFlameR);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_TM, data.szTM);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_Model, data.szModel);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_STRUF, data.szStruF);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FACTORY, data.szProvider);
|
||
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//绘制线管
|
||
void EL_HZXGCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CHZXGDlg dlg;
|
||
dlg.SetSelectRoad(TRUE);
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
XGPipeData data;
|
||
memset(&data, 0, sizeof(XGPipeData));
|
||
if (dlg.GetXGPipeData(data))
|
||
{
|
||
double dRatio = data.dDR / data.dOD;
|
||
AcDbEntity *pEnt = NULL;
|
||
|
||
//如果界面中选择了路径 id;
|
||
AcDbObjectId idPath;
|
||
if (dlg.GetSelectRoad(idPath))
|
||
{
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, idPath, AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine *pRoadCln = NULL;
|
||
AcDbLine *pLn = AcDbLine::cast(pEnt);
|
||
AcDbPolyline *pPl = AcDbPolyline::cast(pEnt);
|
||
if (pLn != NULL || pPl != NULL)
|
||
{
|
||
AcDbCurve *pCurve = AcDbCurve::cast(pEnt);
|
||
pRoadCln = new AecDb3dRoadAxisLine;
|
||
pRoadCln->AppendCurveSeg(pCurve);
|
||
}
|
||
|
||
AecDb3dRoadAxisLine *pRoad = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoad != NULL)
|
||
{
|
||
pRoadCln = (AecDb3dRoadAxisLine *)pRoad->clone();
|
||
}
|
||
|
||
if (pRoadCln != NULL)
|
||
{
|
||
pRoadCln->SaveDandRatio(data.dOD, dRatio);
|
||
//pRoadCln->Create3dRoadAxisLine(data.dOD, dRatio);
|
||
|
||
AecDbEwFlexiblePipe *pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRoadCln);
|
||
pFlexiblePipe->SetSection(data.dOD, data.dt);//
|
||
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, data.szPName);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_MATERIAL, data.szMaterial);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, data.dOD);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_THICK, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_DN, data.dDN);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, dRatio);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DTEMPER, data.szWorkTmp);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DPRESS, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FLAMER, data.szFlameR);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_TM, data.szTM);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_Model, data.szModel);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_STRUF, data.szStruF);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FACTORY, data.szProvider);
|
||
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
delete pRoadCln;
|
||
}
|
||
pEnt->erase();
|
||
pEnt->close();
|
||
}
|
||
return;
|
||
}
|
||
|
||
AcPolylineJig jig;
|
||
jig.InitStatusRecsFor3dRoadAxisLine();
|
||
if (jig.DoIt())
|
||
{
|
||
AcDbObjectId id = jig.GetRoadAxisLineId();
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine *pRoadAxLn = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoadAxLn != NULL)
|
||
{
|
||
pRoadAxLn->SaveDandRatio(data.dOD, dRatio);
|
||
//pRoadAxLn->Create3dRoadAxisLine(data.dOD, dRatio);
|
||
|
||
AecDb3dRoadAxisLine *pRoadAxLnCln = (AecDb3dRoadAxisLine *)pRoadAxLn->clone();
|
||
if (pRoadAxLnCln != NULL)
|
||
{
|
||
AecDbEwFlexiblePipe *pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRoadAxLnCln);
|
||
pFlexiblePipe->SetSection(data.dOD, data.dt);//
|
||
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, data.szPName);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_MATERIAL, data.szMaterial);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, data.dOD);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_THICK, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_DN, data.dDN);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, dRatio);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DTEMPER, data.szWorkTmp);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PID_PIPE_DPRESS, data.dt);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FLAMER, data.szFlameR);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_TM, data.szTM);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_Model, data.szModel);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_STRUF, data.szStruF);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FACTORY, data.szProvider);
|
||
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
delete pRoadAxLnCln;
|
||
}
|
||
}
|
||
pEnt->erase();
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//多层线管
|
||
void EL_DCXGCmdFnc()
|
||
{
|
||
|
||
}
|
||
|
||
//放接线盒
|
||
void EL_FJXHCmdFnc()
|
||
{
|
||
|
||
}
|
||
|
||
//放置开关
|
||
void EL_FZKGCmdFnc()
|
||
{
|
||
|
||
}
|
||
|
||
//放置灯具
|
||
void EL_FZDJCmdFnc()
|
||
{
|
||
|
||
}
|
||
|
||
namespace
|
||
{
|
||
AcDbRegion* makeCircleRegion(const AcGePoint3d& ptOrg
|
||
, const AcGeVector3d& vtZ
|
||
, const double& dR)
|
||
{
|
||
AcDbCircle* pCir(new AcDbCircle(ptOrg, vtZ, dR));
|
||
if (!pCir)
|
||
{
|
||
return NULL;
|
||
}
|
||
return CoreTools::createRegion(pCir);
|
||
}
|
||
|
||
AcDbRegion* makeRectRegion(const AcGePoint3d& ptOrg
|
||
, const double& dL
|
||
, const double& dW
|
||
, const AcGeVector3d& vecL
|
||
, const AcGeVector3d& vecW)
|
||
{
|
||
AcGePoint3d ptGe[4];
|
||
|
||
ptGe[0] = ptOrg + vecW * dW * .5;
|
||
ptGe[0] += vecL * dL * .5;
|
||
ptGe[1] = ptGe[0] - vecW * dW;
|
||
ptGe[2] = ptGe[1] - vecL * dL;
|
||
ptGe[3] = ptGe[2] + vecW * dW;
|
||
|
||
AcDbVoidPtrArray ar;
|
||
ar.append(new AcDbLine(ptGe[0], ptGe[1]));
|
||
ar.append(new AcDbLine(ptGe[1], ptGe[2]));
|
||
ar.append(new AcDbLine(ptGe[2], ptGe[3]));
|
||
ar.append(new AcDbLine(ptGe[3], ptGe[0]));
|
||
AcDbRegion* pReg = CoreTools::createRegion(ar);
|
||
deleteArrayVoidPtrs< AcDbLine>(ar);
|
||
if (!pReg)
|
||
{
|
||
return NULL;
|
||
}
|
||
return pReg;
|
||
}
|
||
|
||
template <typename T>
|
||
void setData(AecEqui::XPrimData* pXPData, void* pData)
|
||
{
|
||
pXPData->m_nID = ::_time32(NULL);
|
||
switch (pXPData->m_eType)
|
||
{
|
||
case AecEqui::kExtrude:
|
||
case AecEqui::kRevolve:
|
||
pXPData->m_nSize = ((AecEqui::XBuffer*)pData)->nSize;
|
||
if (pXPData->m_nSize > 0)
|
||
{
|
||
pXPData->m_pData = new byte[pXPData->m_nSize];
|
||
::memcpy(pXPData->m_pData, ((AecEqui::XBuffer*)pData)->pData, pXPData->m_nSize);
|
||
}
|
||
break;
|
||
default:
|
||
pXPData->m_pData = new T;
|
||
::memcpy(pXPData->m_pData, pData, sizeof(T));
|
||
pXPData->m_nSize = sizeof(T);
|
||
break;
|
||
}
|
||
}
|
||
|
||
void clearData(AecEqui::XPrimData& data)
|
||
{
|
||
data.releaseData();
|
||
return;
|
||
}
|
||
|
||
void swap(AcGePoint3d& ptA, AcGePoint3d& ptB)
|
||
{
|
||
AcGePoint3d ptT = ptA;
|
||
ptA = ptB;
|
||
ptB = ptT;
|
||
return;
|
||
}
|
||
}
|
||
|
||
//参见资源图片 IDB_BITMAP3/4/5
|
||
//绘避雷网
|
||
void EL_HBLWCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CHBLWDlg dlg;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AcPolylineJig jig;
|
||
jig.InitStatusRecsForLineSegs();
|
||
if (jig.DoIt())
|
||
{
|
||
AcDbObjectId id = jig.GetRoadAxisLineId();
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine* pRoadAxLn = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoadAxLn != NULL)
|
||
{
|
||
pRoadAxLn->Create3dRoadAxisLine(dlg.m_dL, 0);
|
||
|
||
AecDb3dRoadAxisLine* pRoadAxLnCln = (AecDb3dRoadAxisLine*)pRoadAxLn->clone();
|
||
if (pRoadAxLnCln != NULL)
|
||
{
|
||
AecDbEwFlexiblePipe* pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRoadAxLnCln);
|
||
pFlexiblePipe->SetStartElevation(dlg.m_dBomH);
|
||
pFlexiblePipe->SetEndElevation(dlg.m_dBomH);
|
||
pFlexiblePipe->SetSection(dlg.m_dL, dlg.m_dt, 0.0);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, _T("扁钢"));
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FORUSE, _T("避雷网"));
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_L, dlg.m_dL);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_T, dlg.m_dt);
|
||
//示例
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
}
|
||
}
|
||
|
||
AcDbPolyline* pPl = pRoadAxLn->ConvertTo2dPline();
|
||
if (!pPl)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int nCount(0), i(0), ntemp(0);
|
||
double dLen(.0);
|
||
AcGePoint3d pt, ptS, ptE, ptTemp;
|
||
AcGeVector3d Z(AcGeVector3d::kZAxis), vt, vtDir;
|
||
|
||
int nNum = pPl->numVerts();
|
||
|
||
AcGePoint3dArray ptAr;
|
||
ptAr.removeAll();
|
||
AcGeVector3dArray vecAr;
|
||
vecAr.removeAll();
|
||
for (i = 0; i < pPl->numVerts() - 1; ++i)
|
||
{
|
||
pPl->getPointAt(i, ptS);
|
||
pPl->getPointAt(i + 1, ptE);
|
||
|
||
vt = (ptS - ptE).normalize();
|
||
|
||
dLen = ptS.distanceTo(ptE);
|
||
nCount = (int)(dLen / dlg.m_dSpace);
|
||
|
||
for (int j = 0; j <= nCount; ++j)
|
||
{
|
||
pt = ptS - vt * dlg.m_dSpace * j;
|
||
|
||
ptAr.append(pt);
|
||
vecAr.append(vt);
|
||
|
||
pPl->getEndPoint(ptE);
|
||
dLen = pt.distanceTo(ptE);
|
||
if (dLen < dlg.m_dSpace)
|
||
{
|
||
ptAr.append(ptE);
|
||
vecAr.append(vt);
|
||
}
|
||
}
|
||
}
|
||
|
||
AcArray<AcDbRegion*> regs;
|
||
AcDbRegion *pTopReg(NULL), *pSubTopReg(NULL), *pReg(NULL);
|
||
AecDbEwEquipment* pEqu = new AecDbEwEquipment;
|
||
for (int k = 0; k < ptAr.length(); ++k)
|
||
{
|
||
//pEqu->SetInsert();
|
||
|
||
pt = ptAr.at(k);
|
||
vt = vecAr.at(k);
|
||
|
||
ptTemp = ptAr.at(k - 1);
|
||
dLen = ptTemp.distanceTo(pt);
|
||
if (dLen < dlg.m_dBomW)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
vtDir = vt;
|
||
vtDir.rotateBy(-PI / 2.0, Z);
|
||
vtDir.normalize();
|
||
|
||
AecDbEwFlexiblePipe* pFlexiblePipeSteel = new AecDbEwFlexiblePipe;
|
||
pReg = makeRectRegion(pt, dlg.m_dt, dlg.m_dL, vtDir, vt);
|
||
if (!pReg)
|
||
{
|
||
return;
|
||
}
|
||
|
||
pFlexiblePipeSteel->SetSection(pReg, pt);
|
||
pFlexiblePipeSteel->SetBaseCurve(pt - Z * (dlg.m_dL + dlg.m_dH - dlg.m_dBomH), pt + Z * dlg.m_dBomH);
|
||
pFlexiblePipeSteel->SetStartElevation(dlg.m_dBomH);
|
||
pFlexiblePipeSteel->SetEndElevation(dlg.m_dBomH);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_NAME, _T("扁钢"));
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_FORUSE, _T("避雷网"));
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_T, dlg.m_dt);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_L, dlg.m_dL);
|
||
CoreTools::AddToModelSpace(pFlexiblePipeSteel);
|
||
|
||
regs.removeAll();
|
||
|
||
// 支墩
|
||
pTopReg = makeRectRegion(pt, dlg.m_dBomW, dlg.m_dBomW, vt, vtDir);
|
||
pSubTopReg = makeRectRegion(pt + Z * dlg.m_dH, dlg.m_dTopW, dlg.m_dTopW, vt, vtDir);
|
||
if (pSubTopReg && pTopReg)
|
||
{
|
||
regs.append(pTopReg);
|
||
regs.append(pSubTopReg);
|
||
|
||
AecEqui::XPrimData data;
|
||
NewLoft nl(true, regs, NULL);
|
||
deleteContainerOfArx<AcDbRegion>(regs);
|
||
data.m_nID = ::GetTickCount();
|
||
data.m_eType = AecEqui::kNewLoft;
|
||
data.m_bBoolSubtract = false;
|
||
data.m_iClr = 256;
|
||
data.m_vtMove = Z * -(dlg.m_dL + dlg.m_dH - dlg.m_dBomH);
|
||
nl.toData(data.m_pData, data.m_nSize);
|
||
pEqu->AddSubPrimObj(&data);
|
||
clearData(data);
|
||
}
|
||
}
|
||
CoreTools::AddToModelSpace(pEqu);
|
||
deleteContainerOfArx<AcDbRegion>(regs);
|
||
|
||
pEnt->setColorIndex(1);
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//绘避雷带
|
||
void EL_HBLDCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CHBLDDlg dlg;
|
||
if (IDOK != dlg.DoModal())
|
||
{
|
||
return;
|
||
}
|
||
//参考代码
|
||
|
||
AcPolylineJig jig;
|
||
jig.InitStatusRecsFor2DLineSegs();
|
||
if (jig.DoIt() == FALSE)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbObjectId id = jig.GetRoadAxisLineId();
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk != acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
return;
|
||
}
|
||
|
||
AecDb3dRoadAxisLine* pRoadAxLn = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (!pRoadAxLn)
|
||
{
|
||
return;
|
||
}
|
||
|
||
pRoadAxLn->SaveDandRatio(dlg.m_dSteelT, 2);
|
||
//pRoadAxLn->Create3dRoadAxisLine(dlg.m_dSteelT, 2);
|
||
AecDb3dRoadAxisLine* pRoadAxLnCln = (AecDb3dRoadAxisLine*)pRoadAxLn->clone();
|
||
if (!pRoadAxLnCln)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AecDbEwFlexiblePipe* pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRoadAxLnCln);
|
||
pFlexiblePipe->SetStartElevation(dlg.m_dBomEl);
|
||
pFlexiblePipe->SetEndElevation(dlg.m_dBomEl);
|
||
pFlexiblePipe->SetSection(dlg.m_dSteelT, dlg.m_dSteelT, 0.0);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, _T("扁钢"));
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_FORUSE, _T("避雷带"));
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_L, dlg.m_dSteelT);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_T, dlg.m_dSteelT);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, dlg.m_dSteelT);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, 2);
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
|
||
AcDbPolyline* pPl = pRoadAxLnCln->ConvertTo2dPline();
|
||
if (!pPl)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int nCount(0), i(0), ntemp(0);
|
||
double dLen(.0);
|
||
AcGePoint3d pt, ptS, ptE, ptTemp;
|
||
AcGeVector3d Z(AcGeVector3d::kZAxis), vt, vtDir;
|
||
|
||
AcGePoint3dArray ptAr;
|
||
ptAr.removeAll();
|
||
AcGeVector3dArray vecAr;
|
||
vecAr.removeAll();
|
||
for (i = 0; i < pPl->numVerts() - 1; ++i)
|
||
{
|
||
pPl->getPointAt(i, ptS);
|
||
pPl->getPointAt(i + 1, ptE);
|
||
|
||
vt = (ptS - ptE).normalize();
|
||
|
||
dLen = ptS.distanceTo(ptE);
|
||
if (dLen < dlg.m_dBaseR)
|
||
{
|
||
continue;
|
||
}
|
||
nCount = (int)(dLen / dlg.m_dBaseDist);
|
||
|
||
for (int j = 0; j <= nCount; ++j)
|
||
{
|
||
pt = ptS - vt * dlg.m_dBaseDist * j;
|
||
|
||
ptAr.append(pt);
|
||
vecAr.append(vt);
|
||
|
||
pPl->getEndPoint(ptE);
|
||
dLen = pt.distanceTo(ptE);
|
||
if ((dLen > dlg.m_dBaseR * .5) && (dLen < dlg.m_dBaseDist))
|
||
{
|
||
ptAr.append(ptE);
|
||
vecAr.append(vt);
|
||
}
|
||
}
|
||
}
|
||
|
||
AecDbEwEquipment* pEqu = new AecDbEwEquipment;
|
||
AcDbRegion* pReg(NULL);
|
||
for (int k = 0; k < ptAr.length(); ++k)
|
||
{
|
||
pt = ptAr.at(k);
|
||
ptTemp = ptAr.at(k - 1);
|
||
vt = vecAr.at(k);
|
||
|
||
dLen = ptTemp.distanceTo(pt);
|
||
if (dLen < dlg.m_dBaseR * .5)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
vtDir = vt;
|
||
vtDir.rotateBy(-PI / 2.0, Z);
|
||
vtDir.normalize();
|
||
|
||
pt += Z * dlg.m_dBomEl;
|
||
|
||
// 圆钢 + 扁钢
|
||
AecDbEwFlexiblePipe* pFlexiblePipeSteel = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipeSteel->SetBaseCurve(pt - Z * dlg.m_dSteelH, pt);
|
||
if (dlg.m_bSteelType)
|
||
{
|
||
// 圆钢
|
||
pFlexiblePipeSteel->SetSection(dlg.m_dSteelT, 0.0);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_NAME, _T("圆钢"));
|
||
}
|
||
else
|
||
{
|
||
// 扁钢
|
||
pReg = makeRectRegion(pt, dlg.m_dSteelT, dlg.m_dSteelT, vt, vtDir);
|
||
if (!pReg)
|
||
{
|
||
return;
|
||
}
|
||
pFlexiblePipeSteel->SetSection(pReg, pt);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_NAME, _T("扁钢"));
|
||
}
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_FORUSE, _T("避雷带"));
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_L, dlg.m_dSteelT);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(KEY_T, dlg.m_dSteelT);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(PIPE_D, dlg.m_dSteelT);
|
||
pFlexiblePipeSteel->GetSpecialtyData()->SetAt(PIPE_RATIO, 2);
|
||
AcDbObjectId idSteel = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipeSteel->setLayer(idSteel);
|
||
CoreTools::AddToModelSpace(pFlexiblePipeSteel);
|
||
|
||
// 底座
|
||
pReg = makeCircleRegion(pt - Z * dlg.m_dSteelH, Z, dlg.m_dBaseR * .5);
|
||
if (!pReg)
|
||
{
|
||
return;
|
||
}
|
||
NewExtrude extrudeDZ(true, pReg, dlg.m_dBaseH);
|
||
DELETE_PTR(pReg);
|
||
AecEqui::XPrimData dataDZ;
|
||
dataDZ.m_eType = AecEqui::kNewExtrude;
|
||
dataDZ.m_bBoolSubtract = false;
|
||
dataDZ.m_iClr = 50;
|
||
extrudeDZ.toData(dataDZ.m_pData, dataDZ.m_nSize);
|
||
pEqu->AddSubPrimObj(&dataDZ);
|
||
clearData(dataDZ);
|
||
}
|
||
CoreTools::AddToModelSpace(pEqu);
|
||
|
||
//pEnt->setColorIndex(1);
|
||
pEnt->close();
|
||
}
|
||
|
||
//加伸缩节
|
||
void EL_JSSJCmdFnc()
|
||
{
|
||
//拾取避雷带位置点
|
||
//输入上弯半径
|
||
|
||
// 拾取避雷带位置点
|
||
ads_name ent;
|
||
ads_point pt;
|
||
int nRes = acedEntSel(_T("\n拾取避雷带:"), ent, pt);
|
||
if (nRes != RTNORM) return;
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
ads_point adsPtSelect;
|
||
nRes = acedGetPoint(NULL, _T("\n拾取避雷带位置点:"), adsPtSelect);
|
||
if (nRes != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
|
||
ads_point pt1;
|
||
acdbUcs2Wcs(adsPtSelect, pt1, false);
|
||
AcGePoint3d ptGe[6];
|
||
ptGe[0] = asPnt3d(pt1);
|
||
|
||
// 输入上弯半径
|
||
double dR(.0);
|
||
nRes = acedGetReal(_T("\n输入上弯半径: "), &dR);
|
||
if (nRes != RTNORM) return;
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbEwFlexiblePipe* pFl = AecDbEwFlexiblePipe::cast(pEnt);
|
||
if (!pFl) return;
|
||
AcDbCurve* pBaseCurve = pFl->GetBaseCurve();//路径
|
||
if (!pBaseCurve) return;
|
||
AecDb3dRoadAxisLine* pRoadAxLn = AecDb3dRoadAxisLine::cast(pBaseCurve);
|
||
if (!pRoadAxLn)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbPolyline* pPl = pRoadAxLn->ConvertTo2dPline();
|
||
if (!pPl)
|
||
{
|
||
return;
|
||
}
|
||
pPl->getClosestPointTo(ptGe[0], ptGe[1]);
|
||
AcDbCircle* pCirM = new AcDbCircle(ptGe[1], AcGeVector3d::kZAxis, 10);
|
||
pCirM->setColorIndex(3);
|
||
CoreTools::AddToModelSpace(pCirM);
|
||
double dLen(.0);
|
||
pPl->getDistAtPoint(ptGe[1], dLen);
|
||
pPl->getPointAtDist(dLen - dR * 2, ptGe[2]);
|
||
pPl->getPointAtDist(dLen + dR * 2, ptGe[3]);
|
||
AcDbCircle* pCirS = new AcDbCircle(ptGe[2], AcGeVector3d::kZAxis, 10);
|
||
pCirS->setColorIndex(6);
|
||
CoreTools::AddToModelSpace(pCirS);
|
||
AcDbCircle* pCirE = new AcDbCircle(ptGe[3], AcGeVector3d::kZAxis, 10);
|
||
pCirE->setColorIndex(6);
|
||
CoreTools::AddToModelSpace(pCirE);
|
||
|
||
AecDb3dRoadAxisLine* pRoad = new AecDb3dRoadAxisLine();
|
||
AcDbCurve* pCurveF(NULL);
|
||
int nNum = pRoadAxLn->GetCurveSegCount();
|
||
double dLen1(.0), dLen2(.0), dLen3(.0);
|
||
AcGePoint3d ptE;
|
||
int nIndex(0);
|
||
AcDbLine* pL(NULL);
|
||
AcDbArc* pArc(NULL);
|
||
for (int i(0); i < nNum; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
dLen3 += dLen1;
|
||
pCurveF->getEndPoint(ptE);
|
||
pCurveF->getDistAtPoint(ptE, dLen1);
|
||
dLen2 += dLen1;
|
||
|
||
if ((dLen <= dLen2)&&(dLen >= dLen3))
|
||
{
|
||
acutPrintf(_T("\nfind!"));
|
||
nIndex = i;
|
||
}
|
||
}
|
||
|
||
for (int i(0); i < nIndex; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
pRoad->AppendCurveSeg(pCurveF);
|
||
}
|
||
|
||
AcGePoint3dArray ptAr;
|
||
ptAr.removeAll();
|
||
ptAr.append(ptGe[2]);
|
||
ptAr.append(ptGe[3]);
|
||
AcDbVoidPtrArray CurveAr;
|
||
CurveAr.removeAll();
|
||
pCurveF = pRoadAxLn->GetCurveSeg(nIndex);
|
||
Acad::ErrorStatus es = pCurveF->getSplitCurves(ptAr, CurveAr);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return;
|
||
}
|
||
AecDb3dRoadAxisLine* pCurveS = (AecDb3dRoadAxisLine*)CurveAr.first();
|
||
AecDb3dRoadAxisLine* pCurveE = (AecDb3dRoadAxisLine*)CurveAr.last();
|
||
if (!pCurveS) return;
|
||
AcGeMatrix3d mat;
|
||
mat.setToIdentity();
|
||
mat.setTranslation(AcGeVector3d::kZAxis * 150);
|
||
//pCurveS->transformBy(mat);
|
||
pCurveS->setColorIndex(3);
|
||
CoreTools::CloneAndAddToModelSpace(pCurveS);
|
||
if (!pCurveE) return;
|
||
mat.setToIdentity();
|
||
mat.setTranslation(AcGeVector3d::kZAxis * 150);
|
||
//pCurveE->transformBy(mat);
|
||
pCurveE->setColorIndex(3);
|
||
CoreTools::CloneAndAddToModelSpace(pCurveE);
|
||
|
||
pRoad->AppendCurveSeg(pCurveS);
|
||
|
||
AcGeVector3d vt, vtDir, Z(AcGeVector3d::kZAxis);
|
||
vt = (ptGe[2] - ptGe[3]).normalize();
|
||
vtDir = vt;
|
||
vtDir.rotateBy(PI / 2.0, Z);
|
||
vtDir.normalize();
|
||
|
||
AcGePoint3d pt = ptGe[2] + Z * dR;
|
||
AcDbArc* pArcTest = new AcDbArc(pt, vtDir, dR, PI * 1.5, PI * 2);
|
||
CoreTools::CloneAndAddToModelSpace(pArcTest);
|
||
pRoad->AppendCurveSeg(pArcTest);
|
||
pt -= vt * dR * 2;
|
||
pArcTest = new AcDbArc(pt, vtDir, dR, .0, PI);
|
||
CoreTools::CloneAndAddToModelSpace(pArcTest);
|
||
pRoad->AppendCurveSeg(pArcTest);
|
||
pt -= vt * dR * 2;
|
||
pArcTest = new AcDbArc(pt, vtDir, dR, PI, PI * 1.5);
|
||
CoreTools::CloneAndAddToModelSpace(pArcTest);
|
||
pRoad->AppendCurveSeg(pArcTest);
|
||
|
||
pRoad->AppendCurveSeg(pCurveE);
|
||
|
||
for (int i = (nIndex + 1); i < nNum; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
pRoad->AppendCurveSeg(pCurveF);
|
||
}
|
||
|
||
pFl->SetBaseCurve(pRoad);
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
//翻弯避让
|
||
void EL_FWBRCmdFnc()
|
||
{
|
||
//拾取避雷带位置第一点
|
||
//拾取避雷带位置第二点
|
||
//输入过度弯曲的半径:
|
||
|
||
ads_name ent;
|
||
ads_point adsPt;
|
||
int nRes = acedEntSel(_T("\n拾取避雷带:"), ent, adsPt);
|
||
if (nRes != RTNORM) return;
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
ads_point adsPtS, adsPtE;
|
||
nRes = acedGetPoint(NULL, _T("\n拾取避雷带位置第一点:"), adsPtS);
|
||
if (nRes != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
nRes = acedGetPoint(NULL, _T("\n拾取避雷带位置第二点:"), adsPtE);
|
||
if (nRes != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
|
||
ads_point adsPtS1, adsPtE1;
|
||
acdbUcs2Wcs(adsPtS, adsPtS1, false);
|
||
acdbUcs2Wcs(adsPtE, adsPtE1, false);
|
||
AcGePoint3d ptGe[6];
|
||
ptGe[0] = asPnt3d(adsPtS1);
|
||
ptGe[1] = asPnt3d(adsPtE1);
|
||
|
||
double dDist = ptGe[0].distanceTo(ptGe[1]);
|
||
if (dDist < 1e-6)
|
||
{
|
||
acutPrintf(_T("\n拾取避雷带位置的两点距离(%g)太短!"), dDist);
|
||
return;
|
||
}
|
||
|
||
// 输入过度弯曲的半径:
|
||
double dR(.0);
|
||
nRes = acedGetReal(_T("\n请输入过度弯曲的半径: "), &dR);
|
||
if (nRes != RTNORM) return;
|
||
|
||
dDist = ptGe[0].distanceTo(ptGe[1]);
|
||
if (dDist < dR * 2)
|
||
{
|
||
acutPrintf(_T("\n拾取避雷带位置的两点距离(%g)太短!"), dDist);
|
||
return;
|
||
}
|
||
|
||
AcDbEntity* pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDbEwFlexiblePipe* pFl = AecDbEwFlexiblePipe::cast(pEnt);
|
||
if (!pFl) return;
|
||
AcDbCurve* pBaseCurve = pFl->GetBaseCurve();//路径
|
||
if (!pBaseCurve) return;
|
||
AecDb3dRoadAxisLine* pRoadAxLn = AecDb3dRoadAxisLine::cast(pBaseCurve);
|
||
if (!pRoadAxLn)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbPolyline* pPl = pRoadAxLn->ConvertTo2dPline();
|
||
if (!pPl)
|
||
{
|
||
return;
|
||
}
|
||
pPl->getClosestPointTo(ptGe[0], ptGe[2]);
|
||
pPl->getClosestPointTo(ptGe[1], ptGe[3]);
|
||
double dLenS(.0), dLenE(.0);
|
||
pPl->getDistAtPoint(ptGe[2], dLenS);
|
||
pPl->getDistAtPoint(ptGe[3], dLenE);
|
||
if (dLenS > dLenE)
|
||
{
|
||
swap(ptGe[2], ptGe[3]);
|
||
}
|
||
|
||
AcGeVector3d vt, vtDir, Z(AcGeVector3d::kZAxis);
|
||
vt = (ptGe[2] - ptGe[3]).normalize();
|
||
vtDir = vt;
|
||
vtDir.rotateBy(PI / 2.0, Z);
|
||
vtDir.normalize();
|
||
|
||
dDist = ptGe[2].distanceTo(ptGe[3]);
|
||
AcGePoint3d ptMid = ptGe[2] - vt * dDist * .5;;
|
||
|
||
AcDbCircle* pCirS = new AcDbCircle(ptGe[2], AcGeVector3d::kZAxis, 10);
|
||
pCirS->setColorIndex(3);
|
||
CoreTools::AddToModelSpace(pCirS);
|
||
AcDbCircle* pCirM = new AcDbCircle(ptMid, AcGeVector3d::kZAxis, 10);
|
||
pCirM->setColorIndex(6);
|
||
CoreTools::AddToModelSpace(pCirM);
|
||
AcDbCircle* pCirE = new AcDbCircle(ptGe[3], AcGeVector3d::kZAxis, 10);
|
||
pCirE->setColorIndex(3);
|
||
CoreTools::AddToModelSpace(pCirE);
|
||
|
||
pPl->getDistAtPoint(ptMid, dDist);
|
||
|
||
AecDb3dRoadAxisLine* pRoad = new AecDb3dRoadAxisLine();
|
||
AcDbCurve* pCurveF(NULL);
|
||
int nNum = pRoadAxLn->GetCurveSegCount();
|
||
double dLen1(.0), dLen2(.0), dLen3(.0);
|
||
AcGePoint3d ptE;
|
||
int nIndex(0);
|
||
AcDbLine* pL(NULL);
|
||
AcDbArc* pArc(NULL);
|
||
for (int i(0); i < nNum; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
dLen3 += dLen1;
|
||
pCurveF->getEndPoint(ptE);
|
||
pCurveF->getDistAtPoint(ptE, dLen1);
|
||
dLen2 += dLen1;
|
||
|
||
if ((dDist <= dLen2) && (dDist >= dLen3))
|
||
{
|
||
acutPrintf(_T("\nfind!"));
|
||
nIndex = i;
|
||
}
|
||
}
|
||
|
||
for (int i(0); i < nIndex; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
pRoad->AppendCurveSeg(pCurveF);
|
||
}
|
||
|
||
AcGePoint3dArray ptAr;
|
||
ptAr.removeAll();
|
||
ptAr.append(ptGe[2]);
|
||
ptAr.append(ptGe[3]);
|
||
AcDbVoidPtrArray CurveAr;
|
||
CurveAr.removeAll();
|
||
pCurveF = pRoadAxLn->GetCurveSeg(nIndex);
|
||
Acad::ErrorStatus es = pCurveF->getSplitCurves(ptAr, CurveAr);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return;
|
||
}
|
||
AecDb3dRoadAxisLine* pCurveS = (AecDb3dRoadAxisLine*)CurveAr.first();
|
||
AecDb3dRoadAxisLine* pCurveE = (AecDb3dRoadAxisLine*)CurveAr.last();
|
||
if (!pCurveS) return;
|
||
AcGeMatrix3d mat;
|
||
mat.setToIdentity();
|
||
mat.setTranslation(AcGeVector3d::kZAxis * 150);
|
||
//pCurveS->transformBy(mat);
|
||
pCurveS->setColorIndex(3);
|
||
CoreTools::CloneAndAddToModelSpace(pCurveS);
|
||
if (!pCurveE) return;
|
||
mat.setToIdentity();
|
||
mat.setTranslation(AcGeVector3d::kZAxis * 150);
|
||
//pCurveE->transformBy(mat);
|
||
pCurveE->setColorIndex(3);
|
||
CoreTools::CloneAndAddToModelSpace(pCurveE);
|
||
|
||
pRoad->AppendCurveSeg(pCurveS);
|
||
|
||
AcGePoint3d pt = ptGe[2] + Z * dR;
|
||
pArc = new AcDbArc(pt, vtDir, dR, PI * 1.5, PI * 2);
|
||
CoreTools::CloneAndAddToModelSpace(pArc);
|
||
pRoad->AppendCurveSeg(pArc);
|
||
pt -= vt * dR * 2;
|
||
pArc = new AcDbArc(pt, vtDir, dR, PI * .5, PI);
|
||
CoreTools::CloneAndAddToModelSpace(pArc);
|
||
pRoad->AppendCurveSeg(pArc);
|
||
|
||
ptGe[4] = ptGe[2] - vt * dR * 2;
|
||
ptGe[4] += Z * dR * 2;
|
||
ptGe[5] = ptGe[3] + vt * dR * 2;
|
||
ptGe[5] += Z * dR * 2;
|
||
pL = new AcDbLine(ptGe[4], ptGe[5]);
|
||
pL->setColorIndex(3);
|
||
CoreTools::CloneAndAddToModelSpace(pL);
|
||
pRoad->AppendCurveSeg(pL);
|
||
|
||
pt = ptGe[3] + Z * dR;
|
||
pt += vt * dR * 2;
|
||
pArc = new AcDbArc(pt, vtDir, dR, .0, PI * .5);
|
||
CoreTools::CloneAndAddToModelSpace(pArc);
|
||
pRoad->AppendCurveSeg(pArc);
|
||
pt -= vt * dR * 2;
|
||
pArc = new AcDbArc(pt, vtDir, dR, PI, PI * 1.5);
|
||
CoreTools::CloneAndAddToModelSpace(pArc);
|
||
pRoad->AppendCurveSeg(pArc);
|
||
|
||
pRoad->AppendCurveSeg(pCurveE);
|
||
|
||
for (int i = (nIndex + 1); i < nNum; ++i)
|
||
{
|
||
pCurveF = pRoadAxLn->GetCurveSeg(i);
|
||
pL = AcDbLine::cast(pCurveF);
|
||
pArc = AcDbArc::cast(pCurveF);
|
||
if (!pL && !pArc)
|
||
{
|
||
acutPrintf(_T("\n存在除直线、弧线之外的曲线类型!"));
|
||
return;
|
||
}
|
||
|
||
pRoad->AppendCurveSeg(pCurveF);
|
||
}
|
||
|
||
pFl->SetBaseCurve(pRoad);
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
//加引下线
|
||
void EL_JYXXCmdFnc()
|
||
{
|
||
//拾取避雷带加引下线位置点:
|
||
ads_name ent;
|
||
ads_point pt;
|
||
int nRes = acedEntSel(_T("\n拾取避雷带位置点:"), ent, pt);
|
||
if (nRes != RTNORM) return;
|
||
|
||
}
|
||
|
||
//柔性类管
|
||
void EL_RXLGCmdFnc()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CRXLGDlg dlg;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AcPolylineJig jig;
|
||
jig.InitStatusRecsForLineSegs();
|
||
if (jig.DoIt())
|
||
{
|
||
AcDbObjectId id = jig.GetRoadAxisLineId();
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
|
||
{
|
||
AecDb3dRoadAxisLine *pRoadAxLn = AecDb3dRoadAxisLine::cast(pEnt);
|
||
if (pRoadAxLn != NULL)
|
||
{
|
||
//TEST
|
||
//AecDb3dRoadAxisLine *pRoadAxLnCln2 = (AecDb3dRoadAxisLine *)pRoadAxLn->clone();
|
||
//pRoadAxLnCln2->setColorIndex(2);
|
||
//CoreTools::AddToModelSpace(pRoadAxLnCln2);
|
||
|
||
pRoadAxLn->SaveDandRatio(dlg.m_dD, dlg.m_dRatio);
|
||
//pRoadAxLn->Create3dRoadAxisLine(dlg.m_dD, dlg.m_dRatio);
|
||
|
||
AecDb3dRoadAxisLine*pRoadAxLnCln = (AecDb3dRoadAxisLine *)pRoadAxLn->clone();
|
||
if (pRoadAxLnCln != NULL)
|
||
{
|
||
AecDbEwFlexiblePipe *pFlexiblePipe = new AecDbEwFlexiblePipe;
|
||
pFlexiblePipe->SetBaseCurve(pRoadAxLnCln);
|
||
pFlexiblePipe->SetSection(0.5 * dlg.m_dD,0.0);//TEST RECT
|
||
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(KEY_NAME, _T("柔性类管"));
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_D, dlg.m_dD);
|
||
pFlexiblePipe->GetSpecialtyData()->SetAt(PIPE_RATIO, dlg.m_dRatio);
|
||
// 示例
|
||
AcDbObjectId idPipe = KTSetting::InitLayer(LAY_PIPE_OUTSIDE);
|
||
pFlexiblePipe->setLayer(idPipe);
|
||
|
||
CoreTools::AddToModelSpace(pFlexiblePipe);
|
||
|
||
delete pRoadAxLnCln;
|
||
}
|
||
}
|
||
//TEST
|
||
//pEnt->erase();
|
||
pEnt->setColorIndex(1);
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//布置电气柜
|
||
void EL_BDQGCmdFnc()
|
||
{
|
||
ads_point adspt, adspt2;
|
||
int nRes = acedGetPoint(NULL, _T("\n选择插入点:"), adspt);
|
||
if (nRes != RTNORM) return;
|
||
AcGePoint3d ptIns(asPnt3d(adspt));
|
||
CoreTools::UCS2WCS(ptIns, ptIns);
|
||
|
||
AcGeVector3d vtDir(AcGeVector3d::kXAxis);
|
||
nRes = acedGetPoint(adspt, _T("\n选择插入方向<默认X方向>:"), adspt2);
|
||
if (nRes == RTNORM)
|
||
{
|
||
AcGePoint3d pt2(asPnt3d(adspt2));
|
||
CoreTools::UCS2WCS(pt2, pt2);
|
||
vtDir = pt2 - ptIns;
|
||
}
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
CBDQGDlg dlg;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
AecDbEwEquipment *pEqu = dlg.getEqu(ptIns, vtDir);
|
||
if (pEqu)
|
||
CoreTools::AddToModelSpace(pEqu);
|
||
}
|
||
}
|
||
|
||
//桥架管件测试
|
||
void EL_QJCSCmdFnc()
|
||
{
|
||
|
||
} |