本文整理汇总了C++中AcDbEntity类的典型用法代码示例。如果您正苦于以下问题:C++ AcDbEntity类的具体用法?C++ AcDbEntity怎么用?C++ AcDbEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AcDbEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: energy
// This function has the user select an entity and then
// calls the reflectedEnergy() function in the protocol
// extension class attached to that entity's class.
//
void
energy()
{
AcDbEntity *pEnt;
AcDbObjectId pEntId;
ads_name en;
ads_point pt;
if (acedEntSel("\nSelect an Entity: ", en, pt)
!= RTNORM)
{
acutPrintf("Nothing Selected\n");
return;
}
acdbGetObjectId(pEntId, en);
acdbOpenObject(pEnt, pEntId, AcDb::kForRead);
// call the protocol extension class's method
//
double eTemp = ACRX_X_CALL(pEnt,
AsdkEntTemperature)->reflectedEnergy(pEnt);
acutPrintf("\nEnergy == %f\n", eTemp);
pEnt->close();
}
示例2: addXdata
void Additional_Class::addXdata( AcDbObjectId entID, CString xdataStr, CString xdataNameStr )
{
AcDbEntity * pEnt;
struct resbuf * pRb;
if(Acad::eOk != acdbOpenAcDbEntity(pEnt, entID, AcDb::kForWrite))
{
pEnt->close();
return;
}
TCHAR * tempTchar = CString2TCHAR(xdataNameStr);
//TCHAR strAppName[] = tempTchar;
acdbRegApp(tempTchar);
TCHAR * typeName = CString2TCHAR(xdataStr);
struct resbuf * pTemp;
pTemp = pEnt->xData(tempTchar);
pRb = acutBuildList(AcDb::kDxfRegAppName, tempTchar,
AcDb::kDxfXdAsciiString, typeName,
RTNONE);
pEnt->setXData(pRb);
acutRelRb(pRb);
pEnt->close();
return;
}
示例3: FindLinesByPoint
// 查找连接点junctionPt关联的分支图元(包含隐形的图元)
static void FindLinesByPoint( const AcGePoint3d& junctionPt, AcDbObjectIdArray& objIds )
{
AcDbBlockTable* pBlkTbl;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable( pBlkTbl, AcDb::kForRead );
AcDbBlockTableRecord* pBlkTblRcd;
pBlkTbl->getAt( ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead );
pBlkTbl->close();
AcDbBlockTableRecordIterator* pBlkTblRcdItr;
pBlkTblRcd->newIterator( pBlkTblRcdItr );
for ( pBlkTblRcdItr->start(); !pBlkTblRcdItr->done(); pBlkTblRcdItr->step() )
{
// 不采用transaction的方法查找LinkedGE,
// 等价于排除当前正在以write状态编辑的LinkedGE
// 重要(***)
AcDbEntity* pEnt = 0;
if( Acad::eOk != pBlkTblRcdItr->getEntity( pEnt, AcDb::kForRead ) ) continue;
LinkedGE* pEdge = LinkedGE::cast( pEnt );
if( pEdge != 0 )
{
AcGePoint3d startPt, endPt;
pEdge->getSEPoint( startPt, endPt );
if( startPt == junctionPt || endPt == junctionPt )
{
objIds.append( pEdge->objectId() );
}
}
pEnt->close();
}
delete pBlkTblRcdItr;
pBlkTblRcd->close();
}
示例4:
bool ArxEntityHelper::SetEntitiesColor2( const AcDbObjectIdArray& objIds, const AcArray<Adesk::UInt16>& colors )
{
AcTransaction* pTrans = actrTransactionManager->startTransaction();
if( pTrans == 0 ) return false;
bool ret = true; // 默认返回true
int len = objIds.length();
for( int i = 0; i < len; i++ )
{
AcDbObject* pObj;
if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite ) )
{
actrTransactionManager->abortTransaction();
ret = false;
break;
}
AcDbEntity* pEnt = AcDbEntity::cast( pObj );
if( pEnt == 0 )
{
actrTransactionManager->abortTransaction();
ret = false;
break;
}
pEnt->setColorIndex( colors[i] ); // 恢复原先的颜色
}
actrTransactionManager->endTransaction();
return ret;
}
示例5: GetSelectedExtent
String GetSelectedExtent() {
ads_name selection;
int returnValue = acedSSGet(_T("I"), NULL, NULL, NULL, selection);
if (returnValue == RTCAN) return 0;
if (returnValue != RTNORM) {
return L"";
}
if (acedSSSetFirst(selection, NULL) != RTNORM) {
acedSSFree(selection);
return L"";
}
ads_name element;
acedSSName(selection, 0, element);
acedSSFree(selection);
AcDbObjectId idEntity;
if (acdbGetObjectId(idEntity, element) != Acad::eOk) {
acedSSFree(element);
return L"";
}
AcDbEntity * entity;
if ((acdbGetObjectId(idEntity, element) != Acad::eOk) ||
(acdbOpenObject(entity, idEntity, AcDb::kForRead) != Acad::eOk)) {
acedSSFree(element);
return L"";
}
acedSSFree(element);
if (!entity->isKindOf(AcDbPolyline::desc())) return L"";
AcDbPolyline * poly = static_cast<AcDbPolyline*>(entity);
if (!poly->isClosed()) return 0;
String extent = L"POLYGON((";
AcGePoint2d start;
AcGePoint2d current;
for (int i = 0; i < poly->numVerts(); i++) {
poly->getPointAt(i, current);
if (i > 0) {
extent += L", ";
} else {
start = current;
}
extent += Round(current.x, 0) + L" " + Round(current.y, 0);
}
if (!start.isEqualTo(current)) {
extent += L", " + Round(start.x, 0) + L" " + Round(start.y, 0);
}
extent += L"))";
poly->close();
return extent;
}
示例6: CopyBack
static void CopyBack( AcDbEntity* pSrcEnt, const AcDbObjectId& objId )
{
AcDbEntity* pEnt;
acdbOpenAcDbEntity( pEnt, objId, AcDb::kForWrite );
pEnt->copyFrom( pSrcEnt );
pEnt->close();
}
示例7: GetEntitiesColor
bool ArxEntityHelper::GetEntitiesColor( const AcDbObjectIdArray& objIds, AcArray<Adesk::UInt16>& colors )
{
AcTransaction* pTrans = actrTransactionManager->startTransaction();
if( pTrans == 0 ) return false;
bool ret = true; // 默认返回true
int len = objIds.length();
for( int i = 0; i < len; i++ )
{
AcDbObject* pObj;
if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) )
{
actrTransactionManager->abortTransaction();
ret = false;
colors.removeAll(); // 清空
break;
}
AcDbEntity* pEnt = AcDbEntity::cast( pObj );
if( pEnt == 0 )
{
actrTransactionManager->abortTransaction();
ret = false;
colors.removeAll(); // 清空
break;
}
Adesk::UInt16 ci = pEnt->colorIndex();
colors.append( ci ); // 记录原有的颜色
}
actrTransactionManager->endTransaction();
return ret;
}
示例8: SetEntitiesColor
bool ArxEntityHelper::SetEntitiesColor( AcDbObjectIdArray& objIds, unsigned short colorIndex )
{
AcTransaction* pTrans = actrTransactionManager->startTransaction();
if( pTrans == 0 ) return false;
bool ret = true; // 默认返回true
int len = objIds.length();
for( int i = 0; i < len; i++ )
{
AcDbObject* pObj;
if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForWrite ) )
{
actrTransactionManager->abortTransaction();
ret = false;
break;
}
AcDbEntity* pGE = AcDbEntity::cast( pObj );
if( pGE == 0 )
{
actrTransactionManager->abortTransaction();
ret = false;
break;
}
// 设置颜色
pGE->setColorIndex( colorIndex );
}
actrTransactionManager->endTransaction();
return ret;
}
示例9: ZoomToEntity
void ArxEntityHelper::ZoomToEntity( const AcDbObjectId& objId )
{
AcTransaction* pTrans = actrTransactionManager->startTransaction();
if( pTrans == 0 ) return;
AcDbObject* pObj;
if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForRead ) )
{
actrTransactionManager->abortTransaction();
return;
}
AcDbEntity* pEnt = AcDbEntity::cast( pObj );
if( pEnt == 0 )
{
actrTransactionManager->abortTransaction();
return;
}
AcDbExtents extents;
bool ret = ( Acad::eOk == pEnt->getGeomExtents( extents ) );
actrTransactionManager->endTransaction();
if( ret && IsValidExtent( extents ) )
{
ZoomEntity_Helper( extents.minPoint(), extents.maxPoint() );
}
}
示例10: ZoomToEntities
void ArxEntityHelper::ZoomToEntities( const AcDbObjectIdArray& objIds )
{
AcTransaction* pTrans = actrTransactionManager->startTransaction();
if( pTrans == 0 ) return;
AcDbExtents exts;
int len = objIds.length();
for( int i = 0; i < len; i++ )
{
AcDbObject* pObj;
if( Acad::eOk != pTrans->getObject( pObj, objIds[i], AcDb::kForRead ) ) continue;
AcDbEntity* pEnt = AcDbEntity::cast( pObj );
if( pEnt == 0 ) continue;
AcDbExtents extents;
if( Acad::eOk != pEnt->getGeomExtents( extents ) ) continue;
exts.addPoint( extents.minPoint() );
exts.addPoint( extents.maxPoint() );
}
actrTransactionManager->endTransaction();
AcGePoint3d minPt = exts.minPoint();
AcGePoint3d maxPt = exts.maxPoint();
if( minPt.x <= maxPt.x && minPt.y <= maxPt.y && minPt.z <= maxPt.z )
{
ZoomEntity_Helper( minPt, maxPt );
}
}
示例11: _search_related_segs
void frgExtractTopologicalEntsFromLinesAlgm::_extract_from_seg(Vertex2dsOnSegment2d &stru)
{
// - 获取相关的线段(相交、重合)
AcDbObjectIdArray ids;
_search_related_segs(ids, stru.seg);
// - 分为两类进行处理:相交和重叠
// -- 增加起点和终点
rlVertex2d *v = NULL;
stru.vertex2ds.insert(std::make_pair(0.0, v));
stru.vertex2ds.insert(std::make_pair(1.0, v));
// -- 处理每一个线段
AcDbEntity *entity = NULL;
for (int i = 0; i < ids.length(); i++)
{
acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead);
if (entity == NULL)
continue;
if (entity->isA() != AcDbLine::desc())
{
entity->close();
continue;
}
AcDbLine *_line = (AcDbLine *)entity;
AcGeLineSeg2d _seg(AcGePoint2d(_line->startPoint().x, _line->startPoint().y),
AcGePoint2d(_line->endPoint().x, _line->endPoint().y));
_line->close();
_extract_vertices(stru, _seg);
}
}
示例12: acedSetStatusBarProgressMeter
void frgExtractTopologicalEntsFromLinesAlgm::_extract_vertices_from_lines(std::vector<Vertex2dsOnSegment2d> &seg_pnts_pairs,
const AcDbObjectIdArray &ids)
{
AcDbEntity *entity = NULL;
acedSetStatusBarProgressMeter(_T("正在提取每根线段上的节点..."), 0, ids.length());
for (int i = 0; i < ids.length(); i++)
{
acdbOpenAcDbEntity(entity, ids[i], AcDb::kForRead);
if (entity == NULL)
continue;
if (entity->isA() != AcDbLine::desc())
{
entity->close();
continue;
}
AcDbLine *line = (AcDbLine *)entity;
Vertex2dsOnSegment2d stru;
stru.seg.set(AcGePoint2d(line->startPoint().x, line->startPoint().y),
AcGePoint2d(line->endPoint().x, line->endPoint().y));
entity->close();
_extract_from_seg(stru);
seg_pnts_pairs.push_back(stru);
acedSetStatusBarProgressMeterPos(i);
}
acedRestoreStatusBar();
}
示例13: readDatabase
void readDatabase()
{
// Use kFalse to create an empty database.
AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse);
// Use readDwgFile to load the DWG file.
acutPrintf(_T("\nRead file \"d:\\temp\\testfile.dwg\"."));
if(Acad::eOk != pDb->readDwgFile(_T("d:\\temp\\testfile.dwg")))
return;
// Get the BlockTable.
AcDbBlockTable *pBTable = NULL;
pDb->getSymbolTable(pBTable, AcDb::kForRead);
// Get the ModelSpace.
AcDbBlockTableRecord *pRecord = NULL;
pBTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForRead);
pBTable->close();
// Get new iterator.
AcDbBlockTableRecordIterator *pItr = NULL;
pRecord->newIterator(pItr);
AcDbEntity *pEnt = NULL;
for (pItr->start(); !pItr->done(); pItr->step())
{
pItr->getEntity(pEnt, AcDb::kForRead);
acutPrintf(_T("\nclassname: %s"), (pEnt->isA())->name());
pEnt->close();
}
pRecord->close();
delete pItr;
delete pDb;
}
示例14: acdbOpenAcDbEntity
BOOL CDetailShow::OnInitDialog()
{
CAcUiDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
long len = m_objIds.length();
//取得选择集的长度
//遍历选择集中的实体,将其打开并修改其颜色为红色
for (int i =0;i<len;i++)
{
ads_name entres;
AcDbObjectId objId;
AcDbEntity *obj;
Acad::ErrorStatus es;
es = acdbOpenAcDbEntity(obj, m_objIds[i], AcDb::kForRead, true);
if (es == Acad::eOk) {
LPCTSTR str;
str = obj->isA()->name();
m_listBox.AddString(str);
obj->close();
}
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
示例15: UpdateEntity2
// 使用常规的Open/Close机制
static void UpdateEntity2( const AcDbObjectId& objId )
{
AcDbEntity* pEnt;
if( Acad::eOk != acdbOpenObject( pEnt, objId, AcDb::kForWrite ) ) return;
pEnt->recordGraphicsModified( true ); // 标签图元状态已修改,需要更新图形
pEnt->close();
}