ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to highlight a line in a Block(reference)?

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
778 Views, 4 Replies

How to highlight a line in a Block(reference)?

There is a block which contains AcDbLines.
This block is used via a single BRef.
How do I highlight a line? Obviously this function must be called:

 

 

Acad::ErrorStatus AcDbEntity::highlight(const AcDbFullSubentPath& subId = kNullSubent, ...

 

 

As the object of which highlight is called, I tried both the BRef and the AcDbLine.
As the first parameter I tried both kNullSubent and a subent that I created like this:

 

 

AcDbFullSubentPath oMyPath;
AcDbObjectIdArray &rObjIds = oMyPath.objectIds();
rObjIds.append(idOfBlockOfBRef); // idBtr2idBRef(idBtr));
rObjIds.append(pEnt->objectId());
AcDbSubentId &rSubentId = oMyPath.subentId();
rSubentId.setType(kEdgeSubentType);


 

I also tried it without the last two lines.

 

The results:

BRef + oMyPath: eInvalidInput
BRef + kNullSubent: Complete "Bref" (iow complete block at the correct location) is highlighted.
Line + oMyPath: eInvalidInput
Line + kNullSubent + any mode other than 2D wireframe: Line is highlighted as if the block(ref) would be positioned at 0,0,0
Line + kNullSubent + 2D wireframe: No error result, no visual effect.

 

So, nothing is like I want (only the single line highlighted at the correct position)

Any ideas?

 

4 REPLIES 4
Message 2 of 5
deepak.a.s.nadig
in reply to: Anonymous

Here is a quick sample I have written to get line entities in a block reference and highlight them :

 

void TestLine()
{
	AcDbBlockTable* pTable; 
	acdbHostApplicationServices()->workingDatabase()->getBlockTable
		(
		pTable,
		AcDb::kForRead
		);
	if(pTable == NULL)
		return; 

	AcDbBlockTableIterator* pTableIter;
	for( pTable->newIterator(pTableIter); !pTableIter->done(); pTableIter->step())
	{     
		AcDbBlockTableRecord* pRecord;     
		pTableIter->getRecord(pRecord,AcDb::kForRead);  
		if(pRecord == NULL)
		{   
			acutPrintf(_T("\nCannot open a BTR"));  
			continue;   
		} 

		AcDbBlockTableRecordIterator* pRecordIter;
		for (    pRecord->newIterator(pRecordIter);
			! pRecordIter->done();
			pRecordIter->step()
			)
		{
			AcDbEntity*pEnt;    
const AcDbFullSubentPath subentIds; pRecordIter->getEntity(pEnt, AcDb::kForRead); AcDbLine *pLine = NULL; pLine = AcDbLine::cast( pEnt ); if ( pLine) { pEnt->subentPtr(subentIds); pEnt->highlight(subentIds); pEnt->close(); } } delete pRecordIter; pRecord->close(); } pTable->close(); delete pTableIter; }
Message 3 of 5
Anonymous
in reply to: deepak.a.s.nadig

Thank you very much.

 

On my computer your code leads to the same behaviour as mine (highlights a "ghost block at 0,0,0" when visual style is not 2D wireframe). I have to say I am using ACAD 2106.

I found out my boss has Acad 2017 installed and there is no "ghosting" on his computer. Do you know whether this a known bug in ACAD2016?

 

 

Bye bye,

Wolfram Kuss,

imos3d.com

Message 4 of 5
Alexander.Rivilis
in reply to: Anonymous

I can reproduce this issue in AutoCAD 2016 with all updates:

 

2016-11-01_9-06-40.png

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 5
66713205
in reply to: deepak.a.s.nadig

it not work in autocad2020

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report