Hi everyone
since I'm new to scripting, here is a simple beginners routine I made.
It creates a sequence of numbers based on your input of a lowest value, highest value and increment. The input locations are the first and second points. To get better at coding, it's perhaps best to let my code be reviewed by more experienced users, so I don't get used to bad practice.
There are some ideas floating in my head of how to beef this code up. They might be impossible or just not worth the effort, but i have no idea about what's possible and not.
-First thing is, perhaps a preview of the first number attached to the cursor as you are placing the first point?
-Second: when placing the second point, allow polar tracking and dynamic input from the first point. Basically the same behaviour as when drawing the second point of a line.
----------------------------------------------------
Sub AddNumbers()
Dim number As AcadText
Dim insertpointA As Variant
Dim insertpointB As Variant
Dim currentpoint(0 To 2) As Double
Dim StartNumber As Integer
Dim EndNumber As Integer
Dim increment As Integer
StartNumber = ThisDrawing.Utility.GetInteger("Give first number")
EndNumber = ThisDrawing.Utility.GetInteger("Give last number")
increment = ThisDrawing.Utility.GetInteger("Give increment")
insertpointA = ThisDrawing.Utility.GetPoint(, "Give starting point")
insertpointB = ThisDrawing.Utility.GetPoint(, "Give second point")
For n = StartNumber To EndNumber Step increment
'this loop sets the coordinates of the current text being added
For o = 0 To 2
currentpoint(o) = insertpointA(o) + (insertpointB(o) - insertpointA(o)) * (n - StartNumber) / (increment)
Next
Set number = ThisDrawing.ActiveLayout.Block.AddText(n, currentpoint, 200)
Next
Exit Sub
fail:
MsgBox "Invalid input! Routine cancelled"
End Sub
----------------------------------------------------