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

Temporarily save model space plot settings

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
776 Views, 2 Replies

Temporarily save model space plot settings

Hello,
I want to save the model space plot settings in an temporary
AcDbPlotSettings object and after modifying the current plot settings and
printing the drawing - I want to set back the saved configuration. Any idea
how to do this? I made the following code snippet and it didn't worked 😞

**** code snippet begin ****
AcApLayoutManager *pLayoutManager;
AcDbLayout *pLayout= NULL;
AcDbPlotSettings *pSavedPlotCfg= NULL;
AcDbPlotSettingsValidator *pPlotSettingsValidator= NULL;

pLayoutManager=
(AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
pLayout= pLayoutManager-> findLayoutNamed("Model", TRUE);
pPlotSettingsValidator=
acdbHostApplicationServices()->plotSettingsValidator();
pPlotSettingsValidator->refreshLists(pLayout);

// Save the layout
pSavedPlotCfg= new AcDbPlotSettings(TRUE);
ASSERT(NULL!= pSavedPlotCfg);
pSavedPlotCfg->copyFrom(pLayout);
pLayout->close();

// Do what you want ...
// Config, Print etc.

// Set back the saved layout
pLayoutManager=
(AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
pLayout= pLayoutManager-> findLayoutNamed("Model", TRUE);
pPlotSettingsValidator=
acdbHostApplicationServices()->plotSettingsValidator();

pPlotSettingsValidator->setDefaultPlotConfig(pSavedPlotCfg));
pPlotSettingsValidator->refreshLists(pLayout);
AcApLayoutManager *pLayM
=(AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
pLayM->setCurrentLayout("Model");
pLayM->updateLayoutTabs();
pLayout->close();
**** code snippet begin ****

Setting Layout back didn't worked !!!

Best regards,
Stefan


--
Rösberg Engineering GmbH
Stefan Pfitzner
Diplom-Ingenieur (BA)

CAE- Systementwicklung
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Is my problem so difficult ??
Anyone can give me some help ??


"Stefan Pfitzner" schrieb im Newsbeitrag
news:EDC72ADC58EE33B36DA9F5E9B79EF0FE@in.WebX.maYIadrTaRb...
> Hello,
> I want to save the model space plot settings in an temporary
> AcDbPlotSettings object and after modifying the current plot settings and
> printing the drawing - I want to set back the saved configuration. Any
idea
> how to do this? I made the following code snippet and it didn't worked 😞
>
> **** code snippet begin ****
> AcApLayoutManager *pLayoutManager;
> AcDbLayout *pLayout= NULL;
> AcDbPlotSettings *pSavedPlotCfg= NULL;
> AcDbPlotSettingsValidator *pPlotSettingsValidator= NULL;
>
> pLayoutManager=
> (AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
> pLayout= pLayoutManager-> findLayoutNamed("Model", TRUE);
> pPlotSettingsValidator=
> acdbHostApplicationServices()->plotSettingsValidator();
> pPlotSettingsValidator->refreshLists(pLayout);
>
> // Save the layout
> pSavedPlotCfg= new AcDbPlotSettings(TRUE);
> ASSERT(NULL!= pSavedPlotCfg);
> pSavedPlotCfg->copyFrom(pLayout);
> pLayout->close();
>
> // Do what you want ...
> // Config, Print etc.
>
> // Set back the saved layout
> pLayoutManager=
> (AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
> pLayout= pLayoutManager-> findLayoutNamed("Model", TRUE);
> pPlotSettingsValidator=
> acdbHostApplicationServices()->plotSettingsValidator();
>
> pPlotSettingsValidator->setDefaultPlotConfig(pSavedPlotCfg));
> pPlotSettingsValidator->refreshLists(pLayout);
> AcApLayoutManager *pLayM
> =(AcApLayoutManager*)acdbHostApplicationServices()->layoutManager();
> pLayM->setCurrentLayout("Model");
> pLayM->updateLayoutTabs();
> pLayout->close();
> **** code snippet begin ****
>
> Setting Layout back didn't worked !!!
>
> Best regards,
> Stefan
>
>
> --
> Rösberg Engineering GmbH
> Stefan Pfitzner
> Diplom-Ingenieur (BA)
>
> CAE- Systementwicklung
>
>
Message 3 of 3
bakerrl2
in reply to: Anonymous

Here is what I do in my program.

 

I create a new AcDbPlotSettings variable and then I copy the settings from the current layout (Model or PaperSpace) in the variable.  From that point I use my AcDbPlotSettings variable to make any adjustments to the plot settings and plot the drawing.

 

Example of copying a layout:

 

AcApLayoutManager *pLM = (AcApLayoutManager *)acdbHostApplicationServices()->layoutManager();

 

AcDbObjectId aoBTRId = pLM->getActiveLayoutBTRId();

 

AcDbBlockTableRecord *pBTR;

es = acdbOpenObject(pBTR, aoBTRId, AcDb::kForRead);

if (es != Acad::eOk)

{

   return 1;

}

 

AcDbObjectId aoLayoutId = pBTR->getLayoutId();

 

pBTR->close();

 

if (aoLayoutId.isNull())

{

   return 1;

}

 

AcDbLayout *pLayout;

es = acdbOpenObject(pLayout, aoLayoutId, AcDb::kForRead);

if (es != Acad::eOk)

{

   return 1;

}

 

AcDbPlotSettings *pPS = new AcDbPlotSettings(pLayout->modelType() == Adesk::kTrue);

if (pPS == NULL)

{

    pLayout->close();

   return 1;

}

 

es = pPS->copyFrom(pLayout);

pLayout->close();

 

From this point on I used the AcDbPlotSettingsValidator class to adjust any settings the the AcDbPlotSettings variable (pPS)

 

AcDbPlotSettingsValidator *pPSV = (AcDbPlotSettingsValidator *)acdbHostApplicationServices()->plotSettingsValidator();

 

Once I am finished with the AcDbPlottingSettings variable (pPS) I simply delete it.

 

delete pPS;

 

This allows me to create temporary layout from an existing layout that I can modify and use to plot the drawing.

 

Note: pPS->modelType() returns true if the layout is a Model layout vs. a Paperspace layout.

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

Post to forums  

Autodesk Design & Make Report

”Boost