TagString Example

Using Programming Languages other than VBA

Sub Example_TagString()
	' This example creates an attribute definition in model space.
	' It then queries the tag string for the attribute, changes
	' the tag string, and displays the new tag string.

	Dim attributeObj As AcadAttribute
	Dim height As Double
	Dim mode As Long
	Dim prompt As String
	Dim insertionPoint(0 To 2) As Double
	Dim tag As String
	Dim value As String

	' Define the attribute definition
	height = 1#
	mode = acAttributeModeVerify
	prompt = "New Prompt"
	insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0
	tag = "NEW_TAG"
	value = "New Value"

	' Create the attribute definition object in model space
	Set attributeObj = ThisDrawing.ModelSpace.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
	ZoomAll

	' Find the current tag string for the attribute
	tag = attributeObj.TagString
	MsgBox "The current tag string for the attribute is " & tag, , "TagString Example"

	' Change the tag string for the attribute
	attributeObj.TagString = "UPDATED_TAG"
	attributeObj.Update
	tag = attributeObj.TagString
	MsgBox "The new tag string for the attribute is " & tag, , "TagString Example"

End Sub

 

   Comments?