Results 1 to 3 of 3

Thread: Draw function VBA

  1. #1

    Draw function VBA

    Hello,

    I'd like to draw a function with VBA for autocad, using a polyline. I'd like to use the following code:

    Sub Example_AddPolyline()
        Dim plineObj As AcadPolyline
        Dim points(0 To 10) As Double
        ' Define the 2D polyline points
        points(0) = 1: points(1) = f: 
        points(2) = 2: points(3) = f:
        points(4) = 3: points(5) = f: 
        points(6) = 2: points(7) = f:
        points(8) = 3: points(9) = f: 
        Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
        ZoomAll
    End Sub

    where points(even) are the x-axis units and points(odd) are the value of the function f (which is not important here) for the x-value.


    How could i do? Trying using a for-cycle maybe...?

    Thank you
    Last edited by Aussiebear; 12-31-2024 at 04:35 PM.

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi ElCidCampead!
    You need to change "AddPolyline" into "AddLightWeightPolyline".
    "AddPolyline" need three direction coordinate, and change "Dim points(0 To 10) As Double" to "Dim points(0 To 9) As Double" if you want to create a 5 points polyline.

  3. #3
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    additional remarks:
    "Dim plineObj As AcadPolyline" must be changed to "Dim plineObj As AcadLWPolyline".

Tags for this Thread

Posting Permissions

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