Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Control Q - Save Macro? 2

Status
Not open for further replies.

Ebbie22

Mechanical
Oct 24, 2007
29
I’ve been experiencing problems with SW2009 where the views aren’t matching the model. From what I can tell it seems to fix itself if you hide the views and show them again or if you do a Control Q on the model and go back to the drawing… To help with this issue I’m wondering if anyone has a Macro that has a build in Control Q Then Save option? (FYI, I’m already using SP 3.0)
 
Replies continue below

Recommended for you

Somebody was kind enough to write me up one when I asked quite some time ago. I feel bad given that I can't remember who wrote it, because they did an excellent job. I would be remiss if I didn't offer it up to you and equally remiss if I tried to take credit for it.

Joe Hasik, CSWP/SMTL
SW 09 x64, SP 3.0
Dell T3400
Intel Core2 Quad
Q6700 2.66 GHz
3.93 GB RAM
NVIDIA Quadro FX 4600

 
Same problem here. I fix it with a macro that hides then re-shows every view on the active sheet.

Code:
Dim swApp As SldWorks.SldWorks
Dim swDwg As SldWorks.DrawingDoc
Dim vViews As Variant
Dim vView As Variant
Dim myView As SldWorks.View
Dim sLinkedBom As String
Dim Msg As String

Sub main()

Set swApp = Application.SldWorks
If swApp.ActiveDoc.GetType <> swDocDRAWING Then
    MsgBox "Active document is not a drawing."
    Exit Sub
End If
Set swDwg = swApp.ActiveDoc
Msg = "Forced update for views on " & swDwg.GetCurrentSheet.GetName & vbCrLf
vViews = swDwg.GetCurrentSheet.GetViews
For Each vView In vViews
    Set myView = vView
    If Not (Left(myView.GetName2, 1) = "*") Then
        myView.SetVisible False, False
        swDwg.EditRebuild3
        myView.SetVisible True, False
    End If
Next vView
MsgBox Msg
End Sub

-handleman, CSWP (The new, easy test)
 
Thanks for the quick reply from both of you! I'll try them out and see what happens!!!

Thanks Again,
Todd
 
Handleman,

Would there be a way to add a save command at the end, once the views are all shown again?
 
add:

swDwg.Save3 swSaveAsOptions_Silent, empty, empty

-handleman, CSWP (The new, easy test)
 
Where would I need to put that code?
 
Right before the MsgBox.


-handleman, CSWP (The new, easy test)
 
That's where I figured it should go but when I put it there I was getting an error once I ran it...

All I did was moved the MsgBox down a line and copied and pasted the above code... Is there an issue with that, does it have to be done a different way?
 
I don’t know much about macro’s or even know where to begin starting one. But from what I can tell by running this macro, when it hides the views and shows them again it somehow re-links the drawing views to the model again. There’s nothing that says forcerebuild in the code but whatever it’s doing seems to fix the errors we’ve been having since starting SW2009. See attached… Before Macro is ran – Shows dimensions going to missing holes on the layout but on the formed views the holes are showing. After Macro is ran – Shows all my missing holes in the layout now.
 
 http://files.engineering.com/getfile.aspx?folder=73c1813f-3b00-49b0-ab6f-0da7fd4e9bbd&file=Before_Macro.pdf
Status
Not open for further replies.

Part and Inventory Search

Sponsor