+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    Using
    Inventor 2011
    Join Date
    Jul 2010
    Posts
    3

    AutoCAD VBA spline with variable amount of points

    Registered forum members do not see this ad.

    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


    Thanks in advance



    Wouter

  2. #2
    Super Member SEANT's Avatar
    Using
    AutoCAD 2012
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,968

    Default

    Unknown quantites are usually dealt via Dynamic Arrays.

    Code:
     
    Dim fitPoints() As Double
    Dim fpCount as Integer
    Dim fpCountBound as Integer
    Once fpCount count is known, for instance, then:

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

  3. #3
    Forum Newbie
    Using
    Inventor 2011
    Join Date
    Jul 2010
    Posts
    3

    Default

    Registered forum members do not see this ad.

    thanks a lot! I'll try it right away..

Similar Threads

  1. How to pick a variable number or points
    By Alhazred in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 23rd Jul 2010, 06:38 pm
  2. LISP to draw Spline or 3D Pline from Points or Lines
    By Phiphi in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 21st Feb 2009, 02:06 pm
  3. Control points of spline to excel
    By karayelh in forum AutoCAD General
    Replies: 0
    Last Post: 14th Oct 2007, 07:05 am
  4. amount of blocks??
    By grasshopper in forum AutoCAD Beginners' Area
    Replies: 15
    Last Post: 3rd Oct 2007, 09:34 pm
  5. Finding points on a spline
    By koder in forum AutoCAD General
    Replies: 3
    Last Post: 15th Sep 2004, 12:11 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts