API Launch "Model View" Function

Hello

 

I've been looking for 3 hours without making too much progress on my problem so I'm coming to ask the community for help ...

 

Here I am writing a Macro to open a MeP, launch the "Model View" function and manually select, or not, the file to attach. And let the user choose the palette view until the dialog box closes. To finish with a recording in a specific format and in the repertoire of my choice.

 

I know how to open a drawing, I can manage to insert a view, from the front or from the side, of the room. But I don't know how to launch the Model View function. I think that to wait for the function to close you just have to do a "RunCommand" it's surely possible with "DoEvents" but more complicated isn't it?

Below is the sketch of the macro I would like:

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long


Sub main()

Set swApp = Application.SldWorks


Set Part = swApp.NewDocument("Chemin Mise en plan", 12, swSheetWidth, swSheetHeight)
Dim swDrawing As DrawingDoc

Set swDrawing = Part

Dim swSheet As sheet
Set swSheet = swDrawing.GetCurrentSheet()
swSheet.SetProperties2 12, 12, 1, 50, False, swSheetWidth, swSheetHeight, True
swSheet.SetTemplateName "Chemin Template Mise en plan"
swSheet.ReloadTemplate True
swApp.ActivateDoc2 "Mise en plan1 - Feuille1", False, longstatus

Set Part = swApp.ActiveDoc

'Création de la Vue du modèle 3D, suivant vue de Face
Dim myView As Object
Set myView = Part.CreateDrawViewFromModelView3("Chemin Du modèle", "*Face", 0.25044660101369, 0.215512710674157, 0)
'C'est ici qu'il faudrait un RunCommand ou DoEvent pour éditer la Vue


' Save As                      Chemin fixe, nom suivant le fichier source
longstatus = Part.SaveAs3("Chemin d'enregistrement", 0, 0)
Part.ClearSelection2 True

' Close Document
Set swDrawing = Nothing
Set Part = Nothing
swApp.CloseDoc "F85162706 - Feuille1"
End Sub

 

I hope I have been clear. Basically, my final request is to make the oxy-cuts of my company, not all the sheet metal is made with the same plan so I have to let the user choose the right plan to not end up with a 6x2000 flat instead of 500x2000 thickness 6.

 

Sincerely, Mandrake.

Small code updates, here are the lines I need but I can't get my Loop to work.

 

Set Part = swApp.ActiveDoc
    Set swModelDocExt = Part.Extension

    'lance la fonction que je veux comme il faut
RefPlan = swModelDocExt.RunCommand(swCommands_ModelView, "")

    'ici ca bug, impossible de détecter si la fonction 'swCommands_ModelView' es toujours active
    Do
        DoEvents
    Loop Until RefPlan = False


' Save As