Print Setup - PrintParameters

Print Setup - PrintParameters

stephen_harrison
Advocate Advocate
528 Views
1 Reply
Message 1 of 2

Print Setup - PrintParameters

stephen_harrison
Advocate
Advocate

I hope someone within the community can help?
I have a simplified Print Setup form to test some code based on the ViewPrinter Sample. The form contains a combobox to select a Print Setup and a series of checkboxes to represent a number of the PrintSetup.CurrentPrintSetting.PrintParameters. The principle of the code is below from my simplified test

 

private void Form1_Load(object sender, EventArgs e)
{
PrintSetupcomboBox.DataSource = PrintSettingNames;
PrintSetupcomboBox.SelectedItem = SettingName;
GetSettings();
}

 

private void PrintSetupcomboBox_SelectedValueChanged(object sender, System.EventArgs e)
{
m_printData.SettingName=PrintSetupcomboBox.Text;
GetSettings();
}

 

private void GetSettings()
{
ViewLinksInBluecheckBox.Checked = m_printData.
PrintMgr.PrintSetup.CurrentPrintSetting.PrintParameters.ViewLinksinBlue;
HideRefWorkPlanescheckBox.Checked = m_printData.
PrintMgr.PrintSetup.CurrentPrintSetting.PrintParameters.HideReforWorkPlanes;
HideUnreferencedViewTagscheckBox.Checked = m_printData.
PrintMgr.PrintSetup.CurrentPrintSetting.PrintParameters.HideUnreferencedViewTags;
HideScopeBoxcheckBox.Checked = m_printData.
PrintMgr.PrintSetup.CurrentPrintSetting.PrintParameters.HideScopeBoxes;
HideCropBounariescheckBox.Checked = m_printData.
PrintMgr.PrintSetup.CurrentPrintSetting.PrintParameters.HideCropBoundaries;
}

 

Class PrintData
public List<string> PrintSettingNames
{
get
{
List<string> names = new List<string>();
ICollection<ElementId> printSettingIds = m_commandData.Application.ActiveUIDocument.Document.GetPrintSettingIds();
foreach (ElementId eid in printSettingIds)
{
Element printSetting = m_commandData.Application.ActiveUIDocument.Document.GetElement(eid);
names.Add(printSetting.Name);
}
names.Add(ConstData.InSessionName);
return names;
}
}


public string SettingName
{
get
{
IPrintSetting setting = m_printMgr.PrintSetup.CurrentPrintSetting;
return (setting is PrintSetting) ? (setting as PrintSetting).Name : ConstData.InSessionName;
}
set
{
if (value == ConstData.InSessionName)
{
m_printMgr.PrintSetup.CurrentPrintSetting = m_printMgr.PrintSetup.InSession;
return;
}
ICollection<ElementId> printSettingIds = m_commandData.Application.ActiveUIDocument.Document.GetPrintSettingIds();
foreach (ElementId eid in printSettingIds)
{
Element printSetting = m_commandData.Application.ActiveUIDocument.Document.GetElement(eid);
if (printSetting.Name.Equals(value))
{
m_printMgr.PrintSetup.CurrentPrintSetting = printSetting as PrintSetting;
}
}
}
}


My problem is that the Print Parameters are not returning the correct result for the selected Print Set i.e. those set within Revit Printer.
I can only surmise that there is something wrong with the setting of CurrentPrintSetting?
Any help would be much appreciated as I have been struggling with this for some time.

0 Likes
529 Views
1 Reply
Reply (1)
Message 2 of 2

stephen_harrison
Advocate
Advocate

UPDATE

 

Having carried out some further testing of this simplified print programme i have identified the following:
Form opens with In-session Print Setup The PrintParameters are displayed correctly.
However when i change the selection through the combobox the PrintParameters remain the same as for In-session.
When I change the selection through the combobox again the PrintParameters display those for my previous selection.
When I change the selection through the combobox again the PrintParameters display those for my previous selection etc.

 

Any ideas as to what may be causing this?

Please any help would be of great assistance.

0 Likes