API - How to edit the active view

API - How to edit the active view

youri_chalon
Explorer Explorer
809 Views
3 Replies
Message 1 of 4

API - How to edit the active view

youri_chalon
Explorer
Explorer

Hello,

in my company we only use Excel for the ellaboration of our calculation notes. In order to explain or help our clients to understand what we are doing we took the habit to screen all our simple load cases with the Robot capture tool. In Robot 2016  this is a really annoying process which make decent lose of time when any change is done. 

 

Having only recently discovered the ROBOT API, I decided as my first attempt, to automatise throught VBA the importation of pictures of our structures  ( then the editing only through vba).

 

I have encountered some end points throught my research which brought me there 🙂

 

First I found How to take Screens:

 

 
Dim RobApp As RobotApplication
    Set RobApp = New RobotApplication
    Dim t As RobotView
    
    ' Création des paramètres de capture d'écran
    Set paramCaptureEcran = CreateObject("Robot.ViewScreenCaptureParams")
    
    ' Définition des paramètres de capture d'écran (facultatif)
    paramCaptureEcran.Comment = "Capture d'écran de la vue graphique"
    'paramCaptureEcran.IncludeDateAndTime = True
    'paramCaptureEcran.Name = "Capture_vue_graphique"
    'paramCaptureEcran.Orientation = 1          ' 1 pour paysage, 2 pour portrait
    'paramCaptureEcran.Resolution = 1           ' Résolution de capture (1 pour standard, 2 pour haute)
    'paramCaptureEcran.ScaleAutomatic = True    ' True pour échelle automatique, False pour échelle définie par l'utilisateur
    'paramCaptureEcran.ScaleValue = 1.0         ' Valeur d'échelle définie par l'utilisateur
    

 

 

But to actually take the screen of what I want I tried different solutions:

 

  • With the view manager Method

 

 
  Dim nViews As Long
    nViews = RobApp.Project.ViewMngr.ViewCount
    
    Workbooks.Add
    
    For I = 1 To nViews
    
            Set t = RobApp.Project.ViewMngr.GetView(I)
            
            t.CopyToClipboard
            't.MakeScreenCapture paramCaptureEcran
            
            'Then the pasting/editing throught excel

    Next I

 

Getting always the same image.

 

  • With the case Selection Method

 

 
    Dim Structure As RobotStructure, CaseSelection As RobotSelection
    Dim Cases As RobotCaseServer, SimpleCase As RobotSimpleCase
    
    Set Structure = RobApp.Project.Structure
    Set Cases = Structure.Cases
    Set CaseSelection = Structure.Selections.CreatePredefined(I_PS_CASE_SIMPLE_CASES)
    
    If CaseSelection.Count = 0 Then
        MsgBox "No loadcase opened"
        Exit Sub
    End If
  
    For I = 1 To CaseSelection.Count
        CaseNo = CaseSelection.Get(I)
        Set SimpleCase = Cases.Get(CaseNo)
        
        With SimpleCase
          If .AnalizeType = I_CAT_DYNAMIC_MODAL Then GoTo NextCase
        End With
        
        ' ACCESS TO VIEW OF THE CASE ??
        Set t = RobApp.Project.ViewMngr.GetView(1)
        t.CopyToClipboard
    

 

 

Which I just didn't find how to link it with an actual change how the view

 

I think I found a decent base but I struggle to understand how the active view of the screen is accessible throught the IDE. Is it even possible to change view, or rotate/translate/zoom the structure like that?

 

 

Many many thanks in advance

 

Ps: you'll find the complete excel macro joined to this post. To use it you need to setup your Robot screen (NOT in full screen!) and click the button. An other issue I encountered 😕

youri_chalon_0-1710491554381.png

 

 
0 Likes
Accepted solutions (1)
810 Views
3 Replies
Replies (3)
Message 2 of 4

Stephane.kapetanovic
Mentor
Mentor

hi @youri_chalon 

There are numerous topics covering print engines, views, parameters, and attributes.

To get the active view number, you can refer to the following code snippet.

Function ActiveViewNumber()
  For i = 1 To ViewMngr.ViewCount
    If ViewMngr.GetView(i).Window.IsActive <> 0 Then
      ActiveViewNumber = i: Exit Function
    End If
  Next i
  ActiveViewNumber = 1
End Function

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 4

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

See Also : 

(API) Command VBA Projection Capture of a view

 

Robot API - set display flags of current view 

(API) Command VBA Projection Capture of a view - msg 146 

Save updating screen capture to file - msg 9 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 4 of 4

youri_chalon
Explorer
Explorer

Thanks a lot, didn't find yet any related topics on the forum

0 Likes