basepointdesignz
Programmer
Hi,
Could someone let me know why this might not be running properly:
What it's meant to do: Allow the user to select one or many points on a drawing, the program will insert a number block (incrementing each time a point is picked) and then break out of the loop when the user presses ENTER on the keyboard..
What it's actually doing: Not incrementing the attribute in the block, so stays at 1 every time and not breaking from the loop on anything, not even ESC or a forced error..
Below is the code for this part of the program, it worked for 2004 but not with 2007 or 2008, but i can't see anything wrong myself but you know the old expression 'can't see the woods for the trees' - after hours looking at it, it all looks like cling-on..
Any ideas?
Cheers,
Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..
Could someone let me know why this might not be running properly:
What it's meant to do: Allow the user to select one or many points on a drawing, the program will insert a number block (incrementing each time a point is picked) and then break out of the loop when the user presses ENTER on the keyboard..
What it's actually doing: Not incrementing the attribute in the block, so stays at 1 every time and not breaking from the loop on anything, not even ESC or a forced error..
Below is the code for this part of the program, it worked for 2004 but not with 2007 or 2008, but i can't see anything wrong myself but you know the old expression 'can't see the woods for the trees' - after hours looking at it, it all looks like cling-on..
Code:
'***********************************************
' PICK POINTS....
'***********************************************
Private Sub selectcoordsBTN_Click()
On Error Resume Next
If Err.Number <> 0 Then
MsgBox "The program has encountered an error and cannot be run at this time. Please try running it again..", vbCritical, "Pogram Error.."
Exit Sub
ThisDrawing.SendCommand " " & vbCr
Else
'Do nothing and continue with the main program..
End If
ThisDrawing.ActiveSpace = acModelSpace 'Force drawing to modelspace..
countx = 1 'Set counter to nothing..
rowcount = 0
textYoffset = 0
countxx = countx * 3
xpointform.Hide 'Hide form to allow user to slect points from AutoCAD..
' Error Test for GetPoint method..
On Error Resume Next
TryAgain:
ptx = ThisDrawing.Utility.GetPoint(, vbCr & "Pick the first point (Press ENTER to finish).. ") 'Getpoint method..
'Set pointX = ThisDrawing.ModelSpace.AddPoint(ptx) 'Add an AcadPoint at each pickpoint, to show where the user has selected..
Set blkX = ThisDrawing.ModelSpace.InsertBlock(ptx, "X:\CAD_Tools\PCE\PointNum.dwg", 1#, 1#, 1#, 0)
blkX.Layer = "XPoints_bpd"
' Get Attribute values..
varAttributes = blkX.GetAttributes
' Edit the attribute text strings to show new coordinates..
varAttributes(0).TextString = countx
ErrHndlr:
If Err.Number <> 0 Then
If Err.Number = -2145320928 Then
GoTo END_DO
End If
Err.Clear
GoTo TryAgain
End If
On Error GoTo ErrHndlr
ReDim Preserve pointinfo(2, 0)
' Add data to the list box..
ptx(0) = ptx(0) / 1000
ptx(0) = Round(ptx(0), 3)
ptx(1) = ptx(1) / 1000
ptx(1) = Round(ptx(1), 3)
pointinfo(0, rowcount) = countx
pointinfo(1, rowcount) = ptx(0)
pointinfo(2, rowcount) = ptx(1)
ListBox1.Column() = pointinfo
'*******************************
'** Start the point pick loop **
'*******************************
Do
countx = countx + 1 'Add 1 to the counter..
countxx = countx * 3
rowcount = rowcount + 1
' Error Test for GetPoint method..
On Error Resume Next
TryAgain2:
ptx = ThisDrawing.Utility.GetPoint(, vbCr & "Pick the next point (Press ENTER to finish).. ") 'Getpoint method..
'Set pointX = ThisDrawing.ModelSpace.AddPoint(ptx) 'Add an AcadPoint at each pickpoint, to show where the user has selected..
Set blkX = ThisDrawing.ModelSpace.InsertBlock(ptx, "X:\CAD_Tools\PCE\PointNum.dwg", 1#, 1#, 1#, 0)
blkX.Layer = "XPoints_bpd"
' Get Attribute values..
varAttributes = blkX.GetAttributes
' Edit the attribute text strings to show new coordinates..
varAttributes(0).TextString = countx
ReDim Preserve pointinfo(2, countx - 1)
' Add data to the list box..
ptx(0) = ptx(0) / 1000
ptx(0) = Round(ptx(0), 3)
ptx(1) = ptx(1) / 1000
ptx(1) = Round(ptx(1), 3)
pointinfo(0, rowcount) = countx
pointinfo(1, rowcount) = ptx(0)
pointinfo(2, rowcount) = ptx(1)
ListBox1.Column() = pointinfo
ErrHndlr2:
If Err.Number <> 0 Then
If Err.Number = -2145320928 Then
GoTo END_DO
End If
Err.Clear
GoTo TryAgain
End If
On Error GoTo ErrHndlr2
On Error GoTo END_DO 'Exit the loop if ENTER or another key is hit (basically an error)..
Loop
'*******************************
'******** End the loop *********
'*******************************
END_DO:
ReDim Preserve pointinfo(2, 0)
CheckBox1.Value = True
xpointform.Height = 348
xpointform.Show
End Sub
'***********************************************
' PICK POINTS....
'***********************************************
Any ideas?
Cheers,
Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..