AnsweredAssumed Answered

Inserting General Tables into drawing at last click coordinates

Question asked by Larry Hooper on Jan 4, 2021
Latest reply on Jan 5, 2021 by Artem Taturevych

I have a user who needs easy access to a drop down list of macros that will easily and quickly import a general table template and will let them place it where they needed it on a cursor click. Currently, the code I have for importing the general table works but I am not familiar enough with the solid works parameters to know which argument to pass to allow the table to be pasted where the user chooses. The specific line in question is

Set swTable = swDrawing.InsertTableAnnotation2(True, 0, 0, swBOMConfigurationAnchor_TopLeft, MATABLE, 2, 1)

The full code is as follows;

 

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swDrawing As SldWorks.DrawingDoc

Dim swTable As SldWorks.TableAnnotation

Const MATABLE As String = "C:\STANDARD Tables\sampleTable.sldtbt"

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

If (swModel Is Nothing) Or (swModel.GetType <> swDocDRAWING) Then

swApp.SendMsgToUser ("To be used for drawings only, Open a drawing first and then TRY!")

Exit Sub

End If

Set swDrawing = swModel


Set swTable = swDrawing.InsertTableAnnotation2(True, 0, 0, swBOMConfigurationAnchor_TopLeft, MATABLE, 2, 1)

If Not swTable Is Nothing Then
swTable.BorderLineWeight = 0
swTable.GridLineWeight = 0

End If

End Sub

Thank you.

Outcomes