ContentChange Example

Using Programming Languages other than VBA

Sub Example_ContentChange()
	 ' This example adds a table in model space
	' and manipulates its contents

	' Note: One content is created for each cell by default;
	' this function need to be called only to create additional contents.

	Dim MyModelSpace As AcadModelSpace
	Set MyModelSpace = ThisDrawing.ModelSpace
	Dim pt(2) As Double
	Dim MyTable As IAcadTable2
	Dim sID As Long
	Dim newSID As Long
	Dim row As Long
	Dim col As Long

	' Creates arbitrary cell points to check
	row = 2
	col = 2

	' Creates the table with an arbitrary number of cells
	Set MyTable = MyModelSpace.AddTable(pt, 5, 5, 10, 30)

	If MyTable.IsEmpty(row, col) Then
		If MyTable.IsContentEditable(row, col) Then
			MsgBox "There is no content in the cell, but it is editable"
		End If
	End If

   ' Create some content in an arbitrary cell
	sID = MyTable.CreateContent(row, col, 8)

	MsgBox "The content ID is " & sID
 
	'Move the content to another index
	Call MyTable.MoveContent(row, col, sID, 4)

	'Check that the content has been deleted
	Call MyTable.DeleteContent(row, col)

	If MyTable.IsEmpty(row, col) Then
		If MyTable.IsContentEditable(row, col) Then
			MsgBox "There is no content in the cell, but it is editable"
		End If
	End If

	ZoomExtents

End Sub

 

   Comments?