
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a problem that i have spent days trying to get working... thinking it is working and then continuously finding bugs with it.
I have created a viewsheet that I want to print...
Setup my printmanager...
and selected the print range - print to view/sheets
... but I can't get it to save the viewsheetsetting correctly in all cases of weither the user has
In-Session or a saved print set enabled.
The code bellow gets me most of the way but, for some reason i need to manually press "OK" in the image bellow and then run the code to get it to work.
otherwise the viewsheetsettings are not saved when In-Session is enabled and it returns an error, "No views/sheets selected for printing";
I have looked at the viewprinter sample and cant find anything to solve this problem.
This has been a nightmare trying to solve so if there is anyone with a working sample of code or any suggestions i would greatly appreciate it.
FilteredElementCollector printSetFilter = new FilteredElementCollector(doc); printSetFilter.OfClass(typeof(View));
ViewSet vwSet = new ViewSet();// to be assigned to IViewSheetSet foreach (Element item in printSetFilter) { if (item is ViewSheet) { ViewSheet vw = (ViewSheet)item; if (vw.SheetNumber == newSheetNumber)// newSheetNumber is of the sheet i have created. { vwSet.Insert(vw); // place our new viewsheet in set } } } ViewSheetSetting newviewSheetSetting = printManager2.ViewSheetSetting; IViewSheetSet vsheetset = newviewSheetSetting.CurrentViewSheetSet; if (vsheetset.Equals(newviewSheetSetting.InSession))// checking to see if InSession is enabled { // there is no boolean return for insession? vsheetset = newviewSheetSetting.InSession; newviewSheetSetting.InSession.Views = vwSet; try { newviewSheetSetting.Save(); } catch { } vsheetset.Views = vwSet; } else { newviewSheetSetting.CurrentViewSheetSet.Views = vwSet; try { newviewSheetSetting.Save(); } catch { } vsheetset.Views = vwSet; }
Thank you
Solved! Go to Solution.