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!

SW Design Table Update Problem.

Status
Not open for further replies.

Martensyte

Mechanical
Oct 29, 2005
9
Hi Group,

I've written a VB6 application which among other things attempts(!) to update some info within design tables - it works sometimes, but the problem is getting the DT to be the active workbook. (there is another WB that must stay open in Excel while the program is running and sometimes it remains as the active WB, so when the program tries to modify the DT it targets the other WB and the DT is unchanged). Code I use is as follows:

swbstat = swPart.Extension.SelectByID2("Design Table", "DESIGNTABLE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
swPart.InsertFamilyTableEdit
Set ExcelWB = ExcelApp.ActiveWorkbook

Any suggestions how upon opening the DT it can be forced to be the active WB?

Thx.

David G.

 
Replies continue below

Recommended for you

I am surprised that the table just opened is not the active workbook. However, I do not access design tables in this manner (although I am curious if the table opens in a separate window or inside SolidWorks). I use the following:

Set swDesignTable = swModel.GetDesignTable

swDesignTable.EditFeature

Another method you could try would be to get the name of the workbook that is always open and then cycle through all the open workbooks. The one that does not match the known open workbook would then be the design table.

Regards,

Regg



 
Thanks for your reply Regg - the cycle through thing seems to work.

Your open table method doesn't seem to work much differently than mine (although a bit sexier).

FYI DTs always open in Solidworks.

Cheers, David.
 
After thinking about it. I believe it is a timing issue. Design tables do not always open immediately. The code simply gets ahead of the design table opening and finds the already open workbook. I do not know how you re-wrote your code but my suggestion now (similar to my original) would be to get the current active workbook object, send your call to open the design table,then enter a do loop that checks for the active workbook change and exits when it happens. The new active workbook is the design table.

Regards,

Regg
 
If you are interested in getting the DT to open in excel as opposed to in SW then you can use the following code...

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.SetUserPreferenceToggle SwConst.swUserPreferenceToggle_e.swEditDesignTableInSeparateWindow, True
boolstatus = Part.Extension.SelectByID2("Design Table", "DESIGNTABLE", 0, 0, 0, False, 0, Nothing, 0)
Part.InsertFamilyTableEdit
End Sub
 
neilc78,

I generally do not use the SelectByID calls because the people at SolidWorks API have led me to believe they are not that reliable (though it is funny that when you record a macro that this is the call that generally is recorded). Thanks for the info about the user preference.

Regards,

Regg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor