API - How to get swApp total Frame Size?

Discussion in 'SolidWorks' started by SolidWorks Nut, Dec 19, 2007.

  1. Is there a way to get the "Frame" dimensions of the SolidWorks
    application? That is, the working area where its windows are tiled?


    For example, I can get a Model's window position and dimensions
    (FrameLeft, FrameTop, FrameWidth, FrameHeight), but how can I get the
    total width and total height available for it to "fit" in the SW
    application (as if it were maximized)?
     
    SolidWorks Nut, Dec 19, 2007
    #1


  2. Also, having another problem in window arranging - I can't seem to
    cycle through all the open documents. This is really weird.

    Even though the macro returns the "title" correctly for all open
    documents, it only changes the Frame properties of the active
    document. How do I make it activate each open document so that I can
    change its Frame properties???


    Ugh..



    Here's the macro I have so far:






    Public ModelView As Object
    Public DocCount As Integer

    Public swApp As SldWorks.SldWorks
    Public swModelDoc As SldWorks.ModelDoc2
    Public swFrame As SldWorks.Frame
    Public swWindow As SldWorks.ModelWindow
    Public varModelWindows As Variant
    Public vobj As Variant



    Sub ArrangeSolidWorksWindowsNow()

    Set swApp = Application.SldWorks
    Set swFrame = swApp.Frame
    varModelWindows = swFrame.ModelWindows

    TotalNumberOfWindows = swFrame.GetModelWindowCount

    n = 0
    For Each vobj In varModelWindows
    Set swWindow = vobj
    Debug.Print swWindow.Title
    ' Get the model document in this model window
    Set swModelDoc = swWindow.ModelDoc
    Set ModelView = swModelDoc.GetFirstModelView
    ModelView.FrameWidth = 400 + n * 5
    ModelView.FrameHeight = 400 + n * 5
    ModelView.FrameTop = n * 5
    ModelView.FrameLeft = n * 5

    Set swModelDoc = Nothing
    Set ModelView = Nothing
    Set swWindow = Nothing

    n = n + 1
    Next vobj
    End Sub
     
    SolidWorks Nut, Dec 19, 2007
    #2
  3. Philippe Guglielmetti, Dec 20, 2007
    #3

  4. I'm not unfamiliar with code, but stuff like this makes me think
    twice. I'm kinda used to my computer working normally now.
     
    SolidWorks Nut, Dec 20, 2007
    #4





  5. Ok - finally got it to work now. I had the "Show Model Window"
    statement too late in the procedure. Moving it up fixed it.

    Here's the routine (simplified just to show how to cycle through open
    documents and change their Frame properties):



    Public ModelView As Object
    Public swApp As SldWorks.SldWorks
    Public swModelDoc As SldWorks.ModelDoc2
    Public swFrame As SldWorks.Frame
    Public swModelWindow As SldWorks.ModelWindow
    Public varModelWindows As Variant
    Public vobj As Variant

    Sub ManipulateFramesOfOpenDocuments

    Set swApp = Application.SldWorks
    Set swFrame = swApp.Frame
    varModelWindows = swFrame.ModelWindows

    TotalNumberOfWindows = swFrame.GetModelWindowCount

    For Each vobj In varModelWindows
    Set swWindow = vobj

    ' Get the model document in this model window
    Set swModelDoc = swWindow.ModelDoc
    Set ModelView = swModelDoc.GetFirstModelView

    'Here's the title for each window
    Debug.Print swWindow.Title

    ' Show the model window
    swFrame.ShowModelWindow swWindow

    'Get the current windows frame information, or place and size
    the current Window
    Debug.Print ModelView.FrameWidth
    Debug.Print ModelView.FrameHeight
    Debug.Print ModelView.FrameTop
    Debug.Print ModelView.FrameLeft

    Next vobj

    End Sub
     
    SolidWorks Nut, Jan 4, 2008
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.