Save As for each view -- how 2 wait for SE !

Valued Contributor
Valued Contributor

 

One Big Problem, googled, searched in forum - nothing found !

I'd like to save each drawing view with the "saveas" method to iges,

it works if I make a breakpoint on save as !!!, because SE needs some time to open the view

with the StartCommand, (haven't found any mathod for opening the view into viewedit).

So how can i find out SE is busy?

 

 Dim views As SolidEdgeDraft.DrawingViews = DraftDoc.ActiveSheet.DrawingViews

        For i As Integer = 1 To views.Count

 

            Dim view As SolidEdgeDraft.DrawingView = views.Item(i)

 

            Dim NewFullName As String = IgesPath & FileName & "_" & i & ".igs"

            If System.IO.File.Exists(NewFullName) = True Then

                System.IO.File.Delete(NewFullName)

            End If

 

            Dim ActiveWindowName As String = SE_App.ActiveWindow.Caption

            'OpenView

            view.Select()

            SE_App.StartCommand(40037)

 

            'SE fnished??

 

            'Save Iges

            DraftDoc.SaveAs(NewFullName) 'BREAK

 

            'CloseView

            SE_App.ActiveWindow.close()

            DraftDoc.SelectSet.RemoveAll()

        Next

 

Posted by: Linus Hechinger
Post date: 8/23/2010 11:09:07 PM

4 REPLIES

RE: Save As for each view -- how 2 wait for SE !

Valued Contributor
Valued Contributor

You could try to use Events.

 

Try to find out (using Solid Egde Spy) which events are fired, and when. If one of this events is usefull to you, you can use this to set for instance a pulic Boolean. In your code you check this Boolean (via a do-while or so), and if the Boolean is set to true by the event your code can continue.

 

You can read about working with events in the SE programming guide.

 

Good luck

 

Posted by: Wouter Sloof
Post date: 8/24/2010 10:28:50 PM

RE: Save As for each view -- how 2 wait for SE !

Valued Contributor
Valued Contributor

 

Hi,

 

the Idea of ErWo is good. But you can do this without events, like this:

 

Dim test As String = SE_App.ActiveEnvironment

Do While test "DrawingViewEdit" 'was the environment changed?

test = SE_App.ActiveEnvironment

Loop

 

and after closeView (window):

 

Do While test "Detail" 'back?

test = SE_App.ActiveEnvironment

Loop

 

Posted by: JR
Post date: 8/26/2010 10:27:15 PM

RE: Save As for each view -- how 2 wait for SE !

Valued Contributor
Valued Contributor

 

I have a hunch that it will work as expected if you call Application.DoIdle() after calling Application.StartCommand().

Give it a try and let us know.

 

Posted by: Jason Newell
Post date: 9/7/2010 9:35:16 PM

RE: Save As for each view -- how 2 wait for SE !

Valued Contributor
Valued Contributor

The answer to waiting for a command to finish after calling StartCommand() is to sink the ApplicationEvents and watch for the command to come through AfterCommandRun event.

 

Posted by: Jason Newell
Post date: 9/14/2010 7:43:15 PM