Get size and position of windows from open parts / assemblies

Get size and position of windows from open parts / assemblies

GeorgK
Advisor Advisor
710 Views
5 Replies
Message 1 of 6

Get size and position of windows from open parts / assemblies

GeorgK
Advisor
Advisor

Hello together,

 

is there a way to store the position, zoom and size of all open windows?

 

Window.png

 

Thank you

 

Georg

0 Likes
Accepted solutions (1)
711 Views
5 Replies
Replies (5)
Message 2 of 6

CCarreiras
Mentor
Mentor

HI!

 

Automatically no, there's no tool to do all that all at once, but...

 

To have the same zoom, you can create Representations Views with a defined position and Zoom.

To Have all the windows with the same size, go to View panel and select Tile All, or TIle Horizontal/Vertical

CCarreiras

EESignature

0 Likes
Message 3 of 6

wayne.brill
Collaborator
Collaborator

Hi Georg,

 

You can get the size and location of windows using the Views of the Application:

 

Public Sub Views_Test()
    Dim oViews As Views
    Set oViews = ThisApplication.Views
   
    Dim oView As View
    For Each oView In oViews
        Debug.Print oView.Caption
        Dim Top As Long
        Dim Left As Long
        Dim Height As Long
        Dim Width As Long
        Call oView.GetWindowExtents(Top, Left, Height, Width)
               
        Debug.Print Top
        Debug.Print Left
        Debug.Print Height
        Debug.Print Width
    Next
   
End Sub

 

You could store and retrieve the data in each document using attributes. See this topic in the API help:

Inventor API User's Manual > Custom Data > Working with Attributes

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 6

GeorgK
Advisor
Advisor

Hello Wayne,

 

thanks for your help. I tried it. Why is the new form smaller when I use the values for top, left, height and width?

 

Georg

0 Likes
Message 5 of 6

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi Georg,

 

Yes I see the behavior. However in my tests I see height and width increasing in size by 4 each time I run the code.

 

Instead of using GetWindowExtents just get the values directly. This kept the sizes the same in my test.  (loops 10 times to test)

 

 Public Sub Views_Test2()
    
    Dim oActView As View
    Set oActView = ThisApplication.ActiveView
       
    Dim oViews As Views
    Set oViews = ThisApplication.Views
    
    Dim oView As View
    Dim i As Integer
    For i = 0 To 10
    For Each oView In oViews
        Debug.Print oView.Caption
        Dim Top As Long
        Top = oView.Top
        Dim Left As Long
        Left = oView.Left
        Dim Height As Long
        Height = oView.Height
        Dim Width As Long
        Width = oView.Width
              
        Debug.Print Top
        oView.Top = Top 
        Debug.Print Left
        oView.Left = Left
        Debug.Print Height
        oView.Height = Height 
        Debug.Print Width
        oView.Width = Width 

    Next
    Next i
    
End Sub

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 6 of 6

GeorgK
Advisor
Advisor

Hello Wayne,

 

thanks. That solves the problem.

 

Georg

0 Likes