Regenerating Model Removes Highlight

Regenerating Model Removes Highlight

Kyudos
Advisor Advisor
604 Views
1 Reply
Message 1 of 2

Regenerating Model Removes Highlight

Kyudos
Advisor
Advisor

In AutoCAD 2108, I have a function that displays errors by highlighting the relevant entities. This is working well. I want to subsequently have a Next / Previous part of the function to "go to" each entity. This also works, but when I "Goto" the highlighting no longer shows (though if I test the entity's highlight state it is still highlighted).

My Goto function (below) causes a "Regenerating model" - I think that might be the issue. I've tried queue / flush / update,  acdbEntUpd and issuing a REGEN but I can't get the highlight to come back. 

 

Are there any other options?

 

//------------------------------------------------------------------------------
void Goto(double dX, double dY, BOOL bZoom)
//------------------------------------------------------------------------------
{
	Acad::ErrorStatus es = Acad::eOk;

	AcDbDatabase* pDb = pApp->GetCurrentAcDb();

	if (pDb != NULL)
	{
		// Get the viewport
		es = acedVports2VportTableRecords();
		AcDbViewportTable *pVpT = NULL;
		AcDbViewportTableRecord *pActVp = NULL;
		AcGePoint2d centerpt;
		double height = 0.0L;
		double width = 0.0L;

		// Get the *Active view port
		es = pDb->getViewportTable(pVpT, AcDb::kForRead);
		if (pVpT != NULL)
		{
			es = pVpT->getAt(_T("*ACTIVE"), pActVp, AcDb::kForWrite);
			es = pVpT->close();

			if (pActVp != NULL)
			{
				centerpt = pActVp->centerPoint();
				height = pActVp->height();
				width = pActVp->width();

				// Close the Active viewport
				es = pActVp->close();

				// Update the viewport
				es = acedVportTableRecords2Vports();
			}
		}

		// Notify
		CString sMsg = _T("");
		sMsg.Format(RESSTR(IDS_MOVINGTO), dX, dY);
		pApp->DisplayMessage(0, sMsg);

		// This is the same as ZoomTo - but without the unit conversion
		centerpt.x = dX;
		centerpt.y = dY;

		// Adjust for UCS
		acdbUcs2Wcs((double*)(&centerpt), (double*)(&centerpt), false);

		// Adjust zoom state based on design size if required
		DocSettings* pDocSettings = pApp->GetDocSettings();
		if (bZoom && pDocSettings != NULL)
		{
			DistanceUnit unit;
			pApp->GetUnitSettings()->GetUserUnit(&unit);
			DocSettings::DesignSizes Sizes = pDocSettings->GetDesignSizes();
			double basesize = Sizes.m_BaseSymbolSize.GetConvertedValue(unit);

			(height > 10.0L * basesize) ? height = 10.0L * basesize : height;
			(width > 10.0L * basesize) ? width = 10.0L * basesize : width;
		}

		// Got specified point
		if (height > 0.001 || width > 0.001)
		{
			AcDbViewTableRecord mVTR;
			mVTR.setCenterPoint(centerpt);
			mVTR.setHeight(height);
			mVTR.setWidth(width);
			es = acedSetCurrentView(&mVTR, NULL);
		}
	}
}
0 Likes
Accepted solutions (1)
605 Views
1 Reply
Reply (1)
Message 2 of 2

Kyudos
Advisor
Advisor
Accepted solution

Nevermind....I used a simpler ZoomTo function and my highlight stays...

 

 

//------------------------------------------------------------------------------
Acad::ErrorStatus ZoomTo(AcGePoint2d& Min, AcGePoint2d& Max, double dZoomFactor)
//------------------------------------------------------------------------------
{
	Acad::ErrorStatus es = (Acad::ErrorStatus)-1;
	// Check zoom makes sense
	if ((Max.y - Min.y) > 0.001 || (Max.x - Min.x) > 0.001)
	{
		AcDbViewTableRecord mVTR;
		mVTR.setCenterPoint(Min + (Max - Min) / 2.0);
		mVTR.setHeight((Max.y - Min.y) * dZoomFactor);
		mVTR.setWidth((Max.x - Min.x) * dZoomFactor);
		es = acedSetCurrentView(&mVTR, NULL);
	}
	return es;
}

 

 

0 Likes