#include "stdafx.h" #include "resource.h" #include "CKTDimUtility.h" #include "KTPipeOper.h" #include "KTFitting.h" #include "KTDimLeaderJig.h" #include "KTObjLifeMgr.h" #include "KTSideJig.h" #include "KTGeUtility.h" #include "CoreTools.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif namespace { BOOL ElDescr2EveryOne(CString& sText, CString& sEl, CString& sTopEl, CString& sCenEl, CString& sBomEl) { //--|--|-- int nLen = sText.GetLength(); if (nLen == 0) return FALSE; int nIndex = sText.Find(KT_SEPARATOR_CHAR, 0); sEl = sText.Mid(0, nIndex); sText.SetAt(nIndex, KT_SUBTRACT_CHAR); //'-' int nIndex1 = nIndex; nIndex = sText.Find(KT_SEPARATOR_CHAR, 0); //'|' if (nIndex != -1) { sTopEl = sText.Mid(nIndex1 + 1, nIndex - nIndex1 - 1); sText.SetAt(nIndex, KT_SUBTRACT_CHAR); } nIndex1 = nIndex; nIndex = sText.Find(KT_SEPARATOR_CHAR, 0); if (nIndex != -1) { sCenEl = sText.Mid(nIndex1 + 1, nIndex - nIndex1 - 1); sText.SetAt(nIndex, KT_SUBTRACT_CHAR); } nIndex1 = nIndex; nIndex = sText.Find(KT_SEPARATOR_CHAR, 0); if (nIndex != -1) { sBomEl = sText.Mid(nIndex1 + 1, nIndex - nIndex1 - 1); sText.SetAt(nIndex, KT_SUBTRACT_CHAR); return TRUE; } return FALSE; } } void PL_KTPDIMONLINE() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId idtxt,idLayer; int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return; } vcy=vc; vcy.rotateBy(PI_2,AcGeVector3d::kZAxis); vc.normalize(); vcy.normalize(); pton= ptBase + vcy*(dpipew*0.5 + 40); ptdown= ptBase - vcy*(dpipew*0.5 + 40); if (npipe==1) { pton= ptBase + vcy*(dpipedn*0.5 + 40); ptdown= ptBase - vcy*(dpipedn*0.5 + 40); } AcDbObjectId idTxtStyle = AcDbObjectId::kNull; //AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_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); CKTDimUtility::addToModelSpace(ptext,idtxt); 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); CKTDimUtility::addToModelSpace(ptext,idtxt); return; } void PL_KTPDIMONLINET() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId idtxt,idLayer; int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return; } vcy=vc; vcy.rotateBy(PI_2,AcGeVector3d::kZAxis); vc.normalize(); vcy.normalize(); pton= ptBase + vcy*(dpipew*0.5 + 40); ptdown= ptBase - vcy*(dpipew*0.5 + 40); if (npipe==1) { pton= ptBase + vcy*(dpipedn*0.5 + 40); ptdown= ptBase - vcy*(dpipedn*0.5 + 40); } AcDbObjectId idTxtStyle = AcDbObjectId::kNull; //AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_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); CKTDimUtility::addToModelSpace(ptext,idtxt); return; } void PL_KTPDIMONLINEB() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId idtxt,idLayer; int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return; } vcy=vc; vcy.rotateBy(PI_2,AcGeVector3d::kZAxis); vc.normalize(); vcy.normalize(); pton= ptBase + vcy*(dpipew*0.5 + 40); ptdown= ptBase - vcy*(dpipew*0.5 + 40); if (npipe==1) { pton= ptBase + vcy*(dpipedn*0.5 + 40); ptdown= ptBase - vcy*(dpipedn*0.5 + 40); } AcDbObjectId idTxtStyle = AcDbObjectId::kNull; //AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM")); AcDbMText* 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); CKTDimUtility::addToModelSpace(ptext,idtxt); return; } void PL_KTDIMGRA() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId idtxt,idLayer,idLine; int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return; } vcy=vc; vcy.rotateBy(PI_2,AcGeVector3d::kZAxis); vc.normalize(); vcy.normalize(); pton= ptBase + vcy*(dpipew*0.5 + 40); ptdown= ptBase - vcy*(dpipew*0.5 + 40); if (npipe==1) { pton= ptBase + vcy*(dpipedn*0.5 + 40); ptdown= ptBase - vcy*(dpipedn*0.5 + 40); } double dw = 5.0; CString sTip; sTip.Format(_T("\n<输入坡度值(%g)>:"),dw); double dw1 = 0.0; int nresult = acedGetReal(sTip, &dw1); if (nresult == RTNONE) { dw1 = dw; } sTxtT.Format(_T("%g%%"),dw1); AcDbObjectId idTxtStyle = AcDbObjectId::kNull; // AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_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); CKTDimUtility::addToModelSpace(ptext,idtxt); AcGePoint3d pt1,pt2,pt3; pt1=pton + vc*dtxtW*2; pt3=pt1 + vc*dtxtW*2; pt2=pt3 + vcy*dtxtH; AcDbPolyline * pPl= new AcDbPolyline; pPl->addVertexAt(0,CKTDimUtility::P3d_to_P2d(pt1)); pPl->addVertexAt(1,CKTDimUtility::P3d_to_P2d(pt2)); pPl->addVertexAt(2,CKTDimUtility::P3d_to_P2d(pt3)); pPl->addVertexAt(3,CKTDimUtility::P3d_to_P2d(pt1)); pPl->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPl,idLine); return; } void PL_KTPDIMLEADER() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return ; } AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,0,sTxtT,sTxtB,_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); return; } void PL_KTPDIMLEADERT() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return ; } AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,0,sTxtT,_T(""),_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); return; } void PL_KTPDIMLEADERY() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dangle,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return ; } AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,1,sTxtT,sTxtB,_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); return; } void PL_KTPDIMLEADERYT() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dtxtH,dangle,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nl=CKTDimUtility::KTPipeDimTxt(sTxtT,sTxtB,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return ; } AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,1,sTxtT,_T(""),_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); return; } void PL_KTPDIMPLINE() { double dpipew,dH,dW; int ndimtype=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dH,dW,ndimtype); AcDbObjectId idTxtStyle = AcDbObjectId::kNull; //AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); AcDbObjectId idLayer = AcDbObjectId::kNull; idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM")); ads_point adsPt; AcGePoint3d pt,pt1,ptTemp,ptTemp1,pttextT1; CString sTopDimTxt,sBomDimTxt,sTexttemp; struct resbuf rb; acedGetVar(_T("ORTHOMODE"), &rb); int nOldOther = rb.resval.rint; //设置系统正交 rb.restype = RTSHORT; rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); acedInitGet(RSG_NOZERO,NULL); CString sTip = _T("\n请选择开始点:"); int nResult = acedGetPoint(NULL, sTip, adsPt); AcDbPolyline * pPLine = NULL; AcGePoint3dArray arptsIns; CStringArray arstext; if(nResult == RTNORM) { pPLine = new AcDbPolyline; pt = asPnt3d(adsPt); pPLine->addVertexAt(0,CKTDimUtility::P3d_to_P2d(pt)); AcDbObjectId idPLine = AcDbObjectId::kNull; int nCount = 0; while(nResult == RTNORM) { pt1=asPnt3d(adsPt); nCount = pPLine->numVerts(); sTip = _T("\n请拾取标线下一点:"); nResult = acedGetPoint(adsPt, sTip, adsPt); if(nResult == RTNORM) { pt = asPnt3d(adsPt); ptTemp = pt; if(idPLine != AcDbObjectId::kNull) { acdbOpenObject(pPLine,idPLine,AcDb::kForWrite); } pPLine->addVertexAt(nCount,CKTDimUtility::P3d_to_P2d(pt)); ads_name adsSS,ename; AcDbObjectId idEnt; AcGePoint3d ptinsert; Adesk::Int32 lLen; CString stext,stextbot; acedSSGet(_T("C"),asDblArray(pt1), adsPt, NULL, adsSS); acedSSLength(adsSS, &lLen); for(long lIndex = 0;lIndex < lLen;lIndex ++) { acedSSName(adsSS,lIndex,ename); acdbGetObjectId(idEnt, ename); if (idEnt ==AcDbObjectId::kNull) { continue; } AcDbEntity* pEnt = NULL; if (Acad::eOk == acdbOpenAcDbEntity(pEnt,idEnt,AcDb::kForRead)) { //1.读扩展数据 AecDbObjXDataMap xData1; xData1.Read(pEnt,PIDPIPE_APP); //2.扩展数据转为pipe参数结构 WPipe::PipeParam param1; KTFitting::XData2PipeParam(¶m1,&xData1, NULL); //判断是管件或管子类型 int nKind = -1; xData1.GetAt(PIPE_FITTING,nKind); KTFitting::Fitting eType = (KTFitting::Fitting)nKind; if (eType == KTFitting::kPipe) //是管子等 { sTopDimTxt=_T(""); sBomDimTxt=_T(""); PIDLineTools::FormatPipeDimTxt(pEnt,sTopDimTxt,sBomDimTxt); CKTDimUtility::SetELDrawgraphic(sTopDimTxt); //替换标高图形字符 ptinsert=CKTDimUtility::GetIntersectWith(pt1,pt,pEnt); arptsIns.append(ptinsert); arstext.Add(sTopDimTxt); pEnt->close(); continue; } else { pEnt->close(); continue; } } } acedSSFree(ename); acedSSFree(adsSS); AcDbLine linesort(pt1, pt); KTGeUtility::SortPoints(arptsIns, &linesort); if(idPLine != AcDbObjectId::kNull) { pPLine->close(); } else { CKTDimUtility::addToModelSpace(pPLine,idPLine); } } else { if(nCount < 2) { delete pPLine; pPLine = NULL; } } } ////////////// int nF=0; AcDbObjectId idPline; for(int i = 0;iaddVertexAt(0,CKTDimUtility::P3d_to_P2d(ptBase1)); pPLine->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptBase2)); pPLine->setConstantWidth(10); pPLine->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPLine,idPLine); //写序号,画小斜线 CString snum; snum.Format(_T("%d"),i+1); AcDbMText * pText = new AcDbMText; vcyT.rotateBy(PI/4,AcGeVector3d::kZAxis); vcyT.normalize(); ptBase += vcyT*150; ptBase =ptBase - vcx*dW; pText->setLocation(ptBase); pText->setTextHeight(dH); #if (ARX > 15) pText->setLocation(ptBase); #else pText->setAlignmentPoint(ptBase); #endif // (ARX > 15) pText->setAttachment(AcDbMText::kBottomLeft); pText->setRotation(0.0); pText->setContents(snum); pText->setLayer(idLayer); pText->setTextStyle(idTxtStyle); AcDbObjectId idText; CKTDimUtility::addToModelSpace(pText,idText); //上标注 ptnum=pt - vcx*dW; ptnumT =ptnum + vcy*20; pttext=pt + vcx*dW; pttextT = pttext + vcy*20; pText = new AcDbMText; pText->setLocation(ptnumT); pText->setTextHeight(dH); #if (ARX > 15) pText->setLocation(ptnumT); #else pText->setAlignmentPoint(ptnumT); #endif // (ARX > 15) pText->setAttachment(AcDbMText::kBottomLeft); pText->setRotation(0.0); pText->setContents(snum); pText->setLayer(idLayer); pText->setTextStyle(idTxtStyle); CKTDimUtility::addToModelSpace(pText,idText); sTexttemp = _T(""); sTexttemp=arstext.GetAt(i); AcDbMText* ptext = new AcDbMText; ptext->setTextHeight(dH); ptext->setAttachment(AcDbMText::kBottomLeft); ptext->setLocation(pttextT); #if (ARX > 15) ptext->setLocation(pttextT); #else ptext->setAlignmentPoint(pttextT); #endif // (ARX > 15) ptext->setContents(sTexttemp); ptext->setRotation(0.0); ptext->setLayer(idLayer); ptext->setTextStyle(idTxtStyle); CKTDimUtility::addToModelSpace(ptext,idText); int nlen = CKTDimUtility::GetDimTextLen(sTexttemp); ptnumend = ptnum + vcx * dW * (nlen + 1); pPLine = new AcDbPolyline; pPLine->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptnum)); pPLine->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptnumend)); pPLine->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPLine,idPLine); pt=pt + vcy*dH*2; } AcGeVector3d vcy =AcGeVector3d::kYAxis; ptTemp1=ptTemp + vcy*dH*1.5*i; pPLine=new AcDbPolyline; pPLine->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptTemp)); pPLine->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptTemp1)); pPLine->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPLine,idPline); } return; } void PL_KTPDIMSIDEH() { double dpipew,dH,dW; AecDbObjXDataMap xInitDataMap; int ndimtype=0; CKTDimUtility::Getinit(xInitDataMap,dpipew,dH,dW,ndimtype); AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 AcDbObjectId id; AcGePoint3dArray arDimpts; CStringArray arstext; arstext.RemoveAll(); CKTDimUtility::Pipedimside(arDimpts,arstext); int nLen = arstext.GetSize(); int nLen1 = arDimpts.length(); if(nLen==nLen1&&nLen>0) { AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTSideJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(arDimpts,dH,dW,arstext,0,_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); } else { AfxMessageBox(_T("请框选标注管道的端点!")); } return; } void PL_KTPDIMSIDEV() { double dpipew,dH,dW; AecDbObjXDataMap xInitDataMap; int ndimtype=0; CKTDimUtility::Getinit(xInitDataMap,dpipew,dH,dW,ndimtype); AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 AcDbObjectId id; AcGePoint3dArray arDimpts; CStringArray arstext; arstext.RemoveAll(); CKTDimUtility::Pipedimside(arDimpts,arstext); int nLen = arstext.GetSize(); int nLen1 = arDimpts.length(); if(nLen==nLen1&&nLen>0) { AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTSideJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(arDimpts,dH,dW,arstext,1,_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); } else { AfxMessageBox(_T("请框选标注管道的端点!")); } return; } void PL_KTDIMPIPEEL() { if (!CoreTools::hasCSSZ(true)) return; CString sTxtT,sTxtB,seltype,sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipedn,dpipew,dpipedl,dangle,dtxtH,dtxtW; AcDbObjectId idtxt,idTxtStyle,idLayer; AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_DPLOTWIDTH,dpipedl); xDataMap.GetAt(DOC_DIMTXTH,dtxtH); xDataMap.GetAt(DOC_DIMTXTF,dtxtW); xDataMap.GetAt(DOC_ELTYPE,seltype); int nELType=0; CString sELDes,sUseEL,sUseELT,sUseELC,sUseELB; xDataMap.GetAt(DOC_ELDESCR,sELDes); xDataMap.GetAt(DOC_ELTYPE,nELType); xDataMap.GetAt(DOC_SCALE,sScale); dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); dtxtH=dtxtH*CKTDimUtility::ScaletoDouble(sScale); dtxtW=dtxtW*dtxtH; //KTPipeOper 管线操作类 int npipe=1; int nEL=0; int nl=CKTDimUtility::KTPipeDimTxtEL(sTxtB,nEL,ptBase,dpipew,vc,dpipedn,dangle,npipe); if (nl==0) { return; } switch(_ttoi(seltype)) { case 0: { sTxtT.Format(_T("^%d^%s"),nEL,sTxtB); CKTDimUtility::SetELDrawgraphic(sTxtT); } break; case 1: { if (nEL==0) { sTxtT=PIPE_TOP_EL + sTxtB; } else if (nEL==1) { sTxtT=PIPE_CEN_EL + sTxtB; } else if (nEL==2) { sTxtT=PIPE_BOM_EL + sTxtB; } else if (nEL==3) { sTxtT=PIPE_EL + sTxtB; } } break; case 2: { ElDescr2EveryOne(sELDes,sUseEL,sUseELT,sUseELC,sUseELB); if (nEL==0) { sTxtT=sUseELT + sTxtB; } else if (nEL==1) { sTxtT=sUseELC + sTxtB; } else if (nEL==2) { sTxtT=sUseELB + sTxtB; } else if (nEL==3) { sTxtT=sUseEL + sTxtB; } } default: break; } vcy=vc; vcy.rotateBy(PI_2,AcGeVector3d::kZAxis); vc.normalize(); vcy.normalize(); pton= ptBase + vcy*(dpipew*0.5 + 40); ptdown= ptBase - vcy*(dpipew*0.5 + 40); if (npipe==1) { pton= ptBase + vcy*(dpipedn*0.5 + 40); ptdown= ptBase - vcy*(dpipedn*0.5 + 40); } //AcDbSymbolUtilities::getTextStyleId(idTxtStyle,_T("Pipe_Dim"),acdbCurDwg()); idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_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); CKTDimUtility::addToModelSpace(ptext,idtxt); return; } void PL_KTDimValveEL() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipew,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectIdArray idarray; idarray.setLogicalLength(0); struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptBase)); if (nresult != RTNORM) return; if (CKTDimUtility::GetValveEL(ptBase,sTxtT) == 1) { AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,0,sTxtT,_T(""),_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); return; } return; } void PL_KTDIMVALVE() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipew,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectIdArray idarray; idarray.setLogicalLength(0); struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nOsModeOld(0); CKTCadUtility::GetSystemVar(_T("OSMODE"),nOsModeOld); CKTCadUtility::SetSystemVar(_T("OSMODE"), 547); int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptBase)); if (nresult != RTNORM) { CKTCadUtility::SetSystemVar(_T("OSMODE"),nOsModeOld); return; } CKTCadUtility::SetSystemVar(_T("OSMODE"),nOsModeOld); CoreTools::UCS2WCS(ptBase, ptBase); if (CKTDimUtility::GetValveDim(ptBase,sTxtT,sTxtB)==1) { AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; sTxtB = _T("DN") + sTxtB; if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,0,sTxtT,sTxtB,_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); return; } return; } void PL_KTDIMVALVE1() { CString sTxtT,sTxtB; AcGeVector3d vc,vcy; AcGePoint3d ptBase,pton,ptdown,ptgraphic; double dpipew,dtxtH,dtxtW; AcDbObjectId id=AcDbObjectId::kNull; AcDbObjectIdArray idarray; idarray.setLogicalLength(0); struct resbuf rb; rb.restype = RTSHORT; rb.resval.rint = 0; acedSetVar(_T("ORTHOMODE"), &rb); int npipe=1,nDimType=0; AecDbObjXDataMap xInitDataMap; CKTDimUtility::Getinit(xInitDataMap,dpipew,dtxtH,dtxtW,nDimType); int nresult = acedGetPoint(NULL,_T("\n选择插入点:"),asDblArray(ptBase)); if (nresult != RTNORM) return; CoreTools::UCS2WCS(ptBase, ptBase); if (CKTDimUtility::GetValveDim(ptBase,sTxtT,sTxtB)==1) { AcDbObjectId idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM"));//获得图层 AcDbObjectId idSt=KTSetting::InitTextStyle(_T("Pipe_Dim"));//获得文字样式 AcDbObjectIdArray arid; arid.setLogicalLength(0); CKTObjLifeMgr entMgr; CKTObjLifeMgr entGroupMgr; KTDimLeaderJig SteelJig; AcDbVoidPtrArray arpEnt; sTxtT.Format(_T("%s DN%s"),sTxtT,sTxtB); if (!SteelJig.DragCreate(ptBase,dtxtH,dtxtW,0,sTxtT,_T(""),_T("\n选择第二点:"),idSt,idLayer,arpEnt)) return; entMgr.Add(arpEnt); entMgr.AddToBlockTableRecord(arid); entGroupMgr.Add(arid); acTransactionManagerPtr()->flushGraphics(); acedUpdateDisplay(); entGroupMgr.Release(); CKTDimUtility::DrawArrow(ptBase,SteelJig.m_ptDynamic,nDimType,idLayer,id); return; } return; } void PL_KTCElev() { if (!CoreTools::hasCSSZ(true)) return; CString sTxtT,sTxtB,seltype,sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,ptstar,ptend,ptgraphic,pt,pttext,pt1,pt2; double dpipew,dpipedl,dtxtH,dtxtW; AcDbObjectId idText,idTxtStyle,idLayer,idpline; AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_DPLOTWIDTH,dpipedl); xDataMap.GetAt(DOC_DIMTXTH,dtxtH); xDataMap.GetAt(DOC_DIMTXTF,dtxtW); xDataMap.GetAt(DOC_ELTYPE,seltype); int nELType=0; CString sELDes,sUseEL,sUseELT,sUseELC,sUseELB; xDataMap.GetAt(DOC_ELDESCR,sELDes); xDataMap.GetAt(DOC_ELTYPE,nELType); xDataMap.GetAt(DOC_SCALE,sScale); dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); dtxtH=dtxtH*CKTDimUtility::ScaletoDouble(sScale); dtxtW=dtxtW*dtxtH; struct resbuf rb; acedGetVar(_T("ORTHOMODE"), &rb); int nOldOther = rb.resval.rint; //设置系统正交 rb.restype = RTSHORT; rb.resval.rint = 1; acedSetVar(_T("ORTHOMODE"), &rb); ads_point adsPt; acedInitGet(RSG_NOZERO,NULL); CString sTip = _T("\n请拾取标线起点:"); int nResult = acedGetPoint(NULL, sTip, adsPt); double delev; int nResult1 = acedGetReal(_T("\n请输入标高初始值:"),&delev); CString selev; selev.Format(_T("%g"),delev); int nl=selev.GetLength(); if(nResult == RTNORM) { AcDbMText * pText = new AcDbMText; AcDbPolyline* pPline; CString stext; AcGeVector3d vcx(1,0,0),vcy(0,1,0); switch(_ttoi(seltype)) { case 0: { sTxtT=DIM_EL + selev; } break; case 1: { sTxtT=PIPE_EL + selev; } break; case 2: { ElDescr2EveryOne(sELDes,sUseEL,sUseELT,sUseELC,sUseELB); sTxtT=sUseEL + selev; } break; } pt=asPnt3d(adsPt); pttext=pt + vcx*dtxtW*0.2;// + vcx*dWidth; pttext=pttext + vcy*dtxtH*0.2;//+ vcx*dWidth; idTxtStyle=KTSetting::InitTextStyle(_T("Pipe_Dim")); idLayer=CKTDimUtility::SetLayer(_T("LAY_PIPE_DIM")); pText->setTextStyle(idTxtStyle); pText->setLocation(pttext); pText->setTextHeight(dtxtH); #if (ARX > 15) pText->setLocation(pttext); #else pText->setAlignmentPoint(pttext); #endif // (ARX > 15) pText->setAttachment(AcDbMText::kBottomLeft); pText->setRotation(0.0); pText->setLayer(idLayer); pText->setContents(sTxtT); CKTDimUtility::addToModelSpace(pText,idText); pt1=asPnt3d(adsPt); ptstar=pt;// - vcy*dHeight*0.2; ptend=ptstar + vcx*(nl+1)*dtxtW; pPline = new AcDbPolyline; pPline->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptstar)); pPline->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptend)); pPline->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPline,idpline); while(nResult == RTNORM) { sTip = _T("\n请拾取标线下一点:"); nResult = acedGetPoint(adsPt, sTip, adsPt); if(nResult == RTNORM) { double dnextelev=(asPnt3d(adsPt)).y - pt1.y; dnextelev = dnextelev + delev; selev.Format(_T("%g"),dnextelev); nl=selev.GetLength(); switch(_ttoi(seltype)) { case 0: { sTxtT=DIM_EL + selev; } break; case 1: { sTxtT=PIPE_EL + selev; } break; case 2: { ElDescr2EveryOne(sELDes,sUseEL,sUseELT,sUseELC,sUseELB); sTxtT=sUseEL + selev; } break; } pt=asPnt3d(adsPt); pttext=pt + vcx*dtxtH*0.2;//+ vcx*dWidth; pttext=pttext + vcy*dtxtH*0.2;//+ vcx*dWidth; pText = new AcDbMText; pText->setTextStyle(idTxtStyle); pText->setLocation(pttext); pText->setTextHeight(dtxtH); #if (ARX > 15) pText->setLocation(pttext); #else pText->setAlignmentPoint(pttext); #endif // (ARX > 15) pText->setAttachment(AcDbMText::kBottomLeft); pText->setRotation(0.0); pText->setLayer(idLayer); pText->setContents(sTxtT); CKTDimUtility::addToModelSpace(pText,idText); ptstar=pt;// - vcy*dHeight*0.2; ptend=ptstar + vcx*(nl+1)*dtxtW; pPline = new AcDbPolyline; pPline->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptstar)); pPline->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptend)); pPline->setLayer(idLayer); CKTDimUtility::addToModelSpace(pPline,idpline); } } } return; } void PL_KTPDIR() { if (!CoreTools::hasCSSZ(true)) return; CString sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,ptstar,ptend,ptnext; double dpipew,dpipedl; AcDbObjectId idpipe,idLayer; idLayer=CKTDimUtility::SetLayer(_T("LAY_FITTING")); acdbCurDwg()->setClayer(idLayer); AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_DPLOTWIDTH,dpipedl); int nELType=0,npipe=0; xDataMap.GetAt(DOC_SCALE,sScale); dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); int nresult = acedGetPoint(NULL,_T("\n请在管道上选择插入点:"),asDblArray(ptBase)); if (nresult != RTNORM) return; if (CKTDimUtility::FindPipeCenPt(ptBase,idpipe,npipe,dpipew+5,ptstar,ptend)) { AecDbObjXDataMap xData1; xData1.Read(idpipe,PIDPIPE_APP); //2.扩展数据转为pipe参数结构 WPipe::PipeParam param1; KTFitting::XData2PipeParam(¶m1,&xData1, NULL); CString sdn,sValveEL; xData1.GetAt(PIPE_DN,sdn);//公称直径 double dstar = ptBase.distanceTo(ptstar); double dend = ptBase.distanceTo(ptend); AcGeVector3d vTemp; AcDbObjectIdArray idGroup; if (dstar > dend) { if (dend==0) { vTemp = ptend - ptstar ; } else { vTemp = ptend - ptBase; } vTemp.normalize(); ptnext = ptend + vTemp *50; CKTDimUtility::DrowPBreak(ptend,ptnext,_ttof(sdn),1,1,idGroup); } else { if (dstar==0) { vTemp = ptstar - ptend ; } else { vTemp = ptstar - ptBase; } vTemp.normalize(); ptnext = ptstar + vTemp *50; CKTDimUtility::DrowPBreak(ptstar,ptnext,_ttof(sdn),1,1,idGroup); } AcDbObjectId idBreakGroup = AcDbObjectId::kNull; CKTDimUtility::CreateGroup(idGroup,_T(""),idBreakGroup); //编组给组 return; } else { acedAlert(_T("没有选中管道")); return; } return; } void PL_KTPCROSS() { if (!CoreTools::hasCSSZ(true)) return; CString sTxtT,sTxtB,seltype,sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,ptstar,ptend,ptInt,ptBase2,ptstar2,ptend2; double dpipew,dBreak; AcDbObjectId idpipe,idpipe2; AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_ELTYPE,seltype); int npipe=0; xDataMap.GetAt(DOC_BREAKSPACE,dBreak); xDataMap.GetAt(DOC_SCALE,sScale); dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); dBreak=dBreak*CKTDimUtility::ScaletoDouble(sScale); int nresult = acedGetPoint(NULL,_T("\n请选择需要断开的下面的管道:"),asDblArray(ptBase)); if (nresult != RTNORM) return; nresult = acedGetPoint(NULL,_T("\n请选择与之相交的上面的管道:"),asDblArray(ptBase2)); if (nresult != RTNORM) return; if (CKTDimUtility::FindPipeCenPt(ptBase,idpipe,npipe,dpipew+5,ptstar,ptend)) { if (CKTDimUtility::FindPipeCenPt(ptBase2,idpipe2,npipe,dpipew+5,ptstar2,ptend2)) { AcDbPolyline *pPLine=new AcDbPolyline;//定义求交直线 pPLine->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptstar)); pPLine->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptend)); AcDbPolyline *pPLine2=new AcDbPolyline;//定义求交直线 pPLine2->addVertexAt(0,CKTDimUtility::P3d_to_P2d(ptstar2)); pPLine2->addVertexAt(1,CKTDimUtility::P3d_to_P2d(ptend2)); AcGePoint3dArray pts; pPLine->intersectWith(pPLine2,AcDb::kOnBothOperands,pts); delete pPLine2; delete pPLine; if (pts.logicalLength() > 0) { CString sdn; //if (npipe == 1 ) { AecDbObjXDataMap xData1; xData1.Read(idpipe2,PIDPIPE_APP); //2.扩展数据转为pipe参数结构 WPipe::PipeParam param1; KTFitting::XData2PipeParam(¶m1,&xData1, NULL); xData1.GetAt(PIPE_DN,sdn);//公称直径 dBreak += _ttof(sdn); //KTPipeOper::BreakPipe(pts.at(0),dBreak*0.5,idpipe); //改为遮挡 AcGeVector3d vt = ptend - ptstar; vt.normalize(); ptstar2 = pts.first() + dBreak * 0.5 * vt; ptend2 = pts.first() - dBreak * 0.5 * vt; AcDbObjectIdArray idGroup; CKTDimUtility::AddWipeOut(ptstar2,ptend2,_ttof(sdn),idGroup,FALSE); AcDbObjectId idBreakGroup = AcDbObjectId::kNull; CKTDimUtility::CreateGroup(idGroup,_T(""),idBreakGroup); //编组给组 //调整显示次序 #if ARX>16 AcDbObjectIdArray ids; ids.append(idpipe2); acedDrawOrderInherit(idpipe,ids,kDrawOrderAbove); acedDrawOrderInherit(idpipe,idGroup,kDrawOrderAbove); acedDrawOrderInherit(idpipe2,idGroup,kDrawOrderBelow); #endif SHacedCommand(RTSTR,_T("WIPEOUT"),RTSTR,_T("F"),RTSTR,_T("Off"),RTNONE); } return; } } else { acedAlert(_T("没有选中管道")); return; } } else { acedAlert(_T("没有选中管道")); return; } return; } void PL_KTPBREAK() { if (!CoreTools::hasCSSZ(true)) return; CString sTxtT,sTxtB,seltype,sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,ptstar,ptend,ptnext,ptBase2,ptDir; double dpipew,dpipedl; AcDbObjectId idpipe,idLayer; idLayer=CKTDimUtility::SetLayer(_T("LAY_FITTING")); acdbCurDwg()->setClayer(idLayer); AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_DPLOTWIDTH,dpipedl); xDataMap.GetAt(DOC_SCALE,sScale); int npipe=0; dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); int nresult = acedGetPoint(NULL,_T("\n请在管道上选择断开第一点:"),asDblArray(ptBase)); if (nresult != RTNORM) return; nresult = acedGetPoint(asDblArray(ptBase),_T("\n请在管道上选择断开第二点:"),asDblArray(ptBase2)); if (nresult != RTNORM) return; if (CKTDimUtility::FindPipeCenPt(ptBase,idpipe,npipe,dpipew+5,ptstar,ptend)) { AcDbCurve* pEnt = NULL; acdbOpenObject(pEnt,idpipe,AcDb::kForRead); if (pEnt != NULL) { pEnt->getClosestPointTo(ptBase2,ptBase2); pEnt->close(); } AecDbObjXDataMap xData1; xData1.Read(idpipe,PIDPIPE_APP); //2.扩展数据转为pipe参数结构 WPipe::PipeParam param1; KTFitting::XData2PipeParam(¶m1,&xData1, NULL); CString sdn,sValveEL; xData1.GetAt(PIPE_DN,sdn);//公称直径 xData1.GetAt(PIPE_DIR,ptDir);//公称直径 AcGeVector3d vc = ptDir.asVector(); AcGeVector3d vctemp = ptBase - ptBase2; double dangle = vc.angleTo(vctemp); if (Adesk::kTrue != vc.isParallelTo(vctemp)) { return; } AcGePoint3d ptmid=CKTDimUtility::Mid(ptBase,ptBase2); double dBreak = ptmid.distanceTo(ptBase); //改为wipeout遮挡 //KTPipeOper::BreakPipe(ptmid,dBreak,idpipe); AcDbObjectIdArray idGroup; CKTDimUtility::DrowPBreak(ptBase,ptmid,_ttof(sdn),1,1,idGroup); idLayer=CKTDimUtility::SetLayer(_T("LAY_FITTING")); acdbCurDwg()->setClayer(idLayer); CKTDimUtility::DrowPBreak(ptBase2,ptmid,_ttof(sdn),1,1,idGroup); //添加遮挡 CKTDimUtility::AddWipeOut(ptBase,ptBase2,_ttof(sdn),idGroup); //加入断开符号材料点 AcDbObjectId idMPt = KTSetting::InitLayer(_T("LAY_MPoint")); AcGePoint3d ptGeMid = CKTDimUtility::Mid(ptBase,ptBase2); double dLength = ptBase2.distanceTo(ptBase); AcDbPoint* pP1 = new AcDbPoint; pP1->setPosition(ptGeMid); pP1->setLayer(idMPt); xData1.SetAt(_T("点类型"),_T("材料点")); xData1.SetAt(_T("名称"),_T("管子")); xData1.SetAt(_T("标志"),_T("1")); xData1.SetAt(_T("长度"),dLength); xData1.Write(pP1,KTPARAMPART); CKTDimUtility::addToModelSpace(pP1,idMPt); idGroup.append(idMPt); AcDbObjectId idBreakGroup = AcDbObjectId::kNull; CKTDimUtility::CreateGroup(idGroup,_T(""),idBreakGroup); //编组给组 SHacedCommand(RTSTR,_T("WIPEOUT"),RTSTR,_T("F"),RTSTR,_T("Off"),RTNONE); return; } else { acedAlert(_T("没有选中管道")); return; } return; } void PL_KTPTEMP() { if (!CoreTools::hasCSSZ(true)) return; CString sScale; AcGeVector3d vc,vcy; AcGePoint3d ptBase,ptstar,ptend,ptnext; double dpipew,dpipedl; AcDbObjectId idpipe,idLayer; idLayer=CKTDimUtility::SetLayer(_T("LAY_FITTING")); acdbCurDwg()->setClayer(idLayer); AecDbObjXDataMap xDataMap; PIDLineTools::ReSet(xDataMap); if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT,xDataMap)) { acutPrintf(_T("\n系统未初始化!")); return; } xDataMap.GetAt(DOC_PLOTWIDTH,dpipew); xDataMap.GetAt(DOC_DPLOTWIDTH,dpipedl); int nELType=0,npipe=0; xDataMap.GetAt(DOC_SCALE,sScale); dpipew=dpipew*CKTDimUtility::ScaletoDouble(sScale); int nresult = acedGetPoint(NULL,_T("\n请在管道上选择插入点:"),asDblArray(ptBase)); if (nresult != RTNORM) return; if (CKTDimUtility::FindPipeCenPt(ptBase,idpipe,npipe,dpipew+5,ptstar,ptend)) { AecDbObjXDataMap xData1; xData1.Read(idpipe,PIDPIPE_APP); //2.扩展数据转为pipe参数结构 WPipe::PipeParam param1; KTFitting::XData2PipeParam(¶m1,&xData1, NULL); CString sdn,sTemp; AcGePoint3d ptDir,pt1,pt2; xData1.GetAt(PIPE_OD,sdn);//公称直径 xData1.GetAt(PIPE_INSTHICK,sTemp);//公称直径 xData1.GetAt(PIPE_DIR,ptDir);//矢量 AcGeVector3d vc = ptDir.asVector(); vc.normalize(); double dBreak=4*CKTDimUtility::ScaletoDouble(sScale); pt1=ptBase + vc*dBreak; pt2=ptBase - vc*dBreak; double dw=_ttof(sdn)+_ttof(sTemp); AcDbObjectIdArray ids; ids.setLogicalLength(0); CKTDimUtility::DrowPTemp(ids,pt1,ptBase,dw,1); CKTDimUtility::DrowPTemp(ids,pt2,ptBase,dw,0); AcDbObjectId idGroup = AcDbObjectId::kNull; CKTDimUtility::CreateGroup(ids,_T(""),idGroup); //编组给组 KTPipeOper::BreakPipe(ptBase,dBreak,idpipe); return; } else { acedAlert(_T("没有选中管道")); return; } return; }