PDA

View Full Version : VBA spline with variable amount of points



woutervddn
28th Jul 2010, 07:02 pm
hi,

I'm working on a program that would automate the drawing of a curve. Normally you would use spline command and put where you want your points to be.
Now the problem is that the amount of points can vary. I used this code:

' Define the extrusion path (spline object)
Dim splineObj As AcadSpline
Dim startTan(0 To 2) As Double
Dim endTan(0 To 2) As Double
Dim fitPoints(0 To snggeg) As Double

snggeg is the amount of points that I need.

After this part I start putting the values in the fitpoints & then I draw the spline. but he keeps saying (about snggeg): "compile error: constant expression required."

That's a problem! Any ideas about how to fix it? I could do it with an if and go make the fitpoints from 0 to 2, from 0 to 5, from... only problem is that we might need 500 points sometimes. so that are 500 ifs, which doesn't sound fun to me..

Pls let there be someone with a solution cause I've allready spent WAY to much time on this problem :D


Thanks in advance



Wouter

SEANT
28th Jul 2010, 08:04 pm
Unknown quantites are usually dealt via Dynamic Arrays.



Dim fitPoints() As Double
Dim fpCount as Integer
Dim fpCountBound as Integer


Once fpCount count is known, for instance, then:



fpCountBound = (fpCount * 3) - 1
Redim fitPoints(fpCountBound)

woutervddn
30th Jul 2010, 09:24 am
thanks a lot! I'll try it right away..