How to retrieve active layout during plot preview?

How to retrieve active layout during plot preview?

maisoui
Advocate Advocate
920 Views
2 Replies
Message 1 of 3

How to retrieve active layout during plot preview?

maisoui
Advocate
Advocate

Hi,

 

I have a custom entity which always displays a Plan view. To do that, I need to retrieve the current layout to get the view direction, the camera up vector and the view X axis. In case of plot generation, I need to adapt the view X axis according to the active layout plot rotation.

 

 

if(m_pMode->context()->isPlotGeneration())
{
	//get the plot configuration of the current layout
	AcApLayoutManager * pLayoutManager = static_cast<AcApLayoutManager *>(acdbHostApplicationServices()->layoutManager());
	AcDbLayout * pLayout = pLayoutManager->findLayoutNamed(pLayoutManager->findActiveLayout(false));
	assert(pLayout != NULL);
	if(pLayout != NULL)
	{
		//check if this plot is rotated or not
		switch(pLayout->plotRotation())
		{
		case AcDbPlotSettings::PlotRotation::k90degrees:
			m_viewXAxis.rotateBy(-PI / 2., m_viewDirection);
			break;

		case AcDbPlotSettings::PlotRotation::k180degrees:
			m_viewXAxis.rotateBy(PI, m_viewDirection);
			break;

		case AcDbPlotSettings::PlotRotation::k270degrees:
			m_viewXAxis.rotateBy(PI / 2., m_viewDirection);
			break;
		}
	}
}

 

So far, everything works perfectly, but when I use the plot dialog, changes are not repercuted in the active layout I have. It seems that the plot dialog have an internal copy of the active layout, and don't apply changes to the "real" active layout.

 

2015-08-11 16_51_22-Plot - Layout1.png

 

So my question is : How can I retrieve the information used by the plot dialog ?

 

Note : If I press on "Apply to Layout" button, close the dialog and re-open it, preview is now ok because I receive updated information from AcDbLayout.

 

Best regards,

--
Jonathan
0 Likes
Accepted solutions (1)
921 Views
2 Replies
Replies (2)
Message 2 of 3

Balaji_Ram
Alumni
Alumni
Accepted solution

Hi Jonathan,

 

This is a known behavior.

The layout is not updated until the plot ends and so the information on plot rotation is not available during preview.

 

The workaround for this is to use the plot reactor.

The plot rotation can be obtained using AcPlPlotReactor::beginDocument from its AcPlPlotInfo::overrideSettings.

To identify the preview mode, please use the PlotType parameter of the AcPlPlotReactor::beginPlot method.

 

Regards,

Balaji

 

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

maisoui
Advocate
Advocate

Thank you Balaji.

Best regards,

--
Jonathan
0 Likes