create design table in part or assembly

Programming and macros
Kjara
Posts: 21
Joined: Mon Jul 19, 2021 2:49 am
Answers: 0
x 1

create design table in part or assembly

Unread post by Kjara »

How do I create a design table in a part or assembly document via SolidWorks API?

I tried to find anything in the API docs, but IDesignTable interface lists only IModelDoc2.GetDesignTable as an accessor.

Typing "design table" in the index also gives no useful results: The only useful I find is the topic "insert", which links me to either IModelDoc2.InsertFamilyTableNew which has to do with drawings and IModelDoc2.InsertFamilyTableOpen which requires an excel file.

I just want to create a new design table, analog to this option in the GUI
grafik.png
but without any user interference and without the user noticing anything.
User avatar
AlexB
Posts: 452
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 24
x 243
x 401

Re: create design table in part or assembly

Unread post by AlexB »

Just a quick macro to test this adds a design blank table to a part and then closes it, because it pop up an Excel window.

Code: Select all

Option Explicit

Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As ModelDoc2
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    swModel.InsertFamilyTableNew
    swModel.CloseFamilyTable
End Sub
I imagine you'll have to edit the design table feature after the fact with IDesignTable::EditFeature to modify the settings that pop up when a user adds a table with the UI.
Post Reply