Code (Arx) for Insert "TEXT" in Model

Code (Arx) for Insert "TEXT" in Model

Anonymous
Not applicable
342 Views
1 Reply
Message 1 of 2

Code (Arx) for Insert "TEXT" in Model

Anonymous
Not applicable
HI all,
I wanted to have a single code for insert a text (String") in Model , please, I am novice in this.
for example that it primes my name "Ayala Bizarro , Ivan"

thank you All
Ayala Bizarro , Ivan

Message was edited by: ivancho

Message was edited by: ivancho Message was edited by: ivancho
0 Likes
343 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hm, i think that you need to do something like this. First you need this variables:
CString strText; // Text to writte
AcGePoint3d* position; //- text position
double height; // text height
double rotation; // rotation (0.0f)


// First take working database (dwg)
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
acDocManager->lockDocument(acDocManager->document(pCurDb));
if(!pCurDb)
{
acDocManager->unlockDocument(acDocManager->document(pCurDb));
return FALSE;
}



//- Take block table
AcDbBlockTable* pBlockTable = NULL;
pCurDb->getBlockTable(pBlockTable, AcDb::kForRead);
if(!pBlockTable)
{
acDocManager->unlockDocument(acDocManager->document(pCurDb));
return FALSE;
}

AcDbBlockTableRecord* pBlockTableRecord;
ErrorStatus es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
if(!pBlockTableRecord)
{
pBlockTable->close();
acDocManager->unlockDocument(acDocManager->document(pCurDb));
return FALSE;
}
pBlockTable->close();

//- Take text style
AcDbObjectId objId_TextStyle = AcDbObjectId::kNull;
AcDbSymbolUtilities::getTextStyleId(objId_TextStyle, _T("HCTEXT"), pCurDb);

//- New text reference
AcDbText* pText = new AcDbText(*position, strText, objId_TextStyle, height, rotation);

AcDbObjectId textID;

//- Put text in database
pBlockTableRecord->appendAcDbEntity(textID, pText);

pBlockTableRecord->close();
pText->close();
acDocManager->unlockDocument(acDocManager->document(pCurDb)); Message was edited by: Andeo
0 Likes