Macro edition of solidworks table

Hello

Under sw2017, I want to edit a revision table by macro.

In my MEP, I have a variable "Date ind A" and a variable "Draftsman".

Today, after a copy of the project, I need to update the revision tables of all the plans in the project by integrating these variables.

I want to automatically assign these variables to the corresponding boxes of my revision table. Is it possible?

Thank you in advance.

Fred

Hello

 

When you say by integrating its means by creating and adding to the table or just modifying the value?

1 Like

I would like the cell to display the value of the file's custom property.

Today, I replace the text of the cells with the following text$PRP: "Date indA" for example, but since I have a lot of plans I would like to automate this step.

Can you send us an example of a drawing that you are modifying?

I managed to do pretty much what I wanted with the following code:

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView

myModelView.FrameState = swWindowState_e.swWindowMaximized

boolstatus = Part.Extension.SelectByID2("détail166@Feuille1 object", "REVISIONTABLE", 0.238189661374546, 5.37305690286136E-02, 0, False, 0, Nothing, 0)
Part.EditDelete

Dim currentSheet As Object
Dim myRevisionTable As Object
Set currentSheet = Part.GetCurrentSheet()
Set myRevisionTable = currentSheet.InsertRevisionTable(True, 0.41, 4.01116812853213E-02, 4, "T:\BEM\Solidworks\Models\Table Revision\Revision TESTELEC - DATE - DRAFTSMAN.sldrevtbt")
boolstatus = Part.Extension.SelectByID2("détail167@Feuille1 object", "REVISIONTABLE", 0.237457760308212, 4.89732120974398E-02, 0, False, 0, Nothing, 0)
Set currentSheet = Part.GetCurrentSheet()
Set myRevisionTable = currentSheet.RevisionTable
longstatus = myRevisionTable.AddRevision("A")
boolstatus = Part.ActivateView("Layout View1")
boolstatus = Part.ActivateSheet("Sheet1")
boolstatus = Part.Extension.SelectByID2("détail167@Feuille1 Object", "REVISIONTABLE", 0.373957309179585, 4.80583357645217E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True

Dim myTable As Object
Set myTable = myRevisionTable
myTable.Text(0, 2) = "$PRP:"""Date ind A"""
Part.ClearSelection2 True
Set myTable = myRevisionTable
myTable.Text(0, 3) = "$PRP:""Draftsman"""
Part.ClearSelection2 True
Set myTable = myRevisionTable
myTable.Text(0, 1) = "Creation"

boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.364259620050653, 6.48920602902139E-02, 0, False, 0, Nothing, 0)

'Macro Launch
Dim runMacroError       As Long

boolstatus = swApp.RunMacro2("T:\BEM\Solidworks\Templates\Macros\Reload basemap\changebasemaps.swp", "ChangeBasePlanwp1", "main", swRunMacroDefault, runMacroError)
End Sub

 

All that's left to do is find a way to select the table automatically at the beginning instead of having to click on it....

 

Good evening

In my opinion you don't need to select it first.

Instead, look at this example in the api help: http://help.solidworks.com/2017/English/api/sldworksapi/Get_Revision_Table_Example_VB.htm

1 Like