Jump to content

VBA spline with variable amount of points


woutervddn

Recommended Posts

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...