So I'm new to the programming idea. I've done projects in LISP, and customized my share of pallet commands. But now I want to take some time to understand how to do the more detailed things that Autocad is capable of. So I started out with the simple task...
I want to select a point in a drawing.
Have a form pop up and offer me three options.
Rise, Run, and Number of Risers.
Then click on the "Magic"
CommandButton.
And Poof, it will have created a polyline, that looks like stair.
I figured this would be a simple project to get me started, it had all the great elements. I have read a number of different tutorials, seen many different examples, and have learned a lot about how other projects work. So now I'm stuck. I know where to make my declarations. I know how to add a module. I know how to create a form and how to have the results of the form appear in a module. If everything is made public, why are theses values not passing thru from one module to another?
Dim Abstairs As Double all declarations are made at top of page in thisdrawing
Dim Bbstairs As Double
Dim Cbstairs As Double
Dim R As Integer
Dim X As Double
Dim Y As Double
Dim ptstair As Variant
Dim p As Collection
Dim i As Integer
Public Sub stair()
ptstair = ThisDrawing.Utility.GetPoint(, "Select a point")
MsgBox ptstair(0) & ";" & ptstair(1) & ";" & ptstair(2)
Abstairs = ptstair(0)
Bbstairs = ptstair(1)
Cbstairs = ptstair(2)
MsgBox Abstairs & Bbstairs & Cbstairs
StrOpt.Show
='this is the name of my form.End Sub
after options in form are entered and the magic button is pushed... it should begin this module
Public Sub makestair()
MsgBox Abstairs & ";" & Bbstairs & ";" & Cbstairs everytime this message box appears, the values are blank.
R = StrOpt.textboxR
X = StrOpt.textboxX
Y = StrOpt.textboxY
' You always have to do this with a collection before you can use it.
Set p = New Collection
' We need r*2+1 points because we go up first; this gives us r horizontal lines
For i = 1 To R * 2 + 1
' This line tells us if it's odd or even; i Mod 2 = 0 means i is even
' (i divided by 2 gives us a remainder of 0)
If i Mod 2 = 0 Then
p.Add "(" & Abstairs + X * (i - 2) / 2 & "," & Bbstairs + Y * i / 2 & "," & Cbstairs & ")"
Else
p.Add "(" & Abstairs + X * (i - 1) / 2 & "," & Bbstairs + Y * (i - 1) / 2 & "," & Cbstairs & ")"
End If
' This just outputs the variables to the spreadsheet so that you can check it; you probably
' won't be able to do this in AutoCAD
' This is the end of the loop; it tells i to increment by 1
Next i
MsgBox p(1) & p(2) this message box shows the values for p but it does not reference the point selected earlier.
I have tried different syntax for getting the addpolyline to look up the values of p from the collection and use them for the points that should be included in the polyline. I was thinking that only an array can be used in this manor for a polyline. But not sure.
End Sub
If there is a better way to do this I'm open to new directions. This is the one that made the most sense to me. I have ran across so many roadblocks, that is becoming apparant that I have so much more home work to do. And then maybe one day I will be come familiar enough to move on to acad.net. That would be nice.
Thanks all.