- 积分
- 26737
- 明经币
- 个
- 注册时间
- 2007-4-24
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2015-10-5 21:49:39
|
显示全部楼层
高程点移位
- acDocManager->lockDocument(acDocManager->curDocument());
- int iosmode = 0;
- CDwgDatabaseUtil::GetVar(_T("osmode"), iosmode); // 获取捕捉状态值
- CDwgDatabaseUtil::setVar(_T("osmode"), 0); // 设置捕获关
- CDwgDatabaseUtil::setVar(_T("cmdecho"), 0); // 关闭回显
- acedCommand(RTSTR, _T("undo"), RTSTR, _T("be"), RTNONE);
- bool result = true;
- AcGePoint3dArray ptArray;
- ads_name ss;
- // 建立缓冲区链表
- AcDbObjectIdArray entIds;
- struct resbuf *rb, *retRb;
- CString myXdata = _T("202101");
- rb = acutBuildList(RTDXF0, _T("INSERT"), 2, _T("gc200"), RTNONE);
- if (CCassUtil::PromptSelectEnts(_T("X"), myXdata, rb, entIds))
- {
- long length = entIds.length();
- for (int i = 0; i < length; i++)
- {
- AcDbEntity *pEnt = NULL;
- if (acdbOpenObject(pEnt, entIds[i], AcDb::kForWrite) == Acad::eOk)
- {
- CString layerName = pEnt->layer(); //图层名
- AcGePoint2d zxPt, ysPt; // 文本的左下角点、右上角点
- AcDbBlockReference *pBlk = AcDbBlockReference::cast(pEnt);
- AcGePoint3d pt3d = pBlk->position();
- double ptz = pt3d.z;
- AcDbObjectIterator *pAttrIter = pBlk->attributeIterator();
- AcDbAttribute *pAttr = NULL;
- AcDbObjectId attrObjId = NULL;
- CString strHeight;
- AcGePoint3d AlimPt, textPt;
- attrObjId = pAttrIter->objectId();
- acdbOpenObject(pAttr, attrObjId, AcDb::kForWrite);
- strHeight = pAttr->textString();
- double hh = pAttr->height(); // 文字高度
- double ww = pAttr->widthFactor(); // 宽度比例系数
- double ll = CTextUtil::getTextLength(strHeight, hh, ww); // 文字长度
- AlimPt = pAttr->alignmentPoint(); // 对齐点
- textPt = pAttr->position(); // 文本的位置点(左下角点)
- AcGePoint3d yPt1 = CGePointUtil::PolarPoint(textPt, 0.0, ll); // 向右
- AcGePoint3d yPt2 = CGePointUtil::PolarPoint(yPt1, CMathUtil::PI() * 0.5, hh); // 向上
- zxPt = CConvertUtil::ToPoint2d(textPt); // 文本的位置点(左下角点)
- ysPt = CConvertUtil::ToPoint2d(yPt2); // 文本的位置点(右上角点)
- CViewUtil::Set(textPt, yPt2, 3);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(zxPt), asDblArray(ysPt), retRb, ss);
- if (rt != RTNORM)
- {
- pAttr->close();
- delete pAttrIter;
- pBlk->close();
- pEnt->close();
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- continue;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- AcGePoint2d ydPt1, ydPt2, xdPt1, xdPt2, xdPt3, xdPt4, xdPt5, xdPt6, xdPt7, xdPt8;
- if (result)
- {
- // 设定向下移动限制
- double xzLen = hh;
- double yLen = 0;
- while (yLen < xzLen)
- {
- yLen = yLen + hh * 0.25;
- ydPt1 = CGePointUtil::PolarPoint(zxPt, CMathUtil::PI() * 1.5, yLen);
- ydPt2 = CGePointUtil::PolarPoint(ysPt, CMathUtil::PI() * 1.5, yLen);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(ydPt1), asDblArray(ydPt2), retRb, ss);
- if (rt != RTNORM)
- {
- // 文本的位置点
- AcGePoint3d setPosPt(ydPt1.x, ydPt1.y, ptz);
- AcGePoint3d setAliPt = CGePointUtil::PolarPoint(setPosPt, CMathUtil::PI() * 0.5, hh * 0.5);
- pAttr->setHorizontalMode(AcDb::kTextLeft); // 左对齐
- pAttr->setVerticalMode(AcDb::kTextVertMid); // 左中
- pAttr->setPosition(setPosPt);
- pAttr->setAlignmentPoint(setAliPt);
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- break;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- }
- }
- if (result)
- {
- // 设定向左移动限制
- double yzLen = hh * 4;
- double yLen = 0;
- while (yLen < yzLen)
- {
- yLen = yLen + hh * 0.25;
- xdPt1 = CGePointUtil::PolarPoint(ydPt1, CMathUtil::PI(), yLen);
- xdPt2 = CGePointUtil::PolarPoint(ydPt2, CMathUtil::PI(), yLen);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(xdPt1), asDblArray(xdPt2), retRb, ss);
- if (rt != RTNORM)
- {
- AcGePoint3d setPosPt(xdPt1.x, xdPt1.y, ptz);
- AcGePoint3d setAliPt = CGePointUtil::PolarPoint(setPosPt, CMathUtil::PI() * 0.5, hh * 0.5);
- pAttr->setHorizontalMode(AcDb::kTextLeft); // 左对齐
- pAttr->setVerticalMode(AcDb::kTextVertMid); // 左中
- pAttr->setPosition(setPosPt);
- pAttr->setAlignmentPoint(setAliPt);
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- break;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- }
- }
- if (result)
- {
- // 设定向上移动限制
- double yzLen = hh * 2;
- double yLen = 0;
- while (yLen < yzLen)
- {
- yLen = yLen + hh * 0.25;
- xdPt3 = CGePointUtil::PolarPoint(xdPt1, CMathUtil::PI() * 0.5, yLen);
- xdPt4 = CGePointUtil::PolarPoint(xdPt2, CMathUtil::PI() * 0.5, yLen);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(xdPt3), asDblArray(xdPt4), retRb, ss);
- if (rt != RTNORM)
- {
- AcGePoint3d setPosPt(xdPt3.x, xdPt3.y, ptz);
- AcGePoint3d setAliPt = CGePointUtil::PolarPoint(setPosPt, CMathUtil::PI() * 0.5, hh * 0.5);
- pAttr->setHorizontalMode(AcDb::kTextLeft);
- pAttr->setVerticalMode(AcDb::kTextVertMid);
- pAttr->setPosition(setPosPt);
- pAttr->setAlignmentPoint(setAliPt);
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- break;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- }
- }
- if (result)
- {
- // 设定向右移动限制
- double yzLen = hh * 4;
- double yLen = 0;
- while (yLen < yzLen)
- {
- yLen = yLen + hh * 0.25;
- xdPt5 = CGePointUtil::PolarPoint(xdPt3, 0.0, yLen);
- xdPt6 = CGePointUtil::PolarPoint(xdPt4, 0.0, yLen);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(xdPt5), asDblArray(xdPt6), retRb, ss);
- if (rt != RTNORM)
- {
- AcGePoint3d setPosPt(xdPt5.x, xdPt5.y, ptz);
- AcGePoint3d setAliPt = CGePointUtil::PolarPoint(setPosPt, CMathUtil::PI() * 0.5, hh * 0.5);
- pAttr->setHorizontalMode(AcDb::kTextLeft);
- pAttr->setVerticalMode(AcDb::kTextVertMid);
- pAttr->setPosition(setPosPt);
- pAttr->setAlignmentPoint(setAliPt);
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- break;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- }
- }
- if (result)
- {
- // 设定向下移动限制
- double yzLen = hh;
- double yLen = 0;
- while (yLen < yzLen)
- {
- yLen = yLen + hh * 0.25;
- xdPt7 = CGePointUtil::PolarPoint(xdPt5, CMathUtil::PI() * 1.5, yLen);
- xdPt8 = CGePointUtil::PolarPoint(xdPt6, CMathUtil::PI() * 1.5, yLen);
- retRb = acutBuildList(-4, _T("<NOT"), 2, _T("GC200"), -4, _T("NOT>"), RTNONE);
- int rt = acedSSGet(_T("C"), asDblArray(xdPt7), asDblArray(xdPt8), retRb, ss);
- if (rt != RTNORM)
- {
- AcGePoint3d setPosPt(xdPt7.x, xdPt7.y, ptz);
- AcGePoint3d setAliPt = CGePointUtil::PolarPoint(setPosPt, CMathUtil::PI() * 0.5, hh * 0.5);
- pAttr->setHorizontalMode(AcDb::kTextLeft);
- pAttr->setVerticalMode(AcDb::kTextVertMid);
- pAttr->setPosition(setPosPt);
- pAttr->setAlignmentPoint(setAliPt);
- acutRelRb(retRb);
- acedSSFree(ss);
- result = false;
- break;
- }
- else
- {
- acutRelRb(retRb);
- acedSSFree(ss);
- result = true;
- }
- }
- if (result)
- {
- ptArray.append(pt3d);
- }
- }
- pAttr->close();
- delete pAttrIter;
- pBlk->close();
- pEnt->close();
- }
- }
- acutRelRb(rb);
- if (ptArray.length() > 0)
- {
- CLayerUtil::Add(_T("检查"), 1);
- int i = 0;
- for (i; i < ptArray.length(); i++)
- {
- AcGeVector3d vec(0, 0, 1);
- AcDbCircle *pCircle = new AcDbCircle(ptArray[i], vec, 2.0);
- pCircle->setLayer(_T("检查"));
- CDwgDatabaseUtil::PostToModelSpace(pCircle);
- }
- acutPrintf(_T("\n高程点处理完毕,有: %d 个未处理。已画圆为标记请检查!"), i);
- }
- }
- else
- {
- AfxMessageBox(_T("只限定CASS的合成高程点!"));
- acutRelRb(rb);
- }
- CDwgDatabaseUtil::setVar(_T("osmode"), iosmode); // 还原捕捉状态值
- acDocManager->unlockDocument(acDocManager->curDocument());
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|