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

PlotSettings - Saving

8 REPLIES 8
Reply
Message 1 of 9
Martin60
677 Views, 8 Replies

PlotSettings - Saving

Once again I have come to a hurdle.

I cannot see how to save my plot settings after:
{code}
Dim acPlotSettings As New PlotSettings(False)
acPlotSettings.PlotHidden = bHide
acPlotSettings.PlotPlotStyles = True
acPlotSettings.PrintLineweights = True
acPlotSettings.ScaleLineweights = False
{code}

Thanks
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Martin60

From memory there are several approaches you could take.

If your looking at using the settings only during 1 session, you could save it as a global variable reading and writing it.
If your looking at using with other drawings, either save an an applications settings or within an external XML/INI/Settings file.
If it's drawing/layout specific, you could create a new page setup saving and loading to it.

I personally prefer the XML file.
Message 3 of 9
martinw
in reply to: Martin60

My question is more basic then that.
Having set acPlotSettings how do I apply acPlotSettings so the new values are used.
Message 4 of 9
Anonymous
in reply to: Martin60

Ah, that's simple.
You should have a PlotInfo and PlotInfoValidator declaration.
using these, override the PlotInfo settings with the PlotSettings and Validate them.

{code}
//Create plot settings
PlotSettings acPS = new PlotSettings(acL.ModelType);
PlotSettingsValidator acPSV = PlotSettingsValidator.Current;

//
//Do what is required with them
//

//New PlotInfo and Validator for Plot Settings
PlotInfo acPI = new PlotInfo();
PlotInfoValidator acPIV = new PlotInfoValidator();

//Overide the default plot settings with that specified
acPI.OverrideSettings = acPS;
//Validate all information
acPIV.Validate(acPI);

//
//Use PlotInfo to plot the page.
//
{code}

Reference
Plot from Model Space
Message 5 of 9
Martin60
in reply to: Martin60

Using your guide I have rewritten my code as I was not able to detect where I had gone wrong.
My original coed would run through and create the plot file but not save the settings.
With my new code I get an error on the last lien so I have still missed something.
Any ideas greatly appreciated.
Thanks
{code}
Dim acLM As LayoutManager
acLM = LayoutManager.Current
'' Get the current layout and output its name in the Command Line window
Dim acL As Layout
acL = acTrans.GetObject(acLM.GetLayoutId(acLM.CurrentLayout), _
OpenMode.ForRead)
''Create plot settings
'PlotSettings
Dim acPS As PlotSettings
acPS = New PlotSettings(acL.ModelType)
'PlotSettingsValidator
Dim acPSV As PlotSettingsValidator
acPSV = PlotSettingsValidator.Current

''
''Do what is required with them
''
acPSV.SetPlotConfigurationName(acPS, sDevice, sSize)
'' Set the plot type
acPSV.SetPlotType(acPS, _
Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
If sDevice Like "*TIFF*" Then
acPSV.SetPlotPaperUnits(acPS, PlotPaperUnit.Pixels)
Else
acPSV.SetPlotPaperUnits(acPS, PlotPaperUnit.Millimeters)
End If
'' Set the plot scale
Dim dDimscale As Double = Application.GetSystemVariable("DIMSCALE")
Select Case sScale
Case "Full"
If dDimscale = 0 Then dDimscale = 1
acPSV.SetUseStandardScale(acPS, False)
acPSV.SetCustomPrintScale(acPS, New CustomScale(1.0, dDimscale))
Case Else
acPSV.SetPlotType(acPS, DatabaseServices.PlotType.Extents)
acPSV.SetUseStandardScale(acPS, True)
acPSV.SetStdScaleType(acPS, StdScaleType.ScaleToFit)
End Select
acPSV.SetCurrentStyleSheet(acPS, sCTBfile)
acPSV.SetPlotRotation(acPS, iRotation)
If bCentre = True Then
acPSV.SetPlotCentered(acPS, bCentre)
Else
acPSV.SetPlotOrigin(acPS, offset)
End If
''New PlotInfo and Validator for Plot Settings
'PlotInfo
Dim acPI As PlotInfo
acPI = New PlotInfo()
'PlotInfoValidator
Dim acPIV As PlotInfoValidator
acPIV = New PlotInfoValidator()
''Overide the default plot settings with that specified
acPI.OverrideSettings = acPS
acPIV.MediaMatchingPolicy = MatchingPolicy.MatchEnabled
''Validate all information
acPIV.Validate(acPI)
{code}
Message 6 of 9
Anonymous
in reply to: Martin60

I've compared your code to mine and the AutoDesk reference.

I've noted that you haven't specified an actual layout to plot.
{code}
//Identify the layout to plot
acPI.Layout = acL.Id
{code}

Also, if the system variable "PSTYLEMODE" is set to 0, the CTB file will error, and you will have to use STB instead.
in the sample below, I have the same plot styles in both ctb and stb.
{code}
//If the System Variable 'PSTYLEMODE' is set to 1, we need to use .ctb settings
if (Convert.ToInt16(Application.GetSystemVariable("PSTYLEMODE")) == 1)
{
acPSV.SetCurrentStyleSheet(acPS, sPens + ".ctb");
}
//else use .stb settings
else
{
acPSV.SetCurrentStyleSheet(acPS, sPens + ".stb");
}
{code}

If you still get an error when referencing the layout, send the entire plot code and I'll have a closer look.
Message 7 of 9
Martin60
in reply to: Martin60

As you noted when I re-wrote the code I had not included the layout.objectID.
Now my functions works as desired in regards to the plot but still does not save the settings so they are visible in the standard plot dialog.
Regards Edited by: Martin60 on Nov 23, 2009 3:35 AM
Message 8 of 9
Anonymous
in reply to: Martin60

Alright, I've had no need to actually display the settings within the plot dialog itself. One thing you could try...(not sure if it will work).

If you can obtain the page setup or Plot Settings (as the API refers to them, see reference below), and identify the default setting, you may be able to alter the settings and save them. Thus making them default for all plots with that particular layout.

> {quote:title=PlotSettings:}{quote}
>A PlotSettings object is similar to a Layout object, as both contain identical plot information and this is because the Layout class is derived from the PlotSettings class. The main difference is that a Layout object has an associated BlockTableRecord object containing the geometry to plot. A PlotSettings object is not associated with a particular BlockTableRecord object. It is simply a named collection of plot settings available for use with any geometry. PlotSettings objects are known as page setups in the AutoCAD user interface and are accessed from the Page Setup Manager.

Edit:
It is possible. The Developer's Guide indicates the following
{code}
'' Update the layout
acLayout.UpgradeOpen()
acLayout.CopyFrom(acPlSet)
''Commit the Transaction!
acTrans.Commit()
{code}
Query and Set Layout Settings

Edited by: DeathTiger on Nov 23, 2009 2:14 PM Edited by: DeathTiger on Nov 23, 2009 2:16 PM
Message 9 of 9
Martin60
in reply to: Martin60

Worked a treat.
Thanks for all your help.
I now need to review and understand.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost