AddLightWeightPolyline method

 BricsCad AddLightWeightPolyline assumes a zero based array. this is not the case in autocad.  i was comparing and the polyline in bricscad is creating a zero for the first x value, then running the polyline, so the x and y values are interchanged, and just ignoring the last value in the array.  not terrible but the first big difference i have seen. is this an item that is considered a bug that might be fixed?

i run vba from excel, i am using a 32 bit trial version of bricscad.  i have another question about why is there no vba in the 64 bit version. i assume its a technical reason, but is there any possibility of vba disappearing altogether in future releases?




Comments

  • Hi Terry,

    if you have a repeatable issue, then I would raise a Support Request including sample code. That way if it proves to be a bug it can be fixed.

    Vba is deprecated, and is no longer supported by Microsoft. Vba started out on a 32bit platform, so I believe getting it to run on 64bit presents some challenges. Assuming it does become available, you may need 64bit Excel to get the two applications to successfully communicate.

    I think the general advice (in the longer term) is to look at moving your code to another language such as .net.

    Regards,
    Jason Bourhill

  •  screenshots attached, code and results.

    image2016-09-25_1.jpg
    image2016-09-25_2.jpg
  • Why would you not use a zero-based array?
  •  i can, i rewrote some code to work last night.  but first i had to discover why the code did not work in bricsys that worked fine in autocad.  its undocumented in the bricsys com reference that it MUST be a zero based array. i think it qualifies as a bug that it runs anyway and creates a value of zero.  it should just error out. code that works fine in autocad will completely not work in bricsys.  

    its not a deal breaker but it deserves mention.  polylines are a core object.  i assume the 3d polyline is the same way but i use it less.



  • I'm sure that if you check   YOUR original (VBA? VB?) code  it will have something that OVERRIDES the default index. Check for 'Option Base 1'
    So allow me to challenge your statement that in AutoCAD arrays are NOT 0-based...To the  best of my knowledge they are 0-based (unless specified otherwise)
  • I never set option base,  and so I never declare an array such as

    dim pt( 9) which would make a 10 point array,

    I would do

    dim  pt (1 to 10)  or if I had to and know I had to

    dim pt(0 to 9)

    autocad addlightweightpolyline will take either one, bricsys will not.

    the code I posted in the jpg, both examples run in autocad identical and bricsys results diverge as shown in the other jpg.

    perhaps autocad intended the polyline method to be zero based and they forgot to check it, but the method does not care what the index values are as long as the array is an even number. I am sure of this.

    here is an example I have to rewrite. again, not a big deal, but a definite task

    Sub mbox(p1 As Double, p2 As Double, p3 As Double, p4 As Double, strlayer As String)
        Dim objent As AcadLWPolyline
        Dim pt(1 To 8) As Double
       
        pt(1) = p1: pt(2) = p2
        pt(3) = p3: pt(4) = p2
        pt(5) = p3: pt(6) = p4
        pt(7) = p1: pt(8) = p4
        Set objent = acadDoc.ModelSpace.AddLightWeightPolyline(pt)
        objent.Closed = True
        objent.layer = strlayer
    End Sub

  •  not meaning to belabor the point, but this runs in autocad as expected, drawing a triangle. 

    Sub AddLightWeightPolyline_Example3()
    ' This example adds a lightweight polyline to the drawing.
        Dim myLWP As AcadLWPolyline
        'LWpolyline expects an array of 2D OCS coordinates (only x and y)
        Dim myPoints(11 To 16) As Double
        myPoints(11) = 1: myPoints(12) = 2
        myPoints(13) = 4: myPoints(14) = 2
        myPoints(15) = 4: myPoints(16) = 5
        Set myLWP = acadDoc.ModelSpace.AddLightWeightPolyline(myPoints)
        myLWP.Closed = True
        myLWP.Update
        acadDoc.Application.ZoomExtents
    End Sub

    in bricsys it draws a polyline at a single point because it substitutes zeros for all the values.

    --------- Lwpolyline ---------------------------------------------
                      Handle:  97
               Current space:  Model
                       Layer:  0
                       Color:  256 (BYLAYER)
                    Linetype:  ByLayer
              Polyline Flags:  Closed
                        Area:  0.0000 sq. in. (0.0000 sq. ft.)
                   Perimeter:  0"
                    Location:  X=   0"  Y=   0"  Z=   0"
                    Location:  X=   0"  Y=   0"  Z=   0"
                    Location:  X=   0"  Y=   0"  Z=   0"

     of course i would not program it that way. but i start with one a lot. dont have to.

    other than that it looks like a great program.

  • In your other topic you have explained that the VBA code runs in Excel. Ferdinand may not be aware of this. IMO this is a 'COM' problem rather than a VBA problem. You should definitely send in a Support Request.
  • I am seeing the same behavior from the bricscad vba editor.  I paste in the addlightweightpolyline example from bricscad

    https://www.bricsys.com/bricscad/help/en_INTL/CurVer/DevRef/index.html?page=source%2FBRX_01.htm

    it runs,

    change index numbers as per above and it substitutes zero values.

  • Terry at this point I am guessing that the AutoCAD COM interface is able to cope with arrays that are not zero-based (by turning them into zero-based arrays) whereas BricsCAD is not. Repeating your last test in AutoCAD would shed more light on this issue and on Ferdinand's statement.
  •  its a very impressive program.  this is a small workable issue. 


This discussion has been closed.