Change xref color with overrules

Change xref color with overrules

danipon71
Enthusiast Enthusiast
518 Views
2 Replies
Message 1 of 3

Change xref color with overrules

danipon71
Enthusiast
Enthusiast

Hi,

i need to color some entities using overrules.

Now I’m using AcGiDrawableOverrule::worldDraw.

It works fine with all entities but overrules.

Is there any way to color xref with AcGiDrawableOverrule?

 

My code (cleaned) + xref detection 

 

    virtual Adesk::Boolean  worldDraw(AcGiDrawable* pSubject, AcGiWorldDraw * wd)
    {
        bool xref = false;
        AcDbEntity *asEnt = AcDbEntity::cast(pSubject);
        if (asEnt) {
            if (asEnt->isKindOf(AcDbBlockReference::desc())) {
                AcDbBlockReference *pBR = AcDbBlockReference::cast(asEnt);
                AcDbObjectId idBlk = pBR->blockTableRecord();
                AcDbObject *pObj;
                acdbOpenObject(pObj, idBlk, AcDb::kForRead);
                AcDbBlockTableRecord * pBTR = AcDbBlockTableRecord::cast(pObj);
                if (pBTR != NULL) {
                    if (pBTR->isFromExternalReference()) {
                        xref = true;
                    }
                }
                pObj->close();
            }

            AcDbDatabase *db = asEnt->database();
            if (db) {
                TopDwgStatus* dwgstatus = TopDwgStatus::find(db);
                if (dwgstatus) {
                    AcDbObjectId idLay = asEnt->layerId();
                    wd->subEntityTraits().setColor(3);
                }
            }
        }

        Adesk::Boolean retValue = inherited::worldDraw(pSubject, wd);
        return retValue;
    }

 

Thanks in advance

 

 

0 Likes
519 Views
2 Replies
Replies (2)
Message 2 of 3

deepak.a.s.nadig
Alumni
Alumni

Thank you for your patience. 

Is there any way to color Xref with AcGiDrawableOverrule? 

Attached is a simple project to add overrule to the AcDbEntity, where :

 

Adesk::Boolean testOverrule::worldDraw(AcGiDrawable* pSubject, AcGiWorldDraw* wd)
{
	
	AcDbEntity *asEnt = AcDbEntity::cast(pSubject);
	if (asEnt) {	
		wd->subEntityTraits().setColor(3);
	}
	return AcGiDrawableOverrule::worldDraw(pSubject, wd);
}


Having tested the project ( http://autode.sk/2p0je9E ), it works for changing the color of attached XRef .

Hope this helps.

0 Likes
Message 3 of 3

danipon71
Enthusiast
Enthusiast

Thank you for the replay.

After doing some tests i've found out i was doing the "xref detection" part wrong.

I've changed my code like this and now it works:

 

        AcDbEntity *asEnt = AcDbEntity::cast(pSubject);
        if (asEnt) {
            if(asEnt->database() != acdbCurDwg())
                wd->subEntityTraits().setColor(3);
        }
        Adesk::Boolean retValue = AcGiDrawableOverrule::worldDraw(pSubject, wd);

Thank you again

0 Likes