Export sheets combining progress status

Export sheets combining progress status

atk_vinay.krishna
Enthusiast Enthusiast
1,113 Views
6 Replies
Message 1 of 7

Export sheets combining progress status

atk_vinay.krishna
Enthusiast
Enthusiast

Experts,

 

I am using below code to produce the sheet into combined DWF, 

 

ViewSet vset = new ViewSet();
foreach (var v in data)
{
ViewSheet vs = _doc.GetElement(new ElementId(v.Key)) as ViewSheet;
if (vs != null)
{
vset.Insert(vs);
}
}
if(vset.Size > 0)
{
string filenamedwf = "DWF_Binded-" + DateTime.Now.ToString("yyyyMMdd");
DWFExportOptions op = new DWFExportOptions();
op.MergedViews = true;
op.CropBoxVisible = false;
_doc.Export(path_dwf, filenamedwf, vset, op);
vset.Dispose();
}

 

Is there any way to check the status of number combining ..?

0 Likes
Accepted solutions (1)
1,114 Views
6 Replies
Replies (6)
Message 2 of 7

RPTHOMAS108
Mentor
Mentor

I don't know of a direct way.

 

You could try subscribing to the  Application.ProgressChanged event. This event reports the progress of the Revit progress bar that sometimes appears bottom left. I don't know that this is used when views are printed via the UI or API. I've also got a vague recollection that it shows progress per view but if that is the case you would count the 100%'s.

 

The ViewPrinting and ViewPrinted events state that they raise only once for a collection of views combined.

 

Could also try ViewExported event this doesn't state the same as the printing events above.

0 Likes
Message 3 of 7

atk_vinay.krishna
Enthusiast
Enthusiast

thanks for the reply, do you have any sample 🙂

0 Likes
Message 4 of 7

vkelani
Contributor
Contributor

What I do for these purposes is make a form with progressbar on it and call performstep() at the end of each foreach(your code), also make sure to set the maximum size of the progress bar to vset.size and you can display the status in label like combining (i/vset.size). Also make sure you are showing Form.show() and not showdialog() plus to refresh the form in the loop.

 

Cheers!

Vishal Kelani 

0 Likes
Message 5 of 7

RPTHOMAS108
Mentor
Mentor
Accepted solution

Below is for demonstration purposes to keep it all as code, I wouldn't do it this way in reality. The sample mimics the progress bar by creating a copy of it centre parent.

 

There are various steps for each view printed therefore you may want to look at the 'Stage'  and 'Caption' properties of the event args to understand how many stages there typically are per view. You know how many views you have to start with so you can use this further analysed information accordingly to determine the progress through those views. Caption may change multiple times for each view.

 

 

 

Private IntCancelButton As Button = Nothing
    Private IntPB As ProgressBar = Nothing
    Private IntTB As TextBlock = Nothing
    Private IntCancel As Boolean = False
    Private Sub PChg(s As Object, e As Autodesk.Revit.DB.Events.ProgressChangedEventArgs)
        IntPB.Minimum = e.LowerRange
        IntPB.Maximum = e.UpperRange
        IntPB.Value = e.Position
        IntTB.Text = e.Caption

        IntCancelButton.IsEnabled = e.Cancellable
        If IntCancel AndAlso e.Cancellable Then
            e.Cancel()
        End If

        Windows.Forms.Application.DoEvents()
    End Sub

    Private Function GetProgresBarWindow(ParentHwnd As IntPtr) As Window
        Dim Wn As New Window With {.WindowStartupLocation = WindowStartupLocation.CenterOwner,
                                     .WindowStyle = WindowStyle.None,
                                     .SizeToContent = SizeToContent.WidthAndHeight,
                                     .ResizeMode = ResizeMode.NoResize}

        IntPB = New ProgressBar
        IntTB = New TextBlock

        Wn.BorderThickness = New Thickness(8)
        Wn.BorderBrush = New Windows.Media.SolidColorBrush(Colors.LightGray)

        Dim Gr As New Controls.Grid
        Gr.ColumnDefinitions.Add(New Controls.ColumnDefinition With {.Width = New GridLength(400)})
        Gr.ColumnDefinitions.Add(New Controls.ColumnDefinition With {.Width = New GridLength(75)})
        Gr.RowDefinitions.Add(New Controls.RowDefinition With {.Height = New GridLength(30, GridUnitType.Auto)})
        Gr.RowDefinitions.Add(New Controls.RowDefinition With {.Height = New GridLength(35, GridUnitType.Auto)})

        Gr.Children.Add(IntTB)
        IntTB.SetValue(Controls.Grid.RowProperty, 0)
        IntTB.SetValue(Controls.Grid.ColumnProperty, 0)
        IntTB.SetValue(Controls.Grid.ColumnSpanProperty, 2)
        IntTB.Margin = New Thickness(3)
        IntTB.Height = 40

        Gr.Children.Add(IntPB)
        IntPB.SetValue(Controls.Grid.RowProperty, 1)
        IntPB.SetValue(Controls.Grid.ColumnProperty, 0)
        IntPB.Margin = New Thickness(3)
        IntPB.Height = 35

        Dim CloseIt = Sub(s As Object, e As RoutedEventArgs)
                          IntCancel = True
                      End Sub

        IntCancelButton = New Controls.Button With {.Content = "Cancel"}
        Gr.Children.Add(IntCancelButton)
        IntCancelButton.SetValue(Controls.Grid.RowProperty, 1)
        IntCancelButton.SetValue(Controls.Grid.ColumnProperty, 1)
        IntCancelButton.Height = 35
        AddHandler IntCancelButton.Click, CloseIt

        Wn.Content = Gr
        Dim HelperWn As New Interop.WindowInteropHelper(Wn)
        HelperWn.Owner = ParentHwnd

        Return Wn
    End Function


    Public Function TObj95(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result

        Dim Doc As Document = commandData.Application.ActiveUIDocument.Document
        AddHandler commandData.Application.Application.ProgressChanged, AddressOf PChg

        Dim IntPbarWn As Window = GetProgresBarWindow(commandData.Application.MainWindowHandle)
        IntTB.Text = "The progress is..."

        Dim VS As New ViewSet
        Dim FEC As New FilteredElementCollector(Doc)
        Dim ECF As New ElementClassFilter(GetType(ViewSheet))

        Dim Els As List(Of ElementId) = FEC.WherePasses(ECF).ToElementIds

        For i = 0 To Els.Count - 1
            Dim Vsht As ViewSheet = Doc.GetElement(Els(i))
            If Vsht.IsTemplate Then Continue For Else

            VS.Insert(Vsht)
        Next
        IntPbarWn.Show()

        Dim DN As String = "c:\temp"
        Dim Path As String = Guid.NewGuid.ToString

        Using Tx As New Transaction(Doc, "Print")
            If Tx.Start = TransactionStatus.Started Then
                Doc.Export(DN, Path, VS, New DWFExportOptions() With {.CropBoxVisible = False, .MergedViews = True})
                Tx.RollBack()
            End If
        End Using

        VS.Dispose()
        IntPbarWn.Close()

        RemoveHandler commandData.Application.Application.ProgressChanged, AddressOf PChg

        Return Result.Succeeded
    End Function

 

 

 

Message 6 of 7

atk_vinay.krishna
Enthusiast
Enthusiast

Much appreciated your effort, as per your suggestion i have tracked the sheet status by its caption and it worked for me.  

Thank you all 🙂

0 Likes
Message 7 of 7

ivo.lafeber
Advocate
Advocate

Is there also an option for the progress bar to see the IFC export progress ? 

0 Likes