Print Setup - PrintParameters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.