I would like to click a button (or keyboard shortcut) and it will zoom to view a model or drawing to actual scale size on my computer screen monitor.
I've found two posts about this:
It appears that another CAD program can do this with a macro:
I'm not very experienced with creating macros, and I have no idea how to look up the internal value that gets or sets the Solid Edge zoom level.
I will have a look at the SolidWorks macro you pointed to - there are multiple versions shared in that discussion.
Moreover, swp files are encrypted so SW is required to open them and I don't have access to SW readily, but I will manage.
After this, writing the equivalent API calls for Solid Edge should be easy, if those are available.
Let's hope it works for SE too
Here's what the latest version of the shared SW macro looks like and does:
It permits the user to set the view scale, then updates the view - see the line in bold.
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swModView As SldWorks.ModelView Sub main() Set swApp = CreateObject("SldWorks.Application") Set swModel = swApp.ActiveDoc Set swModView = swModel.ActiveView swModView.Scale2 = 0.25 ' Change scale value here swModel.GraphicsRedraw2 End Sub
Is this good enough?
Writing the SE equivalent code will take just under a minute.
@sryp Do you have a commercial license for Solid Edge or are you using Free2D or the Student Version? I ask because I noticed your signature states you are running ST7 MP0 which usually indicates someone who does not have access to the patches and thus a "free" license which does not have an API available to run macros/addins.
Yes I have a commercial liscence. We've stopped subscribing to maintenance updates a few years ago (c. 2014?...before I started here). Apparently we're upgrading our decade-old computers soon, which I think would be a good time to upgrade SE as well.
Yes I have run macros many times here. My favorite one so far is SEExplore.
OK. Now that Ken's genuine doubt about the license type is out of way, here's the equivalent code in Solid Edge for the SW macro:
Imports SolidEdgeFramework Imports SolidEdgeFrameworkSupport Module Module1 Dim seApp As SolidEdgeFramework.Application = Nothing Dim seDocument As SolidEdgeDocument = Nothing Sub Main() seApp = Runtime.InteropServices.Marshal.GetActiveObject("SolidEdge.Application") seDocument = seApp.ActiveDocument Dim seActiveWindow As SolidEdgeFramework.Window = seApp.ActiveWindow Dim seView As View = seActiveWindow.View Dim seViewScale As Double = Convert.ToDouble(InputBox("Enter View Scale", "View Scale", "1.0")) seView.ZoomCamera(seViewScale) End Sub End Module
Also attached is the macro that can be readily run, see seViewScale.zip at the end of this message.
The macro will prompt for a scale factor and update the current view in Solid Edge accordingly.
1. Absolutely no error checks, no notifications.
2. Works with all 3D documents - Part, Sheetmetal, Assembly.
3. Does not work with Draft.
Thanks for the work on this, Tushar.
It appears that this macro will just zoom in/out a multiplied ratio to what is currently zoomed.
Eg., let's say I'm currently zoomed at 1.0. If I run the macro and set it to 2.0, it will zoom in double (i.e. everything appears twice as large as before). This seems correct behaviour so far...
However, when I now run the macro a second time and put in 2.0, it will again zoom in 2.0, so now we're at 4.0.
My desired operation is that no matter where/how I am zoomed in, it will zoom in/out to an ABSOLUTE zoom level value, so I can quickly and easily 'visualize' what real size looks like.
I wonder if there is a way to use the bounding box?
May I ask why this can't work in Draft also? My guess is different commands/functions for the different environment.