Populate the Table with AutoCAD Layer Data

Placing the layer data contained in the drawing is the core functionality of the entire application. The following code accomplishes that task by iterating through the AutoCAD Layers collection and placing each layer and its associated data in a single row of the table, as shown in Figure 22-2.

'increment the row counter lngRow = lngRow + 1

'column must begin at 1 lngColumn = 1

Dim objLayer As AcadLayer

'put layer data in table

For Each objLayer In Application.Documents(cboDrawingName.Text).Layers With mobjTable

.Cell(lngRow, lngColumn).Range.Text = objLayer.Name lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertToWord(objLayer.LayerOn) lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertToWord(objLayer.Freeze) lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertToWord(objLayer.Lock) lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertColorToString(objLayer.Color) lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = objLayer.Linetype lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertLineweight(objLayer.Lineweight) lngColumn = lngColumn + 1

If ThisDrawing.Application.Preferences.Output.PlotPolicy Then .Cell(lngRow, lngColumn).Range.Text = "ByColor"

Else

.Cell(lngRow, lngColumn).Range.Text = objLayer.PlotStyleName End If lngColumn = lngColumn + 1

.Cell(lngRow, lngColumn).Range.Text = ConvertToWord(objLayer.Plottable)

'increment the row counter lngRow = lngRow + 1

'column counter must begin at 1 lngColumn = 1 End With Next objLayer

Was this article helpful?

0 0
100 Bowling Tips

100 Bowling Tips

Playing bowling with your friends can help you decide if it is indeed the hobby that you want to invest your time on today. Aside from that, it can help you get a better feel of the sport. More importantly, when you play with your friends, it would become a more fun activity, which you can look forward to each week.

Get My Free Ebook


Post a comment