Opening drafts in inactive mode

Creator
Creator

Hi, 

 

I've been writing a small code to convert all draft files in a folder to PDFs. The code works fine. But the problem is that if one of the files has views that are not updated or is detached from its source, I have to manually click OK for the message box displayed by SE before the code can continue. The workaround would be to open the  draft file as inactive. Is there a way to specify this when using the application.document.open(*pathname*)??

 

The code is as follows:

Imports System.IO

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim str As String()
Dim app As SolidEdgeFramework.Application = Nothing
Dim draft As SolidEdgeDraft.DraftDocument
Dim fname As String
Dim ext As String

Dim i As Integer = 0

If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
'Process.Start("explorer.exe", FolderBrowserDialog1.SelectedPath)
str = IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath)
app = SolidEdgeCommunity.SolidEdgeUtils.Connect(True, False)
For i = 0 To str.Count - 1
ProgressBar1.Minimum = 0
ProgressBar1.Maximum = 100
ProgressBar1.Value = i / (str.Count - 1) * 100
ext = System.IO.Path.GetExtension(str.ElementAt(i))
fname = str.ElementAt(i)
If ext = ".dft" Then
app.Documents.Open(fname)
draft = app.ActiveDocument
fname = FolderBrowserDialog1.SelectedPath + "\" + Path.GetFileNameWithoutExtension(fname) + ".pdf"
draft.SaveAs(fname)
draft.Close(False)
End If
Next i
str = Nothing
app = Nothing
draft = Nothing
fname = Nothing
ext = Nothing
i = Nothing
MsgBox("Completed")
Else
MsgBox("No folder selected")
End If

End Sub
End Class

3 REPLIES

Re: Opening drafts in inactive mode

Set the Solid Edge Application in the right mode:

SEapplication.DisplayAlerts = False
'do something here


SEapplication.DisplayAlerts = True

Greetings from Switzerland

 

Matthias

Re: Opening drafts in inactive mode

Creator
Creator

Hi Matthias,

 

Thanks for the reply. Solved my problem.

But I was wondering whether opening the drafts in inactive mode would speed up the process?

 

Govind

Re: Opening drafts in inactive mode

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I have not personally tried it but I would give the following code a try.

 

Application.SetGlobalParameter(SolidEdgeConstants.ApplicationGlobalConstants.seApplicationGlobalSessionDraftOpenInactive, true)
Jason Newell
Applications Architect
www.jasonnewell.net