Getting the insertion point of a text item

Getting the insertion point of a text item

Anonymous
Not applicable
1,079 Views
5 Replies
Message 1 of 6

Getting the insertion point of a text item

Anonymous
Not applicable
Hi all!

 

I am trying to write some code to do the following:

 

This is the order they will happen as well!

1. Allow the user to select an existing text string in the
drawing.

2. Allow the user to select a closed polyline.

3. Get the area of the closed polyline and send it to a string
variable.

4. Place a new line of text exactly one line of text below the one the user
picked. (this new line of text will match the properties of the previous
selected text.  The contents of this new line of text will be from the
string variable noted in #3 above.

 

I have almost all of this working except that I can not get the point to be
the text insertion point and I am not sure how to force the new line of text
onto the next line.  I also have not messed with the text properties. 
Everything else works though. As it is now it wont insert the new line of text
because of the insertion point problem.

 

Here is the code:

 

Private Sub cmdRun_Click()

 

Dim Ent As AcadEntity
Dim Ent2 As AcadEntity
Dim Pt As Variant
Dim
Pt2 As Variant
Dim Cnt As Integer
Dim Cnt2 As Double
Dim strCnt As
String
Dim objText As acadText
Dim pointObj As AcadPoint
Dim objlayer
As AcadLayer
Dim strlayerName As String
Dim strText As String

 

On Error Resume Next
oldlayer =
ThisDrawing.ActiveLayer.Name
strlayerName = "NG_TEXT"
Set objlayer =
ThisDrawing.Layers(strlayerName)

 

If objlayer Is Nothing Then
    MsgBox "Layer '" &
strlayerName & "' does not exist. Please create it before
continuing."
    Exit Sub
Else
   
ThisDrawing.ActiveLayer = ThisDrawing.Layers("NG_TEXT")
End If

 

Me.Hide

 

ThisDrawing.Utility.GetEntity Ent2, Pt2, "Select the matching Text: "

 

    Ent2.Highlight
True
        If Err
Then
           
Ent2.Highlight False
        End
If
       
    If
TypeOf Ent2 Is acadText Then
        Set
objText = Ent2
        Set Pt2 =
objText.insertionPoint 'HERE IS WHERE THE PROBLEM IS. i CAN NOT SEEM TO FIGURE
THIS OUT.
        Debug.Print
Ent2.ObjectName 'THE OBJECT NAME COMES UP AS AcDcText, SO IT IS ASIGNING IT
CORRECTLY.
    End If

 

On Error Resume Next
Do
Me.Hide
ThisDrawing.Utility.GetEntity Ent,
Pt, "Select the desired polyline: "
    Ent.Highlight
True
        If Err
Then
           
Ent.Highlight
False
           

            If
ThisDrawing.GetVariable("errno") = "7"
Then
               
Err.Clear
           
Else
               
Err.Clear
               
Exit Do
           
End If
        End
If
    If TypeOf Ent Is AcadLWPolyline
Then
        Set ObjPly =
Ent
            If
ObjPly.Closed = True
Then
            If
ObjPly.area > 0
Then
               

               
Cnt2 =
ObjPly.area
               
Cnt2 = Round(Cnt2,
0)
               
strCnt =
Cnt2
               
strCnt = Format(strCnt,
"##.0")
               
strCnt = Round(strCnt /
9)
            End
If
           
Else
'If the entity selected is not a closed polyline then send the following
message.
               
MsgBox "The Polyline you selected is not closed. Please close it before " &
_
               
"continuing. This command will exit.
"
            Exit
Do
            End
If
    Else
'If the entity selected is not a roompoly then
send the following message.
        MsgBox
"The object you selected is not a Polyline. This command will exit.
"
        Exit Do
   
End If

 

Loop

 

strText = strCnt

 

Debug.Print strText

 

    If optLeft.Value = True
Then
       

        Set pointObj =
ThisDrawing.ModelSpace.AddPoint(Pt2)
       
pointObj.Color = acRed
        Set objText
= ThisDrawing.ModelSpace.AddText(strText, pointObj,
8)
        objText.Alignment =
acAlignmentLeft
       
objText.TextAlignmentPoint = pointObj
    End If

 

    If optMidCent.Value = True
Then
        Set pointObj =
ThisDrawing.ModelSpace.AddPoint(Pt2)
       
pointObj.Color = acRed
        Set objText
= ThisDrawing.ModelSpace.AddText(strText, pointObj,
8)
        objText.Alignment =
acAlignmentMiddleCenter
       
objText.TextAlignmentPoint = pointObj
    End If

 

End Sub

Any suggestions?

 

Thanx,

 

Rob
0 Likes
1,080 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Hi Rob,
Commented code follows

Private Sub cmdRun_Click()
Dim Ent As AcadEntity
Dim Ent2 As AcadEntity
Dim Pt As Variant
Dim Pt2 As Variant
Dim Cnt As Integer
Dim Cnt2 As Double
Dim strCnt As String
Dim objText As AcadText
Dim pointObj As AcadPoint
Dim objlayer As AcadLayer
Dim strlayerName As String
Dim strText As String
'ADDED BECAUSE THEY HAD NOT BEEN DECLARED IN CODE
'IF YOU HAVE THESE LISTED AS PUBLIC MEMBERS OF THIS
'MODULE OR ANOTHER MODULE, COMMENT THESE LINES OUT
Dim oldlayer As String
Dim ObjPly As AcadLWPolyline
'////END DIMS //////
On Error GoTo Err_Control
'On Error Resume Next '
'LOOK AT HOW I HANDLED THIS...
oldlayer = ThisDrawing.ActiveLayer.Name
strlayerName = "NG_TEXT"
Set objlayer = ThisDrawing.Layers(strlayerName)
ThisDrawing.ActiveLayer = ThisDrawing.Layers("NG_TEXT")
Me.Hide
ThisDrawing.Utility.GetEntity Ent2, Pt2, "Select the matching Text: "
Ent2.Highlight True
If Err Then
Ent2.Highlight False
End If
If TypeOf Ent2 Is AcadText Then
Set objText = Ent2
'HERE IS WHERE THE PROBLEM IS. i CAN NOT SEEM TO FIGURE THIS OUT.
'///Set Pt2 = objText.InsertionPoint////
Pt2 = objText.InsertionPoint
'////SET IS FOR OBJECTS ONLY/////
End If
'On Error Resume Next
'////I STOPPED CORRECTIONS HERE (ASIDE FROM THE ERROR HANDLER AT THE
'////END. WOULD YOU LIKE ME TO CONTINUE?
Do
Me.Hide
ThisDrawing.Utility.GetEntity Ent, Pt, "Select the desired polyline: "
Ent.Highlight True
If Err Then
Ent.Highlight False

If ThisDrawing.GetVariable("errno") = "7" Then
Err.Clear
Else
Err.Clear
Exit Do
End If
End If
If TypeOf Ent Is AcadLWPolyline Then
Set ObjPly = Ent
If ObjPly.Closed = True Then
If ObjPly.Area > 0 Then
Cnt2 = ObjPly.Area
'Cnt2 = Round(Cnt2, 0)
strCnt = Cnt2
strCnt = Format(strCnt, "##.0")
'strCnt = Round(strCnt / 9)
End If
Else
'If the entity selected is not a closed polyline then send the following
message.
MsgBox "The Polyline you selected is not closed. Please close it
before " & _
"continuing. This command will exit. "
Exit Do
End If
Else
'If the entity selected is not a roompoly then send the following message.
MsgBox "The object you selected is not a Polyline. This command will
exit. "
Exit Do
End If
Loop

strText = strCnt

Debug.Print strText

If optLeft.Value = True Then

Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
pointObj.Color = acRed
Set objText = ThisDrawing.ModelSpace.AddText(strText, pointObj, 8)
objText.Alignment = acAlignmentLeft
objText.TextAlignmentPoint = pointObj
End If

If optMidCent.Value = True Then
Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
pointObj.Color = acRed
Set objText = ThisDrawing.ModelSpace.AddText(strText, pointObj, 8)
objText.Alignment = acAlignmentMiddleCenter
objText.TextAlignmentPoint = pointObj
End If
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case -2145386476
If ObjPly Is Nothing Then
MsgBox "Layer '" & strlayerName & _
"' does not exist. Please create it before continuing."
End If
Resume Exit_Here
Case Else
MsgBox Err.Description
End Select
End Sub

Randall Rath
VB Design
http://www.vbdesign.net/cadpages/
Home of A Code A Day
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi Randall,

You are more than welcome to continue if you wish. I enjoy seeing new ways
of doing things to make my life easier. I do still have one problem. I am
now getting the following error message after I select my polyline and click
enter:

Method 'Getentity' of object 'IAcadUtility' failed.

I press 'OK' and the macro stops. I am assuming this comes in from the
Err_Control routine you have added? Any suggestions as to why I am getting
this error?

Thanx for the help,

Rob

"Randall Rath" wrote in message
news:B6CDCB21ADA35ED9E92E3137F4EF0386@in.WebX.maYIadrTaRb...
> Hi Rob,
> Commented code follows
>
> Private Sub cmdRun_Click()
> Dim Ent As AcadEntity
> Dim Ent2 As AcadEntity
> Dim Pt As Variant
> Dim Pt2 As Variant
> Dim Cnt As Integer
> Dim Cnt2 As Double
> Dim strCnt As String
> Dim objText As AcadText
> Dim pointObj As AcadPoint
> Dim objlayer As AcadLayer
> Dim strlayerName As String
> Dim strText As String
> 'ADDED BECAUSE THEY HAD NOT BEEN DECLARED IN CODE
> 'IF YOU HAVE THESE LISTED AS PUBLIC MEMBERS OF THIS
> 'MODULE OR ANOTHER MODULE, COMMENT THESE LINES OUT
> Dim oldlayer As String
> Dim ObjPly As AcadLWPolyline
> '////END DIMS //////
> On Error GoTo Err_Control
> 'On Error Resume Next '
> 'LOOK AT HOW I HANDLED THIS...
> oldlayer = ThisDrawing.ActiveLayer.Name
> strlayerName = "NG_TEXT"
> Set objlayer = ThisDrawing.Layers(strlayerName)
> ThisDrawing.ActiveLayer = ThisDrawing.Layers("NG_TEXT")
> Me.Hide
> ThisDrawing.Utility.GetEntity Ent2, Pt2, "Select the matching Text: "
> Ent2.Highlight True
> If Err Then
> Ent2.Highlight False
> End If
> If TypeOf Ent2 Is AcadText Then
> Set objText = Ent2
> 'HERE IS WHERE THE PROBLEM IS. i CAN NOT SEEM TO FIGURE THIS OUT.
> '///Set Pt2 = objText.InsertionPoint////
> Pt2 = objText.InsertionPoint
> '////SET IS FOR OBJECTS ONLY/////
> End If
> 'On Error Resume Next
> '////I STOPPED CORRECTIONS HERE (ASIDE FROM THE ERROR HANDLER AT THE
> '////END. WOULD YOU LIKE ME TO CONTINUE?
> Do
> Me.Hide
> ThisDrawing.Utility.GetEntity Ent, Pt, "Select the desired polyline: "
> Ent.Highlight True
> If Err Then
> Ent.Highlight False
>
> If ThisDrawing.GetVariable("errno") = "7" Then
> Err.Clear
> Else
> Err.Clear
> Exit Do
> End If
> End If
> If TypeOf Ent Is AcadLWPolyline Then
> Set ObjPly = Ent
> If ObjPly.Closed = True Then
> If ObjPly.Area > 0 Then
> Cnt2 = ObjPly.Area
> 'Cnt2 = Round(Cnt2, 0)
> strCnt = Cnt2
> strCnt = Format(strCnt, "##.0")
> 'strCnt = Round(strCnt / 9)
> End If
> Else
> 'If the entity selected is not a closed polyline then send the following
> message.
> MsgBox "The Polyline you selected is not closed. Please close it
> before " & _
> "continuing. This command will exit. "
> Exit Do
> End If
> Else
> 'If the entity selected is not a roompoly then send the following message.
> MsgBox "The object you selected is not a Polyline. This command will
> exit. "
> Exit Do
> End If
> Loop
>
> strText = strCnt
>
> Debug.Print strText
>
> If optLeft.Value = True Then
>
> Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
> pointObj.Color = acRed
> Set objText = ThisDrawing.ModelSpace.AddText(strText, pointObj, 8)
> objText.Alignment = acAlignmentLeft
> objText.TextAlignmentPoint = pointObj
> End If
>
> If optMidCent.Value = True Then
> Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
> pointObj.Color = acRed
> Set objText = ThisDrawing.ModelSpace.AddText(strText, pointObj, 8)
> objText.Alignment = acAlignmentMiddleCenter
> objText.TextAlignmentPoint = pointObj
> End If
> Exit_Here:
> Exit Sub
> Err_Control:
> Select Case Err.Number
> Case -2145386476
> If ObjPly Is Nothing Then
> MsgBox "Layer '" & strlayerName & _
> "' does not exist. Please create it before continuing."
> End If
> Resume Exit_Here
> Case Else
> MsgBox Err.Description
> End Select
> End Sub
>
> Randall Rath
> VB Design
> http://www.vbdesign.net/cadpages/
> Home of A Code A Day
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi Rob,

Give this a spin..

Private Sub cmdRun_Click()
Dim Ent As AcadEntity
Dim Ent2 As AcadEntity
Dim Pt As Variant
Dim Pt2 As Variant
Dim Cnt As Integer
Dim Cnt2 As Double
Dim strCnt As String
Dim objText As AcadText
Dim pointObj As AcadPoint
Dim objlayer As AcadLayer
Dim strlayerName As String
Dim strText As String
'ADDED BECAUSE THEY HAD NOT BEEN DECLARED IN CODE
'IF YOU HAVE THESE LISTED AS PUBLIC MEMBERS OF THIS
'MODULE OR ANOTHER MODULE, COMMENT THESE LINES OUT
Dim oldlayer As String
Dim ObjPly As AcadLWPolyline
Dim varErr As Variant
'////END DIMS //////
On Error GoTo Err_Control
'On Error Resume Next '
'LOOK AT HOW I HANDLED THIS...
oldlayer = ThisDrawing.ActiveLayer.Name
strlayerName = "NG_TEXT"
Set objlayer = ThisDrawing.Layers(strlayerName)
ThisDrawing.ActiveLayer = ThisDrawing.Layers("NG_TEXT")
Me.Hide
ThisDrawing.Utility.GetEntity Ent2, Pt2, "Select the matching Text: "
Ent2.Highlight True
If TypeOf Ent2 Is AcadText Then
Set objText = Ent2
'HERE IS WHERE THE PROBLEM IS. i CAN NOT SEEM TO FIGURE THIS OUT.
'///Set Pt2 = objText.InsertionPoint////
Pt2 = objText.InsertionPoint
'////SET IS FOR OBJECTS ONLY/////
End If
'On Error Resume Next
'//BASED ON YOUR CODE, YOU WANT A SINGLE CLOSED POLYLINE TO MATCH
'//A SINGLE TEXT OBJECT, NO LOOP NEEDED OR THE LOOP SHOULD BEGIN
'//EARLIER TO ALLOW FOR THE SELECTION OF ANOTHER MATCHING TEXT AND
'//CLOSE LATER.
'Do
'Me.Hide
ThisDrawing.Utility.GetEntity Ent, Pt, "Select the desired polyline: "
Ent.Highlight True
If Not Ent Is Nothing Then
If TypeOf Ent Is AcadLWPolyline Then
Set ObjPly = Ent
If ObjPly.Closed = True Then
If ObjPly.Area > 0 Then
Cnt2 = ObjPly.Area
'Cnt2 = Round(Cnt2, 0)
strCnt = Cnt2
strCnt = Format(strCnt, "##.0")
'strCnt = Round(strCnt / 9)
'//SELECTION IS DONE, RESET STATES
Ent.Highlight False
Ent2.Highlight False
End If
Else
'If the entity selected is not a closed polyline then send the following
message.
MsgBox "The Polyline you selected is not closed. Please close it
before " & _
"continuing. This command will exit. "
'Exit Do
End If
Else
'If the entity selected is not a roompoly then send the following message.
MsgBox "The object you selected is not a Polyline. This command will
exit. "
'Exit Do
End If
End If
'Loop
strText = strCnt
'Debug.Print strText
'//A POINT OBJECT IS NOT A VALID ARGUMENT, USE ITS INSERTION POINT.
'//IN THIS CASE I HAVE SIMPLY USED THE ORIGINAL POINT.
Pt2 = Ent2.InsertionPoint
'I HAVE USED .25 TO SET THE GAP, BUT YOU MAY WISH TO USE
'ANOTHER VALUE
Pt2(1) = Pt(1) - (8 + objText.Height + (8 * 0.25))
Debug.Print 8 * ThisDrawing.GetVariable("TSPACEFAC")
If optLeft.Value = True Then
Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
pointObj.Color = acRed
Set objText = ThisDrawing.ModelSpace.AddText(strText, Pt2, 8)
objText.Alignment = acAlignmentLeft
'///IF YOU USE ALIGNMENT LEFT THE ALIGNMENT POINT BECOMES
'///READ ONLY!
'/////objText.TextAlignmentPoint = Pt2
objText.Update
End If

If optMidCent.Value = True Then
Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
pointObj.Color = acRed
Set objText = ThisDrawing.ModelSpace.AddText(strText, Pt2, 8)
objText.Alignment = acAlignmentMiddleCenter
objText.TextAlignmentPoint = Pt2
objText.Update
End If
'////SHOW THE FORM AGAIN
Me.Show
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case -2145386476
If ObjPly Is Nothing Then
MsgBox "Layer '" & strlayerName & _
"' does not exist. Please create it before continuing."
End If
Err.Clear
Resume Exit_Here
Case -2147352567
'varErr = ThisDrawing.GetVariable("LASTPROMPT")
'///THERE ARE MANY WAYS TO DEAL WITH THIS ERROR
'///SINCE YOU USED ERRNO'S VALUE IN YOUR CODE I
'///HAVE USED IT IN THE HANDLER.
If ThisDrawing.GetVariable("errno") <> "52" Then
Err.Clear
'MISSED PICK SEND THEM BACK
Resume
'//IF YOU WANT TO ALLOW EXIT WITH RIGHT CLICK
'//ADD A NEW PROPERTY TO THE THISDRAWING MODULE
'//THAT IS SET TO TRUE ON A RIGHT CLICK AND
'//CHECK IT HERE.
Else
Err.Clear
Resume Exit_Here
End If
Case Else
MsgBox Err.Description
End Select
End Sub

Randall Rath
VB Design
Home of the Wonder Llama
http://www.vbdesign.net/cadpages
0 Likes
Message 5 of 6

Anonymous
Not applicable
Hi again Randall,

I had to make one minor change (noted below) but it now works great. You
guys are all geniuses.
I just wanted to place the new text directly under the selected text, so I
just changed the following line:

Pt2(1) = Pt(1) - (8 + objText.Height + (8 * 0.25))

to:

Pt2(1) = Pt2(1) - (8 + objText.Height + (8 * 0.25))

I do have one question though; what is the number in parenthesis after PT2?
i.e. Pt2(1)
I have never seen this before.

Thanx again Randall, I appreciate all of your help.

Rob

"Randall Rath" wrote in message
news:F1443998C8BDB4E45BE944B76E924D8C@in.WebX.maYIadrTaRb...
> Hi Rob,
>
> Give this a spin..
>
> Private Sub cmdRun_Click()
> Dim Ent As AcadEntity
> Dim Ent2 As AcadEntity
> Dim Pt As Variant
> Dim Pt2 As Variant
> Dim Cnt As Integer
> Dim Cnt2 As Double
> Dim strCnt As String
> Dim objText As AcadText
> Dim pointObj As AcadPoint
> Dim objlayer As AcadLayer
> Dim strlayerName As String
> Dim strText As String
> 'ADDED BECAUSE THEY HAD NOT BEEN DECLARED IN CODE
> 'IF YOU HAVE THESE LISTED AS PUBLIC MEMBERS OF THIS
> 'MODULE OR ANOTHER MODULE, COMMENT THESE LINES OUT
> Dim oldlayer As String
> Dim ObjPly As AcadLWPolyline
> Dim varErr As Variant
> '////END DIMS //////
> On Error GoTo Err_Control
> 'On Error Resume Next '
> 'LOOK AT HOW I HANDLED THIS...
> oldlayer = ThisDrawing.ActiveLayer.Name
> strlayerName = "NG_TEXT"
> Set objlayer = ThisDrawing.Layers(strlayerName)
> ThisDrawing.ActiveLayer = ThisDrawing.Layers("NG_TEXT")
> Me.Hide
> ThisDrawing.Utility.GetEntity Ent2, Pt2, "Select the matching Text: "
> Ent2.Highlight True
> If TypeOf Ent2 Is AcadText Then
> Set objText = Ent2
> 'HERE IS WHERE THE PROBLEM IS. i CAN NOT SEEM TO FIGURE THIS OUT.
> '///Set Pt2 = objText.InsertionPoint////
> Pt2 = objText.InsertionPoint
> '////SET IS FOR OBJECTS ONLY/////
> End If
> 'On Error Resume Next
> '//BASED ON YOUR CODE, YOU WANT A SINGLE CLOSED POLYLINE TO MATCH
> '//A SINGLE TEXT OBJECT, NO LOOP NEEDED OR THE LOOP SHOULD BEGIN
> '//EARLIER TO ALLOW FOR THE SELECTION OF ANOTHER MATCHING TEXT AND
> '//CLOSE LATER.
> 'Do
> 'Me.Hide
> ThisDrawing.Utility.GetEntity Ent, Pt, "Select the desired polyline: "
> Ent.Highlight True
> If Not Ent Is Nothing Then
> If TypeOf Ent Is AcadLWPolyline Then
> Set ObjPly = Ent
> If ObjPly.Closed = True Then
> If ObjPly.Area > 0 Then
> Cnt2 = ObjPly.Area
> 'Cnt2 = Round(Cnt2, 0)
> strCnt = Cnt2
> strCnt = Format(strCnt, "##.0")
> 'strCnt = Round(strCnt / 9)
> '//SELECTION IS DONE, RESET STATES
> Ent.Highlight False
> Ent2.Highlight False
> End If
> Else
> 'If the entity selected is not a closed polyline then send the following
> message.
> MsgBox "The Polyline you selected is not closed. Please close it
> before " & _
> "continuing. This command will exit. "
> 'Exit Do
> End If
> Else
> 'If the entity selected is not a roompoly then send the following
message.
> MsgBox "The object you selected is not a Polyline. This command
will
> exit. "
> 'Exit Do
> End If
> End If
> 'Loop
> strText = strCnt
> 'Debug.Print strText
> '//A POINT OBJECT IS NOT A VALID ARGUMENT, USE ITS INSERTION POINT.
> '//IN THIS CASE I HAVE SIMPLY USED THE ORIGINAL POINT.
> Pt2 = Ent2.InsertionPoint
> 'I HAVE USED .25 TO SET THE GAP, BUT YOU MAY WISH TO USE
> 'ANOTHER VALUE
> Pt2(1) = Pt(1) - (8 + objText.Height + (8 * 0.25))
> Debug.Print 8 * ThisDrawing.GetVariable("TSPACEFAC")
> If optLeft.Value = True Then
> Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
> pointObj.Color = acRed
> Set objText = ThisDrawing.ModelSpace.AddText(strText, Pt2, 8)
> objText.Alignment = acAlignmentLeft
> '///IF YOU USE ALIGNMENT LEFT THE ALIGNMENT POINT BECOMES
> '///READ ONLY!
> '/////objText.TextAlignmentPoint = Pt2
> objText.Update
> End If
>
> If optMidCent.Value = True Then
> Set pointObj = ThisDrawing.ModelSpace.AddPoint(Pt2)
> pointObj.Color = acRed
> Set objText = ThisDrawing.ModelSpace.AddText(strText, Pt2, 8)
> objText.Alignment = acAlignmentMiddleCenter
> objText.TextAlignmentPoint = Pt2
> objText.Update
> End If
> '////SHOW THE FORM AGAIN
> Me.Show
> Exit_Here:
> Exit Sub
> Err_Control:
> Select Case Err.Number
> Case -2145386476
> If ObjPly Is Nothing Then
> MsgBox "Layer '" & strlayerName & _
> "' does not exist. Please create it before continuing."
> End If
> Err.Clear
> Resume Exit_Here
> Case -2147352567
> 'varErr = ThisDrawing.GetVariable("LASTPROMPT")
> '///THERE ARE MANY WAYS TO DEAL WITH THIS ERROR
> '///SINCE YOU USED ERRNO'S VALUE IN YOUR CODE I
> '///HAVE USED IT IN THE HANDLER.
> If ThisDrawing.GetVariable("errno") <> "52" Then
> Err.Clear
> 'MISSED PICK SEND THEM BACK
> Resume
> '//IF YOU WANT TO ALLOW EXIT WITH RIGHT CLICK
> '//ADD A NEW PROPERTY TO THE THISDRAWING MODULE
> '//THAT IS SET TO TRUE ON A RIGHT CLICK AND
> '//CHECK IT HERE.
> Else
> Err.Clear
> Resume Exit_Here
> End If
> Case Else
> MsgBox Err.Description
> End Select
> End Sub
>
> Randall Rath
> VB Design
> Home of the Wonder Llama
> http://www.vbdesign.net/cadpages
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Rob,
After you write a couple million lines of this code, you will be a genius
too!
The Answer to your question:
PT2 has three elements:

PT2(0)
PT2(1)
PT2(2)

because it is a "variant array of doubles"

The values in the array are from the property:

objText.InsertionPoint

Or in the simplest terms, the X,Y,Z of the insertion point of the selected
text in WCS values.

Randall Rath
0 Likes