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)?
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
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
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
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
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.