Mode Example |
Using Programming Languages other than VBA
Sub Example_Mode() ' This example creates an attribute definition in model space. ' It then queries the initial value of the Mode property, ' changes that value, and finally resets the value. 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 ' Return the current field length of the attribute Dim currMode As Integer Dim constant As String currMode = attributeObj.mode GoSub GETCONSTANT MsgBox "The Mode of the attribute is " & constant, vbInformation, "Mode Example" ' Change the field length attributeObj.mode = acAttributeModeInvisible GoSub GETCONSTANT attributeObj.Update MsgBox "The new Mode of the attribute is " & constant, vbInformation, "Mode Example" ' Reset the field length to the original value attributeObj.mode = currMode GoSub GETCONSTANT attributeObj.Update MsgBox "The Mode of the attribute is reset to " & constant, vbInformation, "Mode Example" Exit Sub
GETCONSTANT: ' Get the constant that corresponds to the current mode constant = Choose(attributeObj.mode, "acAttributeModeInvisible", "acAttributeModeConstant", "", "acAttributeModeVerify", "", "", "", "acAttributeModePreset") Return End Sub
Comments? |