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.ActiveDocIf (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 = 0End If
End Sub
Thank you.
Hmmm. You prolly need to have someone write this for you as this involves two things: MathTransform to convert screen coordinates to drawing coordinates and VBA events for capturing mouse clicks.
For the life of me, I have answered a question like this couple of years ago but I can't seem to find that post.
Best,
Amen
SOLIDWORKS PDM API Programming services