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

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

Anonymous
Not applicable
1,186 Views
4 Replies
Message 1 of 5

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

Anonymous
Not applicable

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?

 

0 Likes
1,187 Views
4 Replies
Replies (4)
Message 2 of 5

deepak.a.s.nadig
Alumni
Alumni

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
Not applicable

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

0 Likes
Message 4 of 5

Alexander.Rivilis
Mentor
Mentor

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
Explorer
Explorer

it not work in autocad2020

0 Likes