Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

2947 lines
67 KiB
C++

#include "stdafx.h"
#include "KTParamService.h"
#include "KTEntityDragMgr.h"
#include "ValveDlg.h"
#include "InstHandDlg.h"
#include "PIDLineTools.h"
#include "KTMtoTool.h"
#include "UIHistory.h"
#include "CoreTools.h"
#define DIMOFFSET 3
namespace
{
int InitValve(CUIISQLiteServer &sqlDb, AecDbObjXDataMap & xDataMap)
{
CString dbPath = FilePath::GetSysDir();
dbPath += _T("\\Plumbing.db");
if (!sqlDb.InitADOServer(dbPath))
{
acutPrintf(_T("\n系统数据库环境没有初始化!"));
return FALSE;
}
//选择管子,管件判断类型
//获取初始化数据
xDataMap.SetAt(DOC_PIDTRADE, WPipe::ePetro); //应用行业,石油
xDataMap.SetAt(DOC_PIDSCRIPTT, _T("{0}{-}{1}{-}{2}{-}{3}"));//上标脚本
xDataMap.SetAt(DOC_PIDSCRIPTB, _T("{4}{-}{5}"));//下标脚本
xDataMap.SetAt(DOC_PIDBSPACE, 3.0); //交叉断线间距
xDataMap.SetAt(DOC_PIDEWITHDIM, TRUE); //设备插入标注
xDataMap.SetAt(DOC_PIDVWITHDIM, TRUE); //阀门插入标注
xDataMap.SetAt(DOC_PIDINSRDN, 12); //仪表泡直径
xDataMap.SetAt(DOC_CONSIGN, 30.0); //续接符号
xDataMap.SetAt(DOC_PIDBARROW, 6.0); //大箭头
xDataMap.SetAt(DOC_PIDEQPTXTH, 3.5); //设备标注文字高度
xDataMap.SetAt(DOC_PIDEQPTXTF, 1.0); //设备文字宽度系数
xDataMap.SetAt(DOC_PIDMARROW, 3.0); //中箭头
xDataMap.SetAt(DOC_PIDSARROW, 1.5); //小箭头
xDataMap.SetAt(DOC_PIDVALVTXTH, 3.5); //阀门文字高度
xDataMap.SetAt(DOC_PIDVALVTXTF, 1.0); //阀门文字宽度系数
xDataMap.SetAt(DOC_PIDDIMTXTH, 3.5); //标注文字高度
xDataMap.SetAt(DOC_PIDDIMTXTF, 1.0); //标注文字宽度系数
xDataMap.SetAt(DOC_EQUSCALE, 6.0); //设备比例
xDataMap.SetAt(DOC_LINEARSCALE, 10.0); //线性比例
xDataMap.SetAt(DOC_PIDMPIPE1W, 1.0); //主管道线宽1
xDataMap.SetAt(DOC_PIDMPIPE2W, 0.5); //主管道线宽2
xDataMap.SetAt(DOC_NODESCALE, 6.0); //管嘴比例
xDataMap.SetAt(DOC_PIDSPIPE1W, 0.25); //次管道线宽1
xDataMap.SetAt(DOC_PIDSPIPE2W, 0.125); //次管道线宽2
xDataMap.SetAt(DOC_VALVESCALE, 100.0); //阀门比例
xDataMap.SetAt(DOC_PIDUNIT, 0); //单位
xDataMap.SetAt(DOC_PIDDIMTERM, 0); //标注端符
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xDataMap))
{
acedAlert(_T("\n系统未初始化!"));
return FALSE;
}
return TRUE;
}
BOOL FindPipeCen(AcGePoint3d& ptGeIn, AcDbObjectId& idCen, int & npipe, double dPipeW, AcGePoint3d& pts, AcGePoint3d& pte, CString & sLineno, CString & sDn, CString & sSpec)
{
ads_point ptC[2];
ads_point_set(asDblArray(ptGeIn), ptC[0]);
ads_point_set(asDblArray(ptGeIn), ptC[1]);
ptC[0][X] -= CoreTools::PixelToWcs(10);
ptC[0][Y] -= CoreTools::PixelToWcs(10);
ptC[1][X] += CoreTools::PixelToWcs(10);
ptC[1][Y] += CoreTools::PixelToWcs(10);
ads_name ssname, ent;
acedSSGet(_T("C"), ptC[0], ptC[1], NULL, ssname);
Adesk::Int32 lLen = 0;
acedSSLength(ssname, &lLen);
AcDbEntity* pEnt = NULL;
AcDbObjectId id;
CoreTools::UCS2WCS(ptGeIn, ptGeIn);
for (int i = 0; i < lLen; i++)
{
acedSSName(ssname, i, ent);
if (Acad::eOk == acdbGetObjectId(id, ent))
{
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
{
AecDbObjXDataMap objXData;
if (objXData.Read(pEnt, PIDPIPE_APP))
{
objXData.GetAt(PID_PIPE_DN, sDn);
objXData.GetAt(PID_PIPE_LEVEL, sSpec);
objXData.GetAt(PID_PIPE_LINENO, sLineno);
AcDbPolyline * pPline = AcDbPolyline::cast(pEnt);
if (pPline != NULL) //如果是PL则管道为单线
{
AcGePoint3d pt;
pPline->getClosestPointTo(ptGeIn, pt);
// 去点所在处参数值
double dParam;
pPline->getParamAtPoint(pt, dParam);
// 取前后节点
int iParam = int(dParam);
pPline->getPointAtParam(iParam, pts);
pPline->getPointAtParam(iParam + 1, pte);
pPline->close();
idCen = id;
pEnt->close();
acedSSFree(ssname);
return TRUE;
}
}
else
{
pEnt->close();
continue;
}
//是管线
}
}
}
//没有找到管线,可以是引线
for (int i = 0; i < lLen; i++)
{
acedSSName(ssname, i, ent);
if (Acad::eOk == acdbGetObjectId(id, ent))
{
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
{
AcDbPolyline *pPline = AcDbPolyline::cast(pEnt);
if (pPline != NULL) //如果是PL则管道为单线
{
AcGePoint3d pt;
pPline->getClosestPointTo(ptGeIn, pt);
// 去点所在处参数值
double dParam;
pPline->getParamAtPoint(pt, dParam);
// 取前后节点
int iParam = int(dParam);
pPline->getPointAtParam(iParam, pts);
pPline->getPointAtParam(iParam + 1, pte);
pPline->close();
idCen = id;
pEnt->close();
acedSSFree(ssname);
return TRUE;
}
}
pEnt->close();
}
}
acedSSFree(ssname);
// acutRelRb(pRb);
return FALSE;
}
BOOL FindPipePlines(const AcDbObjectId& idPline, AcDbObjectIdArray& arid, double& dLeftWidth, double& dRightWidth)
{
arid.append(idPline);
dLeftWidth = dRightWidth = 0.0;
AcDbPolyline* pPline = NULL;
acdbOpenObject(pPline, idPline, AcDb::kForRead);
if (NULL == pPline)
return FALSE;
if (2 > pPline->numVerts())
{
pPline->close();
return FALSE;
}
AcGePoint3d pt1, pt2;
pPline->getPointAt(0, pt1);
pPline->getPointAt(1, pt2);
AcGeLine3d line(pt1, pt2);
AcGeVector3d vt1(pt2 - pt1);
AcGeVector3d vt2 = pPline->normal();
pPline->close();
AcDbObjectIdArray aridGroup;
if (0 < CKTCadUtility::GetItemGroups(idPline, aridGroup))
CKTCadUtility::GetGroupItems(aridGroup[0], arid);
double dAngle, dDist;
AcGePoint3d pt3, pt4;
int iPos = arid.length();
while ((--iPos) >= 1)
{
if (arid[iPos] == idPline)
{
arid.removeAt(iPos);
continue;
}
if (Acad::eOk != acdbOpenObject(pPline, arid[iPos], AcDb::kForRead))
{
arid.removeAt(iPos);
continue;
}
pPline->getPointAt(0, pt3);
pPline->close();
pt4 = line.closestPointTo(pt3);
dAngle = vt1.angleTo(pt3 - pt4, vt2);
if (dAngle < PI)
{
dDist = pt3.distanceTo(pt4);
if (dLeftWidth < dDist)
dLeftWidth = dDist;
}
else
{
dDist = -pt3.distanceTo(pt4);
if (dRightWidth > dDist)
dRightWidth = dDist;
}
}
return TRUE;
}
BOOL BreakPIDPipe(const AcDbObjectId& idBreak, const AcGePoint3d& ptBreak, double dLength)
{
// 找到管线组
double dLeft, dRight;
AcDbObjectIdArray aridPoly;
BOOL nOK = FindPipePlines(idBreak, aridPoly, dLeft, dRight);
if (!nOK)
{
return FALSE;
}
// 打开主管线
AcDbPolylinePtr pPline(aridPoly[0], AcDb::kForRead);
if (NULL == pPline)
return FALSE;
// 判断在该点处曲线是否可以裁减(看是否裁超过拐点, 包括多线时)
// 确保是曲线上的点
AcGePoint3d pt, pt1, pt2, pt3;
pPline->getClosestPointTo(ptBreak, pt);
// 去点所在处参数值
double dParam, dAngle;
pPline->getParamAtPoint(pt, dParam);
// 取前后节点
int iParam = int(dParam);
pPline->getPointAtParam(iParam, pt1);
pPline->getPointAtParam(iParam + 1, pt2);
// 该点所在线段方向
AcGeVector3d vt = (pt2 - pt1).normal();
AcGeVector3d vtNormal = pPline->normal();
// 去除多线拐弯宽度
if (Acad::eOk == pPline->getPointAtParam(iParam - 1, pt3))
{
dAngle = vt.angleTo(pt1 - pt3, vtNormal);
pt1 += vt * fabs(dAngle > PI ? fabs(dLeft) : fabs(dRight));
}
// 去除多线拐弯宽度
if (Acad::eOk == pPline->getPointAtParam(iParam + 2, pt3))
{
dAngle = vt.angleTo(pt3 - pt2, vtNormal);
pt2 -= vt * fabs(dAngle < PI ? fabs(dLeft) : fabs(dRight));
}
// 判断是否够裁减
if (pt1.distanceTo(pt) < dLength / 2.0 || pt2.distanceTo(pt) < dLength / 2.0)
return FALSE;
// 将pt1, pt2定位到断开位置
pt1 = pt - vt * dLength / 2.0;
pt2 = pt + vt * dLength / 2.0;
// 关闭主管线
pPline->close();
// 裁减出曲线, 修改保留旧曲线
AcGePlane plane(AcGePoint3d::kOrigin, vtNormal);
//
AcDbObjectId idEnt;
AcDbPolyline* pNew;
AcDbObjectIdArray arid;
//
int iVert;
double dWidth;
struct resbuf* pRb;
int iPos = aridPoly.length();
while ((--iPos) >= 0)
{
// 打开每根多段线
pPline.Open(aridPoly[iPos], AcDb::kForWrite);
if (NULL == pPline)
continue;
// 创建裁剪的新对象
pNew = new AcDbPolyline;
ASSERT(NULL != pNew);
// 复制属新和扩展数据
pNew->setNormal(pPline->normal());
pNew->setElevation(pPline->elevation());
pPline->getConstantWidth(dWidth);
pNew->setConstantWidth(dWidth);
pNew->setPropertiesFrom(pPline);
pRb = pPline->xData();
if (NULL != pRb)
{
pNew->setXData(pRb);
CKTCadUtility::FreeRbList(pRb);
}
//
iVert = 0;
pPline->getClosestPointTo(pt2, pt3);
pNew->addVertexAt(iVert, pt3.convert2d(plane));
++iVert;
//
pPline->getPointAt(iParam + 1, pt3);
pNew->addVertexAt(iVert, pt3.convert2d(plane));
++iVert;
pPline->getClosestPointTo(pt1, pt3);
pPline->setPointAt(iParam + 1, pt3.convert2d(plane));
//
while (Acad::eOk == pPline->getPointAt(iParam + 2, pt3))
{
pNew->addVertexAt(iVert, pt3.convert2d(plane));
++iVert;
pPline->removeVertexAt(iParam + 2);
}
// 加入数据库
CKTCadUtility::AddToCurrentSpace(pNew, idEnt);
pNew->close();
pPline->close();
// 保存id
arid.append(idEnt);
}
// 创建组
if (arid.length() > 1)
CKTCadUtility::CreateAcDbGroup(arid);
return TRUE;
}
double ScaletoDouble(CString sScale)
{
int nIndex = sScale.Find(':', 0);
double dDocScale = 1.0;
if (nIndex != -1)
{
dDocScale = _ttof(sScale.Mid(nIndex + 1)) / _ttof(sScale.Mid(0, nIndex));
}
return dDocScale;
}
bool isModuleLoaded(LPCTSTR str)
{
AcDbVoidPtrArray* pApps = reinterpret_cast<AcDbVoidPtrArray*>(acrxLoadedApps());
if (pApps == NULL)
return false;
bool bFound = false;
for (int i = 0; i < pApps->length(); i++)
{
if (_tcsicmp(reinterpret_cast<LPCTSTR>(pApps->at(i)), str) == 0)
{
bFound = true;
break;
}
}
for (; pApps->length() > 0;)
{
delete reinterpret_cast<LPTSTR>(pApps->at(0));
pApps->removeAt(0);
}
delete pApps;
return bFound;
}
int DrawGraph(AcDbObjectIdArray & idArray, CMapStringToString & mapVarToValue, AcGePoint3d& ptC, double dscale, double& dAngle, CString pszType, BOOL bMove, BOOL bScale, BOOL bRotate)
{
KTParamService* pService = GetKTParamService();
if (NULL == pService)
{
acutPrintf(_T("\n参数化服务不存在, 请先加载参数化模块!"));
return RTERROR;
}
GetKTParamService()->InitService();
//
// 获得参数化设备对象图元
AcDbVoidPtrArray arpPart;
if (!pService->CreateParamPart(arpPart, mapVarToValue, pszType))
{
acutPrintf(_T("参数化设备创建失败, 可能没有找到指定设备或者数据参数不足!"));
return RTERROR;
}
//
if (0 == arpPart.length())
{
acutPrintf(_T("\n参数化设备不存在图形元素定义!"));
return RTNONE;
}
// 放大
AcGeMatrix3d mat, mat2;
mat.setToScaling(dscale);
mat2.setToRotation(dAngle, AcGeVector3d::kZAxis);
AcDbEntity* pEnt;
int iPos = arpPart.length();
while ((--iPos) >= 0)
{
pEnt = (AcDbEntity*)arpPart[iPos];
ASSERT(NULL != pEnt);
pEnt->transformBy(mat*mat2);
}
// 拖放创建的参数化设备图元- AcGePoint3d::kOrigin
CKTEntityDragMgr drag(AcGePoint3d::kOrigin, arpPart, TRUE);
BOOL bBlock = FALSE;
BOOL bGroup = TRUE;
drag.SetDragPoint(ptC, TRUE);
drag.EnableMove(bMove);
drag.EnableScale(bScale);
drag.EnableRotate(bRotate);
BOOL nB = drag.DoDrag();
if (nB)
{
// 做块
if (bBlock)
{
AcDbObjectId id = CKTCadUtility::CreateBlockTableRecord(arpPart, drag.GetDragPoint());
AcDbBlockReference *pRef = new AcDbBlockReference(drag.GetDragPoint(), id);
ASSERT(NULL != pRef);
CKTCadUtility::AddToBlockTableRecord(pRef);
pRef->close();
}
// 做组
else if (bGroup)
{
drag.append(idArray);
CKTCadUtility::CreateAcDbGroup(idArray);
dAngle = drag.GetDragValue();
}
// 打散
else
{
drag.append();
}
}
return 1;
}
int GetPipeAngle(double & dAngle, AcGeVector3d & vc)
{
vc.normalize();
dAngle = vc.angleTo(AcGeVector3d::kXAxis, -AcGeVector3d::kZAxis);
if (dAngle > PI / 2 && dAngle <= PI)
{
dAngle = dAngle - PI;
vc = -vc;
}
else if (dAngle > PI&&dAngle <= 3 * PI / 2)
{
dAngle = dAngle - PI;
vc = -vc;
}
else if (dAngle > 3 * PI / 2 && dAngle <= 2 * PI)
{
dAngle = dAngle - 2 * PI;
}
return 0;
}
AcDbObjectId GetGroupId(AcDbObjectId objId)
{
AcDbObjectId persObjId;
AcDbObject *pEnt;
if (Acad::eOk != acdbOpenObject(pEnt, objId, AcDb::kForRead)) {
acutPrintf(_T("\nCannot open entity."));
return AcDbObjectId::kNull;
}
AcDbDictionary *pGroup;
const AcDbVoidPtrArray *pReactors;
pReactors = pEnt->reactors();
if (pReactors == NULL) {
pEnt->close();
return AcDbObjectId::kNull;
}
pEnt->close();
int length = pReactors->length();
void *pSomething;
for (int i = 0; i < length; ++i)
{
pSomething = (AcDbObject*)pReactors->at(i);
if (acdbIsPersistentReactor(pSomething)) {
// Every group reactor is a persistent reactor.
// Is this a reactor from a group?
persObjId = acdbPersistentReactorObjectId(pSomething);
AcDbObject *pReactor;
if (Acad::eOk != acdbOpenObject(pReactor, persObjId, AcDb::kForRead)) {
// acutPrintf("\nCannot get reactor.");
continue;
}
if (pReactor->isKindOf(AcDbGroup::desc())) {
// This is a group reactor. Get the group name.
AcDbObjectId groupId = pReactor->ownerId();
if (Acad::eOk != acdbOpenObject(pGroup, groupId, AcDb::kForRead)) {
// acutPrintf("\nCannot open group.");
pReactor->close();
continue;
}
LPTSTR groupName;
if (Acad::eOk != (pGroup->nameAt(persObjId, groupName))) {
// acutPrintf("\nCannot get group name.");
pReactor->close();
pGroup->close();
continue;
}
pGroup->close();
}
pReactor->close();
}
}
return persObjId;
}
AcDbObjectId GetObjectId(AcGePoint3d pt)
{
ads_name ss, entres;
ads_point pt1, pt2;
AcDbObjectId id;
struct resbuf* pResbuf = acutBuildList(RTDXF0, _T("LWPOLYLINE,POINT,CIRCLE,ARC,LINE,ELLIPSE"), NULL);
pt1[X] = pt.x;
pt1[Y] = pt.y;
pt1[Z] = pt.z;
acdbWcs2Ucs(pt1, pt1, false);
ads_point_set(pt1, pt2);
double dAperture = CKTCadUtility::GetApertureSize();
pt1[X] -= dAperture;
pt1[Y] += dAperture;
pt2[X] += dAperture;
pt2[Y] -= dAperture;
actrTransactionManager->flushGraphics();//这样就可以选择刚建立的pline了.
if (acedSSGet(_T("_C"), pt1, pt2, pResbuf, ss) == RTNORM)
{
acedSSName(ss, 0, entres);
if (acdbGetObjectId(id, entres) != Acad::eOk)
{
acedSSFree(ss);
acedSSFree(entres);
return AcDbObjectId::kNull;
}
acedSSFree(entres);
acedSSFree(ss);
acutRelRb(pResbuf);
return id;
}
acedSSFree(ss);
acutRelRb(pResbuf);
return AcDbObjectId::kNull;
}
int ConnectParamCompare(const void *pParam1, const void *pParam2)
{
return ((((PID::CConnectData*)pParam1)->dParam < ((PID::CConnectData*)pParam2)->dParam) ? -1 : 1);
}
BOOL OnConnectPolyline(AcDbPolyline* pPline1, BOOL bStart1, AcDbPolyline* pPline2, BOOL bStart2)
{
AcGePoint2d pt;
int iPos = (bStart2 ? 1 : pPline2->numVerts() - 2);
if (Acad::eOk != pPline2->getPointAt(iPos, pt))
return FALSE;
(bStart2 ? ++iPos : --iPos);
pPline1->setPointAt((bStart1 ? 0 : pPline1->numVerts() - 1), pt);
while (Acad::eOk == pPline2->getPointAt(iPos, pt))
{
(bStart2 ? ++iPos : --iPos);
pPline1->addVertexAt((bStart1 ? 0 : pPline1->numVerts()), pt);
}
pPline2->erase();
return TRUE;
}
BOOL OnConnectPolylines(const AcDbObjectId& idEnt1, const AcDbObjectId& idEnt2, const AcGePoint3d ptNear)
{
double dLeft1, dRight1;
AcDbObjectIdArray arid1;
FindPipePlines(idEnt1, arid1, dLeft1, dRight1);
double dLeft2, dRight2;
AcDbObjectIdArray arid2;
FindPipePlines(idEnt2, arid2, dLeft2, dRight2);
int iLen1 = arid1.length();
int iLen2 = arid2.length();
// 没有找到曲线或数目不同,返回
if (iLen1 <= 0 || iLen1 != iLen2)
return FALSE;
// 取得排序方向
PID::CConnectData data;
AcGePoint3d pt1, pt2;
if (Acad::eOk != acdbOpenObject(data.pPline, arid1[0], AcDb::kForRead))
return FALSE;
data.pPline->getStartPoint(pt1);
data.pPline->getEndPoint(pt2);
if (ptNear.distanceTo(pt1) < ptNear.distanceTo(pt2))
data.pPline->getPointAt(1, pt2);
else
data.pPline->getPointAt(data.pPline->numVerts() - 2, pt1);
AcGeVector3d vtDir((pt2 - pt1).normal());
vtDir.rotateBy(PI / 2.0, data.pPline->normal());
data.pPline->close();
AcDbXline cXLine;
cXLine.setBasePoint(ptNear);
cXLine.setUnitDir(vtDir);
int iPos = iLen1;
PID::CConnectDataArray arData1, arData2;
while ((--iPos) >= 0)
{
if (Acad::eOk != acdbOpenObject(data.pPline, arid1[iPos], AcDb::kForWrite))
break;
data.pPline->getStartPoint(pt1);
data.pPline->getEndPoint(pt2);
pt1 = ((data.bStart = (ptNear.distanceTo(pt1) < ptNear.distanceTo(pt2))) ? pt1 : pt2);
cXLine.getClosestPointTo(pt1, pt2);
cXLine.getParamAtPoint(pt2, data.dParam);
arData1.append(data);
if (Acad::eOk != acdbOpenObject(data.pPline, arid2[iPos], AcDb::kForWrite))
break;
data.pPline->getStartPoint(pt1);
data.pPline->getEndPoint(pt2);
pt1 = ((data.bStart = (ptNear.distanceTo(pt1) < ptNear.distanceTo(pt2))) ? pt1 : pt2);
cXLine.getClosestPointTo(pt1, pt2);
cXLine.getParamAtPoint(pt2, data.dParam);
arData2.append(data);
}
BOOL bCanLink = TRUE;
iLen1 = arData1.length();
iLen2 = arData2.length();
if (iLen1 > 0 && iLen1 == iLen2)
{
// 在同一方向上排序
iPos = iLen1;
qsort(arData1.asArrayPtr(), iPos, sizeof(PID::CConnectData), ConnectParamCompare);
qsort(arData2.asArrayPtr(), iPos, sizeof(PID::CConnectData), ConnectParamCompare);
// 判断图层线型是否一致
while ((--iPos) >= 0 && bCanLink)
{
bCanLink = (arData1[iPos].pPline->layerId() == arData2[iPos].pPline->layerId()
&& arData1[iPos].pPline->linetypeId() == arData2[iPos].pPline->linetypeId());
}
// 连接曲线
iPos = iLen1;
while ((--iPos) >= 0 && bCanLink)
{
OnConnectPolyline(arData1[iPos].pPline, arData1[iPos].bStart, arData2[iPos].pPline, arData2[iPos].bStart);
}
}
while ((--iLen1) >= 0)
arData1[iLen1].pPline->close();
while ((--iLen2) >= 0)
arData2[iLen2].pPline->close();
return bCanLink;
}
int InsertValve(AcGePoint3d ptGeOn1, CValveDlg& dlg, CString stext, AcGePoint3d pts, AcGePoint3d pte, BOOL nB)
{
GetKTParamService()->InitService();
double dAngle = 0.0;
double dAngle1 = 0.0;
CMapStringToString mapVarToValue;
AcDbObjectId id;
AcDbObjectIdArray arid;
mapVarToValue.SetAt(_T("Spec"), dlg.m_sSpec);
mapVarToValue.SetAt(_T("Line"), dlg.m_sLineno);
mapVarToValue.SetAt(_T("Tag"), _T("阀门"));
mapVarToValue.SetAt(_T("Type"), dlg.m_sValveType);
mapVarToValue.SetAt(_T("Name"), dlg.m_sValvename);
mapVarToValue.SetAt(_T("DN"), dlg.m_sDn);
mapVarToValue.SetAt(_T("Face"), dlg.m_sFace);
CString sPress;
sPress.Format(_T("%.1f"), dlg.m_dPress);
mapVarToValue.SetAt(_T("Ps"), sPress);
if (nB)
{
AcGeVector3d vc = pte - pts;
GetPipeAngle(dAngle, vc);
CString sTemp;
sTemp.Format(_T("%f"), dAngle);
mapVarToValue.SetAt(_T("VC"), sTemp);
dAngle1 = dAngle;
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext, 0, 0, 0);
if (dlg.m_nInterF == 1)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle1, _T("P-Vfg"), 0, 0, 0);
arid.append(id);
}
else if (dlg.m_nInterF == 2)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle1, _T("P-Vsw"), 0, 0, 0);
}
}
else
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext, 0, 0, 1);
if (dlg.m_nInterF == 1)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, _T("P-Vfg"), 0, 0, 0);
}
else if (dlg.m_nInterF == 2)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, _T("P-Vsw"), 0, 0, 0);
}
CString sTemp;
sTemp.Format(_T("%f"), dAngle);
mapVarToValue.SetAt(_T("VC"), sTemp);
}
return 0;
}
int InsertValve1(AcGePoint3d ptGeOn1, CValveDlg& dlg, CString stext, AcGePoint3d pts, AcGePoint3d pte, BOOL nB)
{
GetKTParamService()->InitService();
double dAngle = 0.0;
double dAngle1 = 0.0;
CMapStringToString mapVarToValue;
AcDbObjectIdArray arid;
CString stext1;
if (nB)
{
AcGeVector3d vc = pte - pts;
GetPipeAngle(dAngle, vc);
dAngle1 = dAngle;
if (dlg.m_nInterF == 0)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext, 0, 0, 0);
}
else if (dlg.m_nInterF == 1)
{
stext1.Format(_T("%s1"), stext);
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle1, stext1, 0, 0, 0);
}
else if (dlg.m_nInterF == 2)
{
stext1.Format(_T("%s2"), stext);
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle1, stext1, 0, 0, 0);
}
}
else
{
if (dlg.m_nInterF == 0)
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext, 0, 0, 1);
}
else if (dlg.m_nInterF == 1)
{
stext1.Format(_T("%s1"), stext);
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext1, 0, 0, 1);
}
else if (dlg.m_nInterF == 2)
{
stext1.Format(_T("%s2"), stext);
DrawGraph(arid, mapVarToValue, ptGeOn1, dlg.m_dScale, dAngle, stext1, 0, 0, 1);
}
}
return 0;
}
int InsertSEqu(LPCTSTR spName, LPCTSTR spValvename, double dPipeW, double dScale, double dbreak)
{
AcGePoint3d ptGeOn1, pts, pte;
int nresult = acedGetPoint(NULL, _T("\n选择插入点:"), asDblArray(ptGeOn1));
if (nresult != RTNORM) return 0;
int npipe = -1;
CString sLineno, sDn, sSpec;
AcDbObjectId id;
BOOL nB = FindPipeCen(ptGeOn1, id, npipe, dPipeW, pts, pte, sLineno, sDn, sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
if (dbreak > 0)
{
BreakPIDPipe(id, ptGeOn1, dbreak);
}
GetKTParamService()->InitService();
double dAngle = 0.0;
double dAngle1 = 0.0;
CMapStringToString mapVarToValue;
AcDbObjectIdArray arid;
CString sss = spValvename;
mapVarToValue.SetAt(_T("Tag"), _T("阀门"));
mapVarToValue.SetAt(_T("Name"), sss);
mapVarToValue.SetAt(_T("DN"), sDn);
if (nB)
{
AcGeVector3d vc = pte - pts;
GetPipeAngle(dAngle, vc);
CString sTemp;
sTemp.Format(_T("%f"), dAngle);
mapVarToValue.SetAt(_T("VC"), sTemp);
dAngle1 = dAngle;
DrawGraph(arid, mapVarToValue, ptGeOn1, dScale, dAngle, spName, 0, 0, 0);
}
else
{
DrawGraph(arid, mapVarToValue, ptGeOn1, dScale, dAngle, spName, 0, 0, 1);
CString sTemp;
sTemp.Format(_T("%f"), dAngle);
mapVarToValue.SetAt(_T("VC"), sTemp);
}
return 0;
}
int InsertCap(LPCTSTR spName, LPCTSTR spValvename, double dScale)
{
AcGePoint3d ptGeOn1, pts, pte;
int nresult = acedGetPoint(NULL, _T("\n选择插入点:"), asDblArray(ptGeOn1));
if (nresult != RTNORM) return 0;
int npipe = -1;
CString sLineno, sDn, sSpec;
AcDbObjectId id;
GetKTParamService()->InitService();
double dAngle = 0.0;
double dAngle1 = 0.0;
CMapStringToString mapVarToValue;
AcDbObjectIdArray arid;
CString sss = spValvename;
mapVarToValue.SetAt(_T("Tag"), _T("阀门"));
mapVarToValue.SetAt(_T("Name"), sss);
mapVarToValue.SetAt(_T("DN"), sDn);
DrawGraph(arid, mapVarToValue, ptGeOn1, dScale, dAngle, spName, 0, 0, 1);
CString sTemp;
sTemp.Format(_T("%f"), dAngle);
mapVarToValue.SetAt(_T("VC"), sTemp);
return 0;
}
BOOL KTPipeDimTxt(CString& sTopDimTxt, CString& sBomDimTxt, AcGePoint3d & ptGeIn, double dPipeW, AcGeVector3d& vc, double& dangle)
{
AcDbObjectId idpipe;
int nresult = acedGetPoint(NULL, _T("\n选择插入点:"), asDblArray(ptGeIn));
if (nresult != RTNORM) return FALSE;
ads_point ptC[2];
ads_point_set(asDblArray(ptGeIn), ptC[0]);
ads_point_set(asDblArray(ptGeIn), ptC[1]);
ptC[0][X] -= CoreTools::PixelToWcs(10);
ptC[0][Y] -= CoreTools::PixelToWcs(10);
ptC[1][X] += CoreTools::PixelToWcs(10);
ptC[1][Y] += CoreTools::PixelToWcs(10);
ads_name ssname, ent;
acedSSGet(_T("C"), ptC[0], ptC[1], NULL, ssname);
Adesk::Int32 lLen = 0;
acedSSLength(ssname, &lLen);
AcDbEntity* pEnt = NULL;
AcDbObjectId id;
for (int i = 0; i < lLen; i++)
{
acedSSName(ssname, i, ent);
if (Acad::eOk == acdbGetObjectId(id, ent))
{
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForRead))
{
AecDbObjXDataMap objXData;
if (objXData.Read(pEnt, PIDPIPE_APP))
{
AcDbPolyline * pPline = AcDbPolyline::cast(pEnt);
if (pPline != NULL) //如果是PL则管道为单线
{
AcGePoint3d pt, pts, pte;
pPline->getClosestPointTo(ptGeIn, pt);
// 去点所在处参数值
double dParam;
pPline->getParamAtPoint(pt, dParam);
// 取前后节点
int iParam = int(dParam);
pPline->getPointAtParam(iParam, pts);
pPline->getPointAtParam(iParam + 1, pte);
vc = pte - pts;
GetPipeAngle(dangle, vc);
pPline->close();
pEnt->close();
if (!PIDLineTools::FormatPIDPipeDimTxt(id, sTopDimTxt, sBomDimTxt))
{
acutPrintf(_T("\n请选择管道中心线!"));
return FALSE;
}
return TRUE;
}
}
else
{
pEnt->close();
continue;
}
}
}
}
acedSSFree(ssname);
return FALSE;
}
BOOL GetValveDim(AcGePoint3d& ptBase, CString &sTxtT, CString &sTxtB, double &dAngle)
{
AcDbObjectId idTemp;
CString sContent;
idTemp = GetObjectId(ptBase);
AcDbObjectId idGroup = GetGroupId(idTemp);
if (idGroup != AcDbObjectId::kNull)
{
AcDbGroup* pGroup = NULL;
acdbOpenObject(pGroup, idGroup, AcDb::kForRead);
AcDbGroupIterator* pIter = pGroup->newIterator();
//AcDbObject* pObj;
AecDbObjXDataMap objXData;
for (; !pIter->done(); pIter->next())
{
idTemp = pIter->objectId();
if (objXData.Read(idTemp, _T("KTParamPart")))
{
objXData.GetAt(_T("点类型"), sContent);
if (sContent.CompareNoCase(_T("材料点")) == 0)
{
objXData.GetAt(_T("名称"), sContent);
if (sContent.CompareNoCase(_T("阀门")) == 0)
{
objXData.GetAt(_T("类型"), sTxtT);
objXData.GetAt(_T("公称直径"), sTxtB);
CString sAngle;
objXData.GetAt(_T("角度"), sAngle);
dAngle = _ttof(sAngle);
sTxtB = _T("DN") + sTxtB;
AcDbPoint * pPoint;
acdbOpenObject(pPoint, idTemp, AcDb::kForRead);
if (pPoint != NULL)
{
ptBase = pPoint->position();
pPoint->close();
}
delete pIter;
pGroup->close();
return TRUE;
}
}
}
}
delete pIter;
pGroup->close();
}
return FALSE;
}
int GETINITdata(double & dPipeW, double &dscale)
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sPipeW, sScale;
if (!InitValve(sqlDb, xInitDataMap))
{
return 0;
}
xInitDataMap.GetAt(DOC_PIDMPIPE1W, sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE, sScale);
dPipeW = _ttof(sPipeW);
dscale = _ttof(sScale);
return 1;
}
}
void PI_CJYB()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade, sPro, sWeldD, sPipeD, sScale, sPipeW;
if (!InitValve(sqlDb, xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT, sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W, sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE, sScale);
double dPipeW = _ttof(sPipeW);
double dL = _ttof(sScale);
int npipe = -1;
AcDbObjectId id;
AcGePoint3d ptGeOn1, pts, pte;
CString sLineno = _T("");
CString sDn = _T("");
CString sSpec = _T("");
int nresult = acedGetPoint(NULL, _T("\n选择插入点:"), asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1, id, npipe, dPipeW, pts, pte, sLineno, sDn, sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno = sLineno;
dlg.m_sDn = sDn;
dlg.m_sSpec = sSpec;
dlg.m_sProname = sPro;
dlg.m_sValveType = _T("加压泵");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal == 2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id, ptGeOn1, dbreak);
InsertValve(ptGeOn1, dlg, _T("P-JYPump"), pts, pte, nB);
return;
}
void PL_KTPIDVGate()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_sValveType=_T("闸阀");
dlg.m_dScale = _ttof(sScale);
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VGate"),pts,pte,nB);
return;
}
void PL_KTPIDVGlobe()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
dPipeW = 5;
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("截止阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VGlobe"),pts,pte,nB);
return;
}
void PL_KTPIDVBall()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("球阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VBall"),pts,pte,nB);
return;
}
void PL_KTPIDVCheck1()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("止回阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VCheck1"),pts,pte,nB);
return;
}
void PL_KTPIDVCheck2()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("止回阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VCheck2"),pts,pte,nB);
return;
}
void PL_KTPIDVButt()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("蝶阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VButter"),pts,pte,nB);
return;
}
void PL_KTPIDVInst()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("调节阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VInst"),pts,pte,nB);
return;
}
void PL_KTPIDVHydr()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("疏水阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VHydr"),pts,pte,nB);
return;
}
void PL_KTPIDV3V()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("三通阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve1(ptGeOn1,dlg,_T("P-V3V"),pts,pte,nB);
return;
}
void PL_KTPIDV4V()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("四通阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve1(ptGeOn1,dlg,_T("P-V4V"),pts,pte,nB);
return;
}
void PL_KTPIDVAngle()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("角阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
InsertValve1(ptGeOn1,dlg,_T("P-VAngle"),pts,pte,nB);
return;
}
void PL_KTPIDVRelif()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("安全阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
InsertValve1(ptGeOn1,dlg,_T("P-VRelif"),pts,pte,nB);
return;
}
void PL_KTPIDVDiaph()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("隔膜阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VDiaph"),pts,pte,nB);
return;
}
void PL_KTPIDVDes()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("减压阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VDes"),pts,pte,nB);
return;
}
void PL_KTPIDVNeedle()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("针型阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VNeedle"),pts,pte,nB);
return;
}
void PL_KTPIDVClose()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("常闭阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VClose"),pts,pte,nB);
return;
}
void PL_KTPIDVPlug()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("旋塞阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
double dbreak = dlg.m_dScale;
if (dlg.m_nInterF == 1)
{
dbreak *= 1.2;
}
BreakPIDPipe(id,ptGeOn1,dbreak);
InsertValve(ptGeOn1,dlg,_T("P-VPlug"),pts,pte,nB);
return;
}
void PL_KTPIDVGroup1()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("闸阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
InsertValve(ptGeOn1,dlg,_T("P-VGate"),pts,pte,nB);
return;
}
void PL_KTPIDVGroup2()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("闸阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
InsertValve(ptGeOn1,dlg,_T("P-VGate"),pts,pte,nB);
return;
}
void PL_KTPIDVGroup3()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectId id;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptGeOn1));
if (nresult != RTNORM) return;
BOOL nB = FindPipeCen(ptGeOn1,id,npipe,dPipeW,pts,pte,sLineno,sDn,sSpec); //是管子dPipeW是线宽,npipe是单双线属性等
CAcModuleResourceOverride myResources;
CValveDlg dlg;
dlg.m_dScale = dL;
GET_CACHE(%s%f, &dlg.m_sValvename, &dlg.m_dScale);
dlg.m_sLineno=sLineno;
dlg.m_sDn=sDn;
dlg.m_sSpec=sSpec;
dlg.m_sProname=sPro;
dlg.m_dScale = _ttof(sScale);
dlg.m_sValveType=_T("闸阀");
dlg.SetADOServer(&sqlDb);
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
SET_CACHE(%s%f, dlg.m_sValvename, dlg.m_dScale);
InsertValve(ptGeOn1,dlg,_T("P-VGate"),pts,pte,nB);
return;
}
void PL_KTPIDVDim1()
{
double dpipew,dtxtH,dtxtW,dScale;
AecDbObjXDataMap xInitDataMap;
AcDbObjectId idtxt;
CUIISQLiteServer sqlDb;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDMPIPE1W,dpipew);
xInitDataMap.GetAt(DOC_PIDVALVTXTH,dtxtH);
xInitDataMap.GetAt(DOC_PIDVALVTXTF,dtxtW);
xInitDataMap.GetAt(DOC_VALVESCALE,dScale);
AcGePoint3d ptBase,pton,ptdown;
CString sTxtT,sTxtB;
double dAngle;
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptBase));
if (nresult != RTNORM) return;
if (GetValveDim(ptBase,sTxtT,sTxtB,dAngle))
{
AcGeVector3d vc,vcy;
if (fabs(dAngle) - 0.000001 < 0 )
{
vc.set(1,0,0);
}
else
{
vc.set(0,1,0);
}
vcy=vc;
vcy.rotateBy(PI_2,AcGeVector3d::kZAxis);
vc.normalize();
vcy.normalize();
pton= ptBase + vcy*(dScale*0.25 + DIMOFFSET);
ptdown= ptBase - vcy*(dScale*0.25 + DIMOFFSET);
AcDbObjectId idTxtStyle = AcDbObjectId::kNull;
AcDbObjectId idLayer = AcDbObjectId::kNull;
//AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg());
idTxtStyle=KTSetting::InitTextStyle(_T("VALVE_DIM"));
idLayer=KTSetting::InitLayer(_T("LAY_VALVE_DIM"));
AcDbMText* ptext = new AcDbMText();
ptext->setTextStyle(idTxtStyle);
ptext->setTextHeight(dtxtH);
ptext->setAttachment(AcDbMText::kBottomCenter);
ptext->setLocation(pton);
#if (ARX > 15)
ptext->setLocation(pton);
#else
ptext->setAlignmentPoint(pton);
#endif // (ARX> 15)
ptext->setLayer(idLayer);
ptext->setContents(sTxtT);
ptext->setRotation(dAngle);
if (Acad::eOk != CKTCadUtility::AddToCurrentSpace(ptext,idtxt))
{
ptext->close();
return;
}
ptext->close();
ptext = new AcDbMText();
ptext->setTextStyle(idTxtStyle);
ptext->setTextHeight(dtxtH);
ptext->setAttachment(AcDbMText::kTopCenter);
ptext->setLocation(ptdown);
#if (ARX> 15)
ptext->setLocation(ptdown);
#else
ptext->setAlignmentPoint(ptdown);
#endif // (ARX> 15)
ptext->setLayer(idLayer);
ptext->setContents(sTxtB);
ptext->setRotation(dAngle);
if (Acad::eOk != CKTCadUtility::AddToCurrentSpace(ptext,idtxt))
{
ptext->close();
return;
}
ptext->close();
}
return;
}
void PL_KTPIDVDim2()
{
double dpipew,dtxtH,dtxtW,dScale;
AecDbObjXDataMap xInitDataMap;
AcDbObjectId idtxt;
CUIISQLiteServer sqlDb;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDMPIPE1W,dpipew);
xInitDataMap.GetAt(DOC_PIDVALVTXTH,dtxtH);
xInitDataMap.GetAt(DOC_PIDVALVTXTF,dtxtW);
xInitDataMap.GetAt(DOC_VALVESCALE,dScale);
AcGePoint3d ptBase,pton,ptdown;
CString sTxtT,sTxtB;
double dAngle;
int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptBase));
if (nresult != RTNORM) return;
if (GetValveDim(ptBase,sTxtT,sTxtB,dAngle))
{
AcGeVector3d vc,vcy;
if (fabs(dAngle) - 0.000001 < 0 )
{
vc.set(1,0,0);
}
else
{
vc.set(0,1,0);
}
vcy=vc;
vcy.rotateBy(PI_2,AcGeVector3d::kZAxis);
vc.normalize();
vcy.normalize();
pton= ptBase + vcy*(dScale*0.25 + DIMOFFSET);
ptdown= ptBase - vcy*(dScale*0.25 + DIMOFFSET);
AcDbObjectId idTxtStyle = AcDbObjectId::kNull;
AcDbObjectId idLayer = AcDbObjectId::kNull;
//AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg());
idTxtStyle=KTSetting::InitTextStyle(_T("VALVE_DIM"));
idLayer=KTSetting::InitLayer(_T("LAY_VALVE_DIM"));
AcDbMText* ptext = new AcDbMText();
ptext->setTextStyle(idTxtStyle);
ptext->setTextHeight(dtxtH);
ptext->setAttachment(AcDbMText::kBottomCenter);
ptext->setLocation(pton);
#if (ARX> 15)
ptext->setLocation(pton);
#else
ptext->setAlignmentPoint(pton);
#endif // (ARX> 15)
ptext->setLayer(idLayer);
ptext->setContents(sTxtT);
ptext->setRotation(dAngle);
if (Acad::eOk != CKTCadUtility::AddToCurrentSpace(ptext,idtxt))
{
ptext->close();
return;
}
ptext->close();
}
return;
}
void PL_KTPIDHandV()
{
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
CString sTrade,sPro,sWeldD,sPipeD,sScale,sPipeW;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDPROJECT,sPro);
xInitDataMap.GetAt(DOC_PIDMPIPE1W,sPipeW);
xInitDataMap.GetAt(DOC_VALVESCALE,sScale);
double dPipeW=_ttof(sPipeW);
double dL=_ttof(sScale);
int npipe=-1;
AcDbObjectIdArray arid;
AcGePoint3d ptGeOn1,pts,pte;
CString sLineno=_T("");
CString sDn=_T("");
CString sSpec=_T("");
CAcModuleResourceOverride myResources;
CInstHandDlg dlg;
dlg.m_dScale=dL;
int nRetVal = dlg.DoModal();
if (nRetVal==2)
{
return;
}
GetKTParamService()->InitService();
double dAngle=0.0;
CString stext=_T("");
switch(dlg.m_nType)
{
case 0:
stext=_T("Hand1");
break;
case 1:
stext=_T("Hand2");
break;
case 2:
stext=_T("Hand3");
break;
case 3:
stext=_T("Hand4");
break;
case 4:
stext=_T("Hand5");
break;
case 5:
stext=_T("Hand6");
break;
case 6:
stext=_T("Hand7");
break;
case 7:
stext=_T("Hand8");
break;
default:
stext=_T("Hand1");
break;
}
CMapStringToString mapVarToValue;
DrawGraph(arid,mapVarToValue,ptGeOn1,dlg.m_dScale,dAngle,stext,1,0,1);
return;
}
////////小型设备
void PL_KTPID8MB1()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PID8MB1"),_T("8字盲板"),dPipeW,dscale,dscale*0.2);
}
return;
}
void PL_KTPID8MB2()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PID8MB2"),_T("8字盲板"),dPipeW,dscale,dscale*0.2);
}
return;
}
void PL_KTPIDMB()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDMB"),_T("盲板"),dPipeW,dscale,dscale*0.2);
}
return;
}
void PL_KTPIDTfilter()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDTfilter"),_T("T型过滤器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDWfilter()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDWfilter"),_T("网状型过滤器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDYfilter()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDYfilter"),_T("Y型过滤器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDZfilter()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDZfilter"),_T("针形型过滤器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDSHIJING()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDSHIJING"),_T("玻璃管试镜"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDJBQ()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDJBQ"),_T("搅拌器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDJTHHQ()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDJTHHQ"),_T("静态混合器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDLD()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDLD"),_T("料斗"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDLouD()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDLouD"),_T("漏斗"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDWLouD()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDWLouD"),_T("污油漏斗"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDMBQYCool()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDMBQYCool"),_T("密闭取样冷却器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDQYCool()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDQYCool"),_T("取样冷却器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDPSQ()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDPSQ"),_T("喷射器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDWEN()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDWEN"),_T("文丘里"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDXQZ()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDXQZ"),_T("吸气罩"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDXSQ()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDXSQ"),_T("消声器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDKong()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDKong"),_T("限流孔板"),dPipeW,dscale,dscale*0.2);
}
return;
}
void PL_KTPIDNFire()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertSEqu(_T("PIDNFire"),_T("阻火器"),dPipeW,dscale,dscale);
}
return;
}
void PL_KTPIDCAP()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertCap(_T("PIDCAP"),_T("封头"),dscale);
}
return;
}
void PL_KTPIDNODE()
{
double dPipeW,dscale;
if (1 == GETINITdata(dPipeW,dscale))
{
InsertCap(_T("PIDNODE"),_T("堵头"),dscale);
}
return;
}
void PI_MTO()
{
CString dbPath = FilePath::GetSysDir();
dbPath += _T("\\Plumbing.db");
CUIISQLiteServer sqlDb;
if (!sqlDb.InitADOServer(dbPath))
{
acutPrintf(_T("\n初始化数据库Plumbing.db失败!"));
return;
}
KTMtoTool mto;
mto.SetDbSrv(&sqlDb);
mto.DoMto();
}
void PL_KTPIDVDEL()
{
KTCADSysVar<int> var(_T("PICKSTYLE"), 1);
KTCADSysVar<int> osmode(_T("OSMODE"), 0);
int nRes = 0;
ads_name ss, ent;
AcDbEntity* pEnt = NULL;
AcDbObjectId id, id1, id2;
ads_point pt1, pt2, pt3, pt4;
struct resbuf* pRbFence = NULL;
struct resbuf* pRb = acutBuildList(RTDXF0, _T("POINT,LINE,LWPOLYLINE,SOLID"), NULL);
while(TRUE)
{
nRes = acedGetPoint(NULL, _T("\n请拾取删除范围对角点<退出>:"), pt1);
if (nRes != RTNORM)
break;
nRes = acedGetCorner(pt1, _T("\n请选择删除范围<退出>:"), pt2);
if (nRes != RTNORM)
break;
nRes = acedSSGet(_T("W"), pt1, pt2, pRb, ss);
if (nRes != RTNORM )
break;
Adesk::Int32 lPos = 0l;
acedSSLength(ss, &lPos);
while ((--lPos) >= 0)
{
acedSSName(ss, lPos, ent);
acdbGetObjectId(id, ent);
if (Acad::eOk == acdbOpenAcDbEntity(pEnt, id, AcDb::kForWrite))
{
pEnt->erase();
pEnt->close();
}
}
acedSSFree(ss);
pt3[X] = pt1[X];
pt3[Y] = pt2[Y];
pt3[Z] = pt2[Z];
pt4[X] = pt2[X];
pt4[Y] = pt1[Y];
pt4[Z] = pt1[Z];
pRbFence = acutBuildList(RT3DPOINT, pt1, RT3DPOINT, pt3, NULL);
nRes = acedSSGet(_T("F"), pRbFence, NULL, NULL, ss);
acutRelRb(pRbFence);
if (nRes == RTNORM)
{
acedSSName(ss, 0, ent);
acdbGetObjectId(id1, ent);
acedSSFree(ss);
}
pRbFence = acutBuildList(RT3DPOINT, pt2, RT3DPOINT, pt4, NULL);
nRes = acedSSGet(_T("F"), pRbFence, NULL, NULL, ss);
acutRelRb(pRbFence);
if (nRes == RTNORM)
{
acedSSName(ss, 0, ent);
acdbGetObjectId(id2, ent);
acedSSFree(ss);
}
if (id1.isValid() && id2.isValid())
{
acdbUcs2Wcs(pt1, pt1, false);
acdbUcs2Wcs(pt2, pt2, false);
OnConnectPolylines(id1, id2, CKTCadUtility::GetMiddlePoint(asPnt3d(pt1), asPnt3d(pt2)));
}
else
{
pRbFence = acutBuildList(RT3DPOINT, pt1, RT3DPOINT, pt4, NULL);
nRes = acedSSGet(_T("F"), pRbFence, NULL, NULL, ss);
acutRelRb(pRbFence);
if (nRes == RTNORM)
{
acedSSName(ss, 0, ent);
acdbGetObjectId(id1, ent);
acedSSFree(ss);
}
pRbFence = acutBuildList(RT3DPOINT, pt2, RT3DPOINT, pt3, NULL);
nRes = acedSSGet(_T("F"), pRbFence, NULL, NULL, ss);
acutRelRb(pRbFence);
if (nRes == RTNORM)
{
acedSSName(ss, 0, ent);
acdbGetObjectId(id2, ent);
acedSSFree(ss);
}
if (id1.isValid() && id2.isValid())
{
acdbUcs2Wcs(pt1, pt1, false);
acdbUcs2Wcs(pt2, pt2, false);
OnConnectPolylines(id1, id2, CKTCadUtility::GetMiddlePoint(asPnt3d(pt1), asPnt3d(pt2)));
}
}
}
acutRelRb(pRb);
return;
}
void PL_KTPIDONLINE()
{
CString sTxtT,sTxtB;
AcGeVector3d vc,vcy;
AcGePoint3d ptBase,pton,ptdown,ptgraphic;
double dpipew,dangle,dtxtH,dtxtW;
AcDbObjectId idtxt,idLayer;
int npipe=1,nDimType=0;
AecDbObjXDataMap xInitDataMap;
CUIISQLiteServer sqlDb;
if(!InitValve(sqlDb,xInitDataMap))
{
return;
}
xInitDataMap.GetAt(DOC_PIDMPIPE1W,dpipew);
xInitDataMap.GetAt(DOC_PIDDIMTXTH,dtxtH);
xInitDataMap.GetAt(DOC_PIDDIMTXTF,dtxtW);
if (!KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dangle))
{
return;
}
vcy=vc;
vcy.rotateBy(PI_2,AcGeVector3d::kZAxis);
vc.normalize();
vcy.normalize();
pton= ptBase + vcy*(dpipew*0.5 + DIMOFFSET);
ptdown= ptBase - vcy*(dpipew*0.5 + DIMOFFSET);
AcDbObjectId idTxtStyle = AcDbObjectId::kNull;
//AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg());
idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim"));
idLayer=KTSetting::InitLayer(_T("LAY_PIPE_DIM"));
AcDbMText* ptext = new AcDbMText();
ptext->setTextStyle(idTxtStyle);
ptext->setTextHeight(dtxtH);
ptext->setAttachment(AcDbMText::kBottomCenter);
ptext->setLocation(pton);
#if (ARX> 15)
ptext->setLocation(pton);
#else
ptext->setAlignmentPoint(pton);
#endif // (ARX> 15)
ptext->setLayer(idLayer);
ptext->setContents(sTxtT);
ptext->setRotation(dangle);
if (Acad::eOk != CKTCadUtility::AddToCurrentSpace(ptext,idtxt))
{
ptext->close();
return;
}
ptext->close();
return;
}