Update drawings

Discussion in 'SolidWorks' started by Ronni, Aug 31, 2007.

  1. Ronni

    Ronni Guest

    I tried using the Task Schduler to update to 2007... And it didnt work
    very well. But then I noticed that you can use the program to run a
    macro. Which could help me with one of my problem.. that when it saves
    a drawing it dosnt update (ctrl+Q) it, which means I have to update
    all the drawings manually at a later point.

    My question is: Does anyone have macro that open the drawing, updates
    (ctrl+Q) it and saves it again?

    I could try running it with the Task Scheduler to seee if it works.
     
    Ronni, Aug 31, 2007
    #1
  2. Ronni

    fcsuper Guest

    Better than CTRL-Q is the forcerebuilt function in SolidWorks API. Do
    you want to open all the files in a particular folder on your
    harddrive, or just one file at a time? This doesn't sound like a hard
    macro to make.

    Matt Lorono
    http://sw.fcsuper.com
     
    fcsuper, Aug 31, 2007
    #2
  3. Ronni

    fcsuper Guest

    fcsuper, Aug 31, 2007
    #3
  4. Ronni

    Jeff Guest

    Ronnie I have one that does this using the API call for forced rebuild
    but I need to know if you want to run on entire folder or just a
    single drawing file.
     
    Jeff, Aug 31, 2007
    #4
  5. Ronni

    Ronni Guest

    Entire folders, have to run around 10k drawings.
     
    Ronni, Sep 3, 2007
    #5
  6. Ronni

    Ronni Guest

    I know these things and have been doing them in that order, but still
    there was a lot I had to update manually and it dont force a rebuild a
    long the way. And it wont work in anyway once I start with assemblies
    that consist of more than a few parts. Also I had to copy the files to
    another folder and run it from there since the scheduler have
    difficulties planning more than around 500 files. So I manually moved
    the parts 500 by 500 to another folder and then ran the updates from
    there, in the order parts, parts used for half fabricated pieces,
    assemblies and then drawings. This is as you point out very logical,
    and was nessesary to get it to work just a little. But this procedure
    is very time consuming with my current 130k SW files (have done around
    70k now), and when I discover that I have to update them once more
    just because it dont cause a force rebuild it is wastet work.
     
    Ronni, Sep 5, 2007
    #6
  7. Ronni

    fcsuper Guest

    Option Explicit

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim strPathAndFilename As String
    Dim strResponse As String
    Dim strFileType As Long
    Dim longstatus As Long
    Dim longwarnings As Long

    Sub main()

    Set swApp = Application.SldWorks

    strPathAndFilename = "C:\Temp\Part1.SLDDRW"
    strResponse = vbYes

    If StrComp((UCase$(Right$(strPathAndFilename, 7))), ".SLDPRT",
    vbTextCompare) = 0 Then
    strFileType = swDocPART
    ElseIf StrComp((UCase$(Right$(strPathAndFilename, 7))), ".SLDASM",
    vbTextCompare) = 0 Then
    strFileType = swDocASSEMBLY
    ElseIf StrComp((UCase$(Right$(strPathAndFilename, 7))), ".SLDDRW",
    vbTextCompare) = 0 Then
    strFileType = swDocDRAWING
    End If

    Set swModel = swApp.OpenDoc6(strPathAndFilename, strFileType, 0,
    "", longstatus, longwarnings)
    Set swModel = swApp.ActivateDoc2(strPathAndFilename, False,
    longstatus)

    If (swModel Is Nothing) Then
    strResponse = MsgBox("The file could not be found." & Chr(13)
    & "Routine Ending.", vbCritical, "FileOpenRebuildSaveClose")
    End
    End If

    If (swModel.IsOpenedReadOnly = "False") Then

    If (swModel.GetType <> swDocDRAWING) Then

    'Shade Part
    swModel.ViewDisplayShaded

    'Set view
    'swModel.ShowNamedView2 "*Isometric", 7
    'swModel.ShowNamedView2 "*Trimetric", 8
    swModel.ShowNamedView2 "*Dimetric", 9

    'Set Feature Manager Splitter Position
    swModel.FeatureManagerSplitterPosition = 0.3

    End If

    'Rebuild File
    'swModel.EditRebuild3 'Stoplight or [Ctrl]+B
    swModel.ForceRebuild '[Ctrl]+Q

    'Zoom to extents
    swModel.ViewZoomtofit2

    'Save
    swModel.Save2 False

    Else
    strResponse = MsgBox("The file is Read-Only." & Chr(13) & "Do
    you want to close the file without Saving?", vbCritical + vbYesNo,
    "FileOpenRebuildSaveClose")
    End If

    Set swModel = Nothing

    If (strResponse = vbYes) Then
    'Close
    swApp.CloseDoc strPathAndFilename
    End If

    Set swApp = Nothing

    End Sub
     
    fcsuper, Sep 7, 2007
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.