danderson.71652
2004-12-13, 05:08 PM
I am very new to VB, and I know there may be better ways to do certain things, but I am learning.
I want a tool that will simply
I have come across a situation that works sometimes, and sometimes not, and I cannot figure out why?
I am including a test file dwg.
Thanks
Dan
VB Code
Sub GetFieldExpression()
Dim ssetObj As AcadSelectionSet
Dim point1(0 To 2) As Double
Dim point2(0 To 2) As Double
Dim entText As AcadObject
Dim vPt As Variant
Dim text As String
Tag
On Error GoTo Err_Control
' Sub ???Not sure why TextObj needs to be present to work, delete after
Dim textObj As IAcadText2
Dim insertionPoint(0 To 2) As Double
Dim Height As Double
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
insertionPoint(0) = 2000000: insertionPoint(1) = 2000000: insertionPoint(2) = 0
Height = 0.5
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, Height)
'acSelectionSetLast
ThisDrawing.Application.ZoomAll
Set ssetObj = ThisDrawing.SelectionSets.Add("deletelast")
ssetObj.Select acSelectionSetLast
'MsgBox ("Selection set " & ssetObj.Name & " contains " & ssetObj.Count & " items")
text = textObj.FieldCode
UserForm3.Hide
ThisDrawing.Application.ZoomPrevious
ThisDrawing.Utility.GetEntity entText, vPt, vbCr & "Pick a FIELD in drawing:"
text = entText.FieldCode
UserForm3.TextBox1 = text
ThisDrawing.Application.ZoomAll
' Erase the objects in the selection set
ssetObj.Erase
ThisDrawing.Application.ZoomPrevious
UserForm3.Show
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit_Here:
Exit Sub
Err_Control:
MsgBox "This OBJECT FIELD Entity's Expression could not be found. " & vbCrLf & "Verify it is not inside a dimension or table.", vbOKOnly + vbQuestion, "CT-Error"
ssetObj.Erase
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit Sub
End Sub
I want a tool that will simply
I have come across a situation that works sometimes, and sometimes not, and I cannot figure out why?
I am including a test file dwg.
Thanks
Dan
VB Code
Sub GetFieldExpression()
Dim ssetObj As AcadSelectionSet
Dim point1(0 To 2) As Double
Dim point2(0 To 2) As Double
Dim entText As AcadObject
Dim vPt As Variant
Dim text As String
Tag
On Error GoTo Err_Control
' Sub ???Not sure why TextObj needs to be present to work, delete after
Dim textObj As IAcadText2
Dim insertionPoint(0 To 2) As Double
Dim Height As Double
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
insertionPoint(0) = 2000000: insertionPoint(1) = 2000000: insertionPoint(2) = 0
Height = 0.5
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, Height)
'acSelectionSetLast
ThisDrawing.Application.ZoomAll
Set ssetObj = ThisDrawing.SelectionSets.Add("deletelast")
ssetObj.Select acSelectionSetLast
'MsgBox ("Selection set " & ssetObj.Name & " contains " & ssetObj.Count & " items")
text = textObj.FieldCode
UserForm3.Hide
ThisDrawing.Application.ZoomPrevious
ThisDrawing.Utility.GetEntity entText, vPt, vbCr & "Pick a FIELD in drawing:"
text = entText.FieldCode
UserForm3.TextBox1 = text
ThisDrawing.Application.ZoomAll
' Erase the objects in the selection set
ssetObj.Erase
ThisDrawing.Application.ZoomPrevious
UserForm3.Show
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit_Here:
Exit Sub
Err_Control:
MsgBox "This OBJECT FIELD Entity's Expression could not be found. " & vbCrLf & "Verify it is not inside a dimension or table.", vbOKOnly + vbQuestion, "CT-Error"
ssetObj.Erase
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit Sub
End Sub