Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modifying PrintParameters

1 REPLY 1
SOLVED
Reply
Message 1 of 2
BobbyC.Jones
560 Views, 1 Reply

Modifying PrintParameters

I'm having trouble setting PrintParameter values.  The following code runs, and the PrintSetup saves, but the PageOrientation value never changes to Portrait.  What am I missing?  Thanks.

 

 

Document activeDoc = commandData.Application.ActiveUIDocument.Document;

var trans = new Transaction(activeDoc, "PrintSettings");
trans.Start();
activeDoc.PrintManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = PageOrientationType.Portrait;
activeDoc.PrintManager.PrintSetup.SaveAs("MyPrintSettings");
PrintSetting myPs = activeDoc.GetPrintSettingIds(). Select(activeDoc.get_Element). Cast<PrintSetting>(). FirstOrDefault(printSetting => printSetting.Name == "MyPrintSettings");
activeDoc.PrintManager.PrintSetup.CurrentPrintSetting = myPs; trans.Commit();
--
Bobby C. Jones
1 REPLY 1
Message 2 of 2
BobbyC.Jones
in reply to: BobbyC.Jones

A quick perusal through the ADN knowledge base and the answer is found.  Apparently each call to a Document's PrintManager property generates a new PrintManager object.  It needs to be cached and all calls should be made to the cached object.

 

 

PrintManager pm = activeDoc.PrintManager;

pm.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = PageOrientationType.Portrait;
--
Bobby C. Jones

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


Rail Community