Table Layers?

Programming and macros
User avatar
loeb
Posts: 74
Joined: Sun Jan 16, 2022 5:55 pm
Answers: 1
x 40
x 10

Table Layers?

Unread post by loeb »

A lot of the VBA Macro tools I write are the bring our legacy drawings up to our current standards. One of the anomalies that we run into is tables that are gray instead of black. The solution to this condition is to manually select them, then put them on the "0" (zero) layer. I'm not sure what's going on here, but that's the solution that works.

I have written a macro that scours a drawing for drawing entities that don't have a layer (ie. layer = ""), and moves them to the zero layer. This matches the workflow that works for us, but I can't find a method for setting the layer for tables using VBA. The SW API help shows some iTable members that do this, but that's only for DraftSight.

How does one move a table to a layer using VBA?

Thank You,

-Loeb
by gupta9665 » Tue Dec 31, 2024 2:24 am
You can get the annotation from the table, and change layer for that.

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swTable As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swTable = swModel.SelectionManager.GetSelectedObject6(1, -1)

Set swAnn = swTable.GetAnnotation
swAnn.Layer = "0" 'Layer Name

End Sub
Go to full post
User avatar
gupta9665
Posts: 423
Joined: Thu Mar 11, 2021 10:20 am
Answers: 26
Location: India
x 442
x 460

Re: Table Layers?

Unread post by gupta9665 »

You can get the annotation from the table, and change layer for that.

Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swTable As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swTable = swModel.SelectionManager.GetSelectedObject6(1, -1)

Set swAnn = swTable.GetAnnotation
swAnn.Layer = "0" 'Layer Name

End Sub
Deepak Gupta
SOLIDWORKS Consultant/Blogger
Post Reply