当前位置: 首页>>代码示例>>C++>>正文


C++ AcDbBlockTable::add方法代码示例

本文整理汇总了C++中AcDbBlockTable::add方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbBlockTable::add方法的具体用法?C++ AcDbBlockTable::add怎么用?C++ AcDbBlockTable::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AcDbBlockTable的用法示例。


在下文中一共展示了AcDbBlockTable::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

Acad::ErrorStatus
ArxDbgUtils::defineNewAnonymousBlock(AcDbBlockTableRecord*& newBlkRec,
                                AcDbObjectId& newBlkRecId, AcDbDatabase* db)
{
	ASSERT(db != NULL);

    AcDbBlockTable* blkTbl;
	Acad::ErrorStatus es = db->getSymbolTable(blkTbl, AcDb::kForWrite);
    if (es != Acad::eOk)
        return es;

    newBlkRec = new AcDbBlockTableRecord;
    newBlkRec->setPathName(AcadString::nullStr);    // constructor doesn't do it properly

    es = newBlkRec->setName(_T("*U"));
    if (es == Acad::eOk)
        es = blkTbl->add(newBlkRecId, newBlkRec);

    if (es != Acad::eOk) {    // make sure everything went ok
        ArxDbgUtils::rxErrorMsg(es);
        delete newBlkRec;
        newBlkRec = NULL;    // don't let caller get bad value
    }

    blkTbl->close();    // doesn't need to be open anymore
    return es;
}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:27,代码来源:ArxDbgUtilsSymTbl.cpp

示例2: AcDbBlockTableRecord

void
makeABlock()
{
     // Create and name a new block table record.
     //
     AcDbBlockTableRecord *pBlockTableRec
         = new AcDbBlockTableRecord();
     pBlockTableRec->setName("ASDK-NO-ATTR");

     // Get the block table.
     //
     AcDbBlockTable *pBlockTable = NULL;
     acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForWrite);

     // Add the new block table record to the block table.
     //
     AcDbObjectId blockTableRecordId;
     pBlockTable->add(blockTableRecordId, pBlockTableRec);
     pBlockTable->close();

     // Create and add a line entity to the component's
     // block record.
     //
     AcDbLine *pLine = new AcDbLine();
     AcDbObjectId lineId;

     pLine->setStartPoint(AcGePoint3d(3, 3, 0));
     pLine->setEndPoint(AcGePoint3d(6, 6, 0));
     pLine->setColorIndex(3);

     pBlockTableRec->appendAcDbEntity(lineId, pLine);
     pLine->close();
     pBlockTableRec->close();
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:35,代码来源:complex.cpp

示例3: CreateBlock

AcDbObjectId CArxHelper::CreateBlock(const AcDbVoidPtrArray& arrEnt, const CString& strName)
{
	AcDbObjectId blockId = AcDbObjectId::kNull;
	AcDbBlockTableRecord* pBlockTableRecord = new AcDbBlockTableRecord();
	pBlockTableRecord->setName(strName);
	pBlockTableRecord->setOrigin(AcGePoint3d::kOrigin);
	for (int i = 0; i < arrEnt.length(); ++ i)
	{
		AcDbEntity* pEntity = (AcDbEntity*)arrEnt.at(i);
		pBlockTableRecord->appendAcDbEntity(pEntity);
		pEntity->close();
	}

	AcDbBlockTable* pBlockTable = NULL;
	acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForWrite);
	pBlockTable->add(blockId,pBlockTableRecord);
	pBlockTableRecord->close();
	pBlockTable->close();
	return blockId;
}
开发者ID:ninuo,项目名称:ArxWorkspace,代码行数:20,代码来源:ArxHelper2.cpp

示例4: createBlockRecord

Acad::ErrorStatus createBlockRecord(/*[in]*/const char* name)
{
	AcDbCircle* pFace = NULL;
	AcDbCircle* pLeftEye = NULL;
	AcDbCircle* pRightEye = NULL;
	AcDbArc* pMouth = NULL;
	AcDbBlockTable* pBlockTable = NULL;
	AcDbBlockTableRecord* pBlockTableRecord = NULL;

	try
	{
		// First, check if a block of the same name already exists
		// by verifying in the current database block table.
		//
		// Open the block table for read
		//
		ARXOK(acdbCurDwg()->getBlockTable(pBlockTable, AcDb::kForRead));

		if (pBlockTable->has(name) == Adesk::kTrue)
		{
			pBlockTable->close();
			return Acad::eDuplicateKey;
		}

		// Now we know the block does not exist, so we create it
		// using the name passed in.
		//
		pBlockTableRecord = new AcDbBlockTableRecord();
		if (!pBlockTableRecord)
			throw Acad::eOutOfMemory;

		pBlockTableRecord->setName(name);

		// To keep it simple, we use the origin for the insertion point
		//
		pBlockTableRecord->setOrigin(AcGePoint3d::kOrigin);

		// Open the block table for write
		// since we are adding a new block definition
		//
		ARXOK(pBlockTable->upgradeOpen());

		// Add the new block table record to the block table.
		// For now, the block table record is empty.
		//
		ARXOK(pBlockTable->add(pBlockTableRecord));
		pBlockTable->close();
		pBlockTable = NULL;

		// Now the block table record is in the database, but is empty
		// (has no sub-entity).
		// Note that after having been added to the database, an object or an entity
		// is implicitely opened for write.
		//
		// So we create the sub entities to append to the block
		// which will represent a "happy face":
		// the block should consist of a round yellow face (circle)
		// two blue eyes (circles) and a red mouth (arc)
		//
		pFace = new AcDbCircle(AcGePoint3d::kOrigin, AcGeVector3d::kZAxis, 1.0);
		pLeftEye = new AcDbCircle(AcGePoint3d(0.33, 0.25, 0.0), AcGeVector3d::kZAxis, 0.1);
		pRightEye = new AcDbCircle(AcGePoint3d(-0.33, 0.25, 0.0), AcGeVector3d::kZAxis, 0.1);
		pMouth = new AcDbArc(AcGePoint3d(0, 0.5, 0), 1.0, PI + (PI * 0.3), PI + (PI * 0.7));
		if (!pFace || !pLeftEye || !pRightEye || !pMouth)
		{
			delete pFace;
			delete pLeftEye;
			delete pRightEye;
			delete pMouth;
			throw Acad::eOutOfMemory;
		}

		// Set the color property.
		//
		pFace->setColorIndex(2);
		pLeftEye->setColorIndex(5);
		pRightEye->setColorIndex(5);
		pMouth->setColorIndex(1);

		ARXOK(pBlockTableRecord->appendAcDbEntity(pFace));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pLeftEye));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pRightEye));
		ARXOK(pBlockTableRecord->appendAcDbEntity(pMouth));

		pFace->close();
		pLeftEye->close();
		pRightEye->close();
		pMouth->close();

		pBlockTableRecord->close();
		return Acad::eOk;
	}

	catch(const Acad::ErrorStatus es)
	{

		if(pBlockTable)
			pBlockTable->close();

		if(pBlockTableRecord)
//.........这里部分代码省略.........
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:101,代码来源:lab3_try-catch.cpp

示例5: tempPt

void
defineBlockWithAttributes(
    AcDbObjectId& blockId, // This is a returned value.
    const AcGePoint3d& basePoint,
    double textHeight,
    double textAngle)
{
    int retCode = 0;
    AcDbBlockTable *pBlockTable = NULL;
    AcDbBlockTableRecord* pBlockRecord
       = new AcDbBlockTableRecord;
    AcDbObjectId entityId;

    // Step 1: Set the block name and base point of the block definition
    //
    pBlockRecord->setName("ASDK-BLOCK-WITH-ATTR");
    pBlockRecord->setOrigin(basePoint);

    // Open the block table for write.
    //
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForWrite);

    // Step 2: Add the block table record to block table.
    //
    pBlockTable->add(blockId, pBlockRecord);

    // Step 3: Create a circle entity.
    //
    AcDbCircle *pCircle = new AcDbCircle;
    pCircle->setCenter(basePoint);
    pCircle->setRadius(textHeight * 4.0);
    pCircle->setColorIndex(3);

    // Append the circle entity to the block record.
    //
    pBlockRecord->appendAcDbEntity(entityId, pCircle);
    pCircle->close();

    // Step 4: Create an attribute definition entity.
    //
    AcDbAttributeDefinition *pAttdef
        = new AcDbAttributeDefinition;

    // Set the attribute definition values.
    //
    pAttdef->setPosition(basePoint);
    pAttdef->setHeight(textHeight);
    pAttdef->setRotation(textAngle);
    pAttdef->setHorizontalMode(AcDb::kTextLeft);
    pAttdef->setVerticalMode(AcDb::kTextBase);
    pAttdef->setPrompt("Prompt");
    pAttdef->setTextString("DEFAULT");
    pAttdef->setTag("Tag");
    pAttdef->setInvisible(Adesk::kFalse);
    pAttdef->setVerifiable(Adesk::kFalse);
    pAttdef->setPreset(Adesk::kFalse);
    pAttdef->setConstant(Adesk::kFalse);
    pAttdef->setFieldLength(25);

    // Append the attribute definition to the block.
    //
    pBlockRecord->appendAcDbEntity(entityId, pAttdef);

    // The second attribute definition is a little easier
    // because we are cloning the first one.
    //
    AcDbAttributeDefinition *pAttdef2
        = AcDbAttributeDefinition::cast(pAttdef->clone());

    // Set the values which are specific to the
    // second attribute definition.
    //
    AcGePoint3d tempPt(basePoint);
    tempPt.y -= pAttdef2->height();
    pAttdef2->setPosition(tempPt);
    pAttdef2->setColorIndex(1); // Red
    pAttdef2->setConstant(Adesk::kTrue);

    // Append the second attribute definition to the block.
    //
    pBlockRecord->appendAcDbEntity(entityId, pAttdef2);

    pAttdef->close();
    pAttdef2->close();
    pBlockRecord->close();
    pBlockTable->close();
    return;
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:89,代码来源:complex.cpp


注:本文中的AcDbBlockTable::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。