AnsweredAssumed Answered

Script to change model based on Excel file

Question asked by Dan Hofstetter on Aug 18, 2016
Latest reply on Aug 19, 2016 by Dan Hofstetter

I have been having trouble with "Server Busy" errors in SolidWorks 2013 when opening a .SLDPRT file that has a slot feature that is LPatterned many times (300 or more small slots in one part).  The dimensions of the slot and number of instances are defined in a Design Table file.  I have not been able to prevent the "Server Busy" warning, and it won't go away on its own no matter how long I wait.  I am automating SolidWorks from an Excel macro, and am not always at my desk to click the "Retry" button every time this occurs, so I am looking for a workaround.


I think one way to avoid the Server Busy error is to delete the design table from the .SLDPRT file, then change the dimensions and suppression states of all design table variables using VBA code (pushing the dimension values via the API).  My thought was to go through the Excel design table file one column at a time, read the variable name, decide if it is a dimension or state, then change the dimension or state based on the entered value in the next row.


I got the following code snippet to work:

Sub Change_SW_Dims()


    Set swApp = CreateObject("SldWorks.Application")

    Set Part = swApp.ActiveDoc

    Part.Parameter("TankDX@Tank Profile Plan View").SystemValue = 1600 * 0.0254

    boolstatus = Part.Extension.SelectByID2("Slot 1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)





End Sub


Before spending a lot of time playing around with this, I thought I'd search for something similar that I could modify.  I have not been able to find similar code yet, and was wondering if anyone might be able to point me in the right direction?