Revit API

Reply
Valued Contributor
russ.green
Posts: 97
Registered: ‎02-27-2010
Message 1 of 6 (325 Views)

Printing active view

325 Views, 5 Replies
10-03-2012 12:38 AM

I'm writing a drawing issue tool and having troubles with my PDF printing to PDFCreator.

 

Basically my addin loops through the sheets to be issued then for each sheet exports DWG, DWF, prints to PDF and will also print.

 

DWG and DWF exporting all OK with the activeview but printing is hit and miss.  does not always detect the active view.

 

Dim thisdoc As Document = uidoc.Document

Using trans As New Transaction(doc, "Export Sheets")

trans.Start()
If Me.chkExportDWG.Checked = True Then ExportDWG(sbFile.ToString & ".dwg")
If Me.chkExportDWF.Checked = True Then ExportDWF(sbFile.ToString & ".dwf", GetSheetsize(sheet, doc), thisdoc)
If Me.chkExportPDF.Checked = True Then ExportPDF(sbFile.ToString & ".pdf", sheet.SheetNumber, thisdoc, thisdoc.ActiveView)
If Me.chkPrint.Checked = True Then PrintSheet(sheet, thisdoc)
trans.Commit()
End Using

 

Private Sub ExportPDF(ByVal ExportFileName As String, ByRef sheetnumber As String, ByRef thisdoc As Document, ByRef thisview As Autodesk.Revit.DB.View)

 

'handle page setups etc

 

ptManager.SubmitPrint(thisview)

 

end sub

 

Now when I debug thisview exists but I sometimes get an error that no views are selected.   Any advice here would be a big help....

 

Russ

Russ Green
ADN Support Specialist
Joe.Ye
Posts: 334
Registered: ‎03-05-2010
Message 2 of 6 (300 Views)

Re: Printing active view

10-10-2012 08:31 AM in reply to: russ.green

 

HI Russ,

 

In which condition the error occurs? 

Not sure if this is caused by not setting the print range.

 

This is the code to set the print range, the print it.

 

PrintManager manager = Document.PrintManager;
manager.PrintRange = PrintRange.Select;
manager.SubmitPrint(view);

 

Document.PrintManager returns a new PrintManager object., so you needt to set it to an PrintManager object, and set the print range and submit the print to the same PrintManager object.

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Valued Contributor
russ.green
Posts: 97
Registered: ‎02-27-2010
Message 3 of 6 (298 Views)

Re: Printing active view

10-10-2012 08:33 AM in reply to: russ.green

thanks.

 

I'll test this again and report back

Russ Green
Valued Contributor
russ.green
Posts: 97
Registered: ‎02-27-2010
Message 4 of 6 (287 Views)

Re: Printing active view

10-11-2012 01:04 AM in reply to: russ.green

Even with PrintRange.Select things are still a little unreliable.

Russ Green
ADN Support Specialist
Joe.Ye
Posts: 334
Registered: ‎03-05-2010
Message 5 of 6 (267 Views)

Re: Printing active view

10-15-2012 07:40 AM in reply to: russ.green

HI Russ,

 

I doubt that some views that cause error is that they are not real view but view template. Please check if the View.IsTemplate property is true. Please skip when it is a view template.

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Valued Contributor
russ.green
Posts: 97
Registered: ‎02-27-2010
Message 6 of 6 (265 Views)

Re: Printing active view

10-15-2012 07:44 AM in reply to: Joe.Ye

my app is only concerned with sheets so i loop through the sheets in the project making each one the active view in turn and exporting the sheet to different formats...i'll add this check in though and give things another test....

Russ Green
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.