hey,
how can i fix a tag letter in a table annotation? i would like to define a especific letter for a especific hole feature in a collection drawings.
is it possible by API?
hey,
how can i fix a tag letter in a table annotation? i would like to define a especific letter for a especific hole feature in a collection drawings.
is it possible by API?
so, i studied this macro before, but it isn't work. i have a "annotationtable" and not a "holetable", it could be the problem?
i try to modify for:
boolstatus = swModel.Extension.SelectByID2("Item de detalhe1305@N", "ANNOTATIONTABLES", 0.126414199968846, 7.69865441259771E-02, 0, False, 0, Nothing, 0)
but when i set "Set swHoleTable = swSelMgr.GetSelectedObject6(1, -1)" one error is showed
sorry if my question doesn't smart, i am still beginner in API
thank you very much!
2017 SOLIDWORKS API Help - IHoleTableAnnotation Interface
you need to get SwHoleTableAnnotation From TableAnnotation.
you can just set it SwHoleTableAnnotation = SwTableAnnotation as it is derived from SwTableAnnotation
so do this
Dim SwHoleTableAnn as holeTableAnnotation
Set SwHoleTableAnn = SwSelMgr.GetSelectedObject6(1,-1)
Dim SwHoleTable as holeTable
Set SwHoleTable = SwHoleTableAnn.HoleTable
also i dont know if you can select the cell using this. "Item de detalhe1305@N"
you may need the TableAnnotation Name. maybe someone else can chime in.
So, unfortunetly it seems not to work.
now i select the table with "Set swTable = swView.GetFirstTableAnnotation" in the first view and set the itens follow your explanetion, but in the line "SwHoleTable.HoleTag(1) = "Test1"". nothing change!
i think that the solid block it.
this sintaxe:
>>>> Debug.Print "Original name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
>>>> SwHoleTable.HoleTag(1) = "Test1"
>>>> Debug.Print "New name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
result it:
Original name of tag in column1, row 2: A
New name of tag in column1, row 2: A
in the others cells i can change the values, but this tags no.
you need to cast the TableAnnotation to a HoleTableAnnotation
Then you can get the HoleTable from The HoleTableAnnotation.GetHoleTable
Dim SwHoleTableAnn as HoleTableAnnotation
Set SwHoleTableAnn = SwTable
Dim SwHoleTable as holetable
Set SwHoleTable = SwHoleTableAnn.HoleTable
SwHoleTable.HoleTag(0)= "Test1"
copy your code on your next reply.
so, this is my code. How you suggest?
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim SwHoleTable As SldWorks.HoleTable
Dim SwTable As SldWorks.HoleTableAnnotation
Dim boolstatus As Boolean
Dim swview As SldWorks.View
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swview = swModel.GetFirstView
Do While Not swview Is Nothing
Set SwTable = swview.GetFirstTableAnnotation
Do While Not SwTable Is Nothing
Set SwHoleTable = SwTable.HoleTable
Debug.Print "Original name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
SwHoleTable.HoleTag(1) = "Test1"
Debug.Print "New name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
Set SwTable = SwTable.GetNext
Loop
Set swview = swview.GetNextView
Loop
End Sub
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim SwHoleTable As SldWorks.HoleTable
Dim SwTableAnn as sldworks.TableAnnotation
Dim SwHoleTableAnn As SldWorks.HoleTableAnnotation
Dim boolstatus As Boolean
Dim swview As SldWorks.View
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swview = swModel.GetFirstView
Do While Not swview Is Nothing
Set SwTableAnn= swview.GetFirstTableAnnotation
Do While Not SwTableAnn Is Nothing
Set SwHoleTableAnn= SwTableAnn
Set SwHoleTable = SwHoleTableAnn.HoleTable
Debug.Print "Original name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
SwHoleTable.HoleTag(1) = "Test1"
Debug.Print "New name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
Set SwTableAnn= SwTableAnn.GetNext
Loop
Set swview = swview.GetNextView
Loop
End Sub
you need to cast to ITableAnnotation
Then to IHoleTableAnnotation
Then to IHoleTable
bold has changed
i think that the problem in my solidworks. its doesnt work.
what did you mean with?
you need to cast to ITableAnnotation
Then to IHoleTableAnnotation
Then to IHoleTable
IHoleTableAnnotation is derived from ITableAnnotation
IHoleTable is accessed from IHoleTableAnnotation.HoleTable
you werent checking the type of the table.
use this code
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim SwHoleTable As SldWorks.HoleTable
Dim SwTableAnn As SldWorks.TableAnnotation
Dim SwHoleTableAnn As SldWorks.HoleTableAnnotation
Dim boolstatus As Boolean
Dim swview As SldWorks.View
Dim SwDraw As DrawingDoc
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set SwDraw = swModel
Set swview = SwDraw.GetFirstView
Do While Not swview Is Nothing
Set SwTableAnn = swview.GetFirstTableAnnotation
Do While Not SwTableAnn Is Nothing
If SwTableAnn.Type = swTableAnnotationType_e.swTableAnnotation_HoleChart Then
Set SwHoleTableAnn = SwTableAnn
Set SwHoleTable = SwHoleTableAnn.HoleTable
Debug.Print "Original name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
SwHoleTable.HoleTag(1) = "Test1"
Debug.Print "New name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
End If
Set SwTableAnn = SwTableAnn.GetNext
Loop
Set swview = swview.GetNextView
Loop
End Sub
IHoleTableAnnotation is derived from ITableAnnotation
IHoleTable is accessed from IHoleTableAnnotation.HoleTable
you werent checking the type of the table.
use this code
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim SwHoleTable As SldWorks.HoleTable
Dim SwTableAnn As SldWorks.TableAnnotation
Dim SwHoleTableAnn As SldWorks.HoleTableAnnotation
Dim boolstatus As Boolean
Dim swview As SldWorks.View
Dim SwDraw As DrawingDoc
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set SwDraw = swModel
Set swview = SwDraw.GetFirstView
Do While Not swview Is Nothing
Set SwTableAnn = swview.GetFirstTableAnnotation
Do While Not SwTableAnn Is Nothing
If SwTableAnn.Type = swTableAnnotationType_e.swTableAnnotation_HoleChart Then
Set SwHoleTableAnn = SwTableAnn
Set SwHoleTable = SwHoleTableAnn.HoleTable
Debug.Print "Original name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
SwHoleTable.HoleTag(1) = "Test1"
Debug.Print "New name of tag in column1, row 2: " & SwHoleTable.HoleTag(1)
End If
Set SwTableAnn = SwTableAnn.GetNext
Loop
Set swview = swview.GetNextView
Loop
End Sub