×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Control Q - Save Macro?
2

Control Q - Save Macro?

Control Q - Save Macro?

(OP)
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)
 

RE: Control Q - Save Macro?

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

RE: Control Q - Save Macro?

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)

RE: Control Q - Save Macro?

(OP)
Thanks for the quick reply from both of you!  I'll try them out and see what happens!!!

Thanks Again,
Todd

RE: Control Q - Save Macro?

(OP)
Handleman,

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

RE: Control Q - Save Macro?

add:

swDwg.Save3 swSaveAsOptions_Silent, empty, empty

-handleman, CSWP (The new, easy test)

RE: Control Q - Save Macro?

(OP)
Where would I need to put that code?

RE: Control Q - Save Macro?

Right before the MsgBox.
 

-handleman, CSWP (The new, easy test)

RE: Control Q - Save Macro?

(OP)
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?

RE: Control Q - Save Macro?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources