Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle broken-view macro 1

Status
Not open for further replies.

smcadman

Mechanical
Nov 6, 2002
1,589
Very often I will go to a page that has a broken view and the view is not broken. By that I mean the view still has the broken-view lines, but there is no clear gap between the lines.

See pic:

I have to right-click the view, pick "un-break view", then break the again.

I thought instead of doing this several times a day, a broken-view toggle would be the better way to do this.

Preconditions: view is pre-selected
1. Un-break view
2. Break view

Code:
' ******************************************************************************
' macro recorded on 06/18/08
' ******************************************************************************
Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
boolstatus = Part.Extension.SelectByID2("", "FACE", 0.1035512874926, 0.06293938349189, -1999.382179705, False, 0, Nothing, 0)
Part.UnBreakView
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("", "FACE", 0.09800694802044, 0.06776054825029, -1999.382179705, False, 0, Nothing, 0)
Part.BreakView
Part.ClearSelection2 True
End Sub

The problem is that it only works with the original view. It doesn't work with different views on different pages.

Can anybody help correct this problem?

Flores
 
Replies continue below

Recommended for you

You might want to check and see if Break and Un-Break are always the same shortcut letter in the right-click menu. For example, I almost wrote something to make a shortcut for Select Other, but then I realized that it's always the S key in the right-click menu. So (since I always roll with left hand on keyboard), I can always access Select Other almost as instantly as a single click. I often don't even see the right-click menu open.

That being said, in this case your macro recorder has recorded the location of your selections. That's why it only works on the first view. If you'll get rid of all the code dealing with selections, the macro will work on whatever view you have pre-selected.

Code:
Dim swDwg As SldWorks.DrawingDoc

Sub main()
    Set swDwg = Application.SldWorks.ActiveDoc
    swDwg.UnBreakView
    swDwg.BreakView
End Sub

-handleman, CSWP (The new, easy test)
 
Thank you much Handleman, you've been a big help as always. This "broken-view becoming un-broken" has been around a long time, but now that you helped me with a toggle, it looks like they fixed it.

Because of the non-disclosure agreement I don't think I can post the text of the SPR fixes, but I think my problem may have been fixed with SPR# 391246 in SP4.0

Flores
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor