ObjectARX, AutoCAD. Среда программирования библиотеки C++

       

Пример Гиперсвязи


Следующая функция перечисляет гиперсвязи, связанные с примитивом и позволяет новым гиперсвязям быть добавленной в их месте. (Проверка ошибок не показывается.)

void AddHyperlink()

{

ads_name en;

ads_point pt;

AcDbEntity * pEnt;

AcDbObjectId pEntId;

// Prompt user to select entity.

acedEntSel("\nSelect an Entity: ", en, pt);

// Get Object id.

acdbGetObjectId(pEntId, en);

// Open object for write.

acdbOpenObject(pEnt, pEntId, AcDb::kForWrite);



// The hyperlink collection object is created inside

// of getHyperlinkCollection

// below. It is our responsibility to delete it.

AcDbHyperlinkCollection * pcHCL = NULL;

// Get the hyperlink collection associated with the entity.

ACRX_X_CALL(pEnt, AcDbEntityHyperlinkPE)->

getHyperlinkCollection(pEnt, pcHCL, false, true);

// If a hyperlink exists already, say so.

if (pcHCL->count() != 0)

{

AcDbHyperlink * pcHO;

acutPrintf("\nThe following hyperlink info already exists

on this entity:");

// Iterate through collection and print existing hyperlinks.

int i = 0;

for (i = 0; i < pcHCL->count(); i++)

{

// Get point to current hyperlink object.

pcHO = pcHCL->item(i);

acutPrintf("\nHyperlink name: %s", pcHO->name());

acutPrintf("\nHyperlink location: %s",

pcHO->subLocation());

acutPrintf("\nHyperlink description: %s",

pcHO->description());

}

acutPrintf("\n** All will be replaced.**");

// Remove existing hyperlinks from collection.

// RemoveAt will delete objects too.

for (i = pcHCL->count() - 1; i >= 0; i--)

{

pcHCL->removeAt(i);

}

}

// Get new hyperlinks for this entity.

for (;;)

{

acutPrintf("\nEnter null name, location, and description to

terminate input requests.");

// Prompt user for name and description.

char sName[100], sLocation[100], sDescription[100];

if (acedGetString(TRUE, "\nEnter hyperlink name: ", sName) != RTNORM)

acutPrintf("Invalid input\n");

if (acedGetString(TRUE, "\nEnter hyperlink location: ", sLocation) != RTNORM)

acutPrintf("Invalid input\n");

if (acedGetString(TRUE, "\nEnter hyperlink description: ", sDescription) != RTNORM)

acutPrintf("Invalid input\n");

// Add hyperlink or exit prompting.

if (strcmp(sName, "") || strcmp(sLocation, "") || strcmp(sDescription, ""))

pcHCL->addTail(sName, sDescription, sLocation);

else

break;

}

// Add these hyperlinks to the selected entity (opened above).

ACRX_X_CALL(pEnt, AcDbEntityHyperlinkPE)->

setHyperlinkCollection(pEnt, pcHCL);

// Delete the collection. The collection will delete all its

// contained hyperlink objects.

delete pcHCL;

// Close the object.

pEnt->close();

}



Содержание раздела