AddLightWeightPolyline method
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
0 -
screenshots attached, code and results.2016-09-25_1.jpg2016-09-25_2.jpg0
-
Why would you not use a zero-based array?0
-
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.0
-
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)0 -
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 Sub0 -
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 DoublemyPoints(11) = 1: myPoints(12) = 2myPoints(13) = 4: myPoints(14) = 2myPoints(15) = 4: myPoints(16) = 5Set myLWP = acadDoc.ModelSpace.AddLightWeightPolyline(myPoints)myLWP.Closed = TruemyLWP.UpdateacadDoc.Application.ZoomExtentsEnd Subin bricsys it draws a polyline at a single point because it substitutes zeros for all the values.--------- Lwpolyline ---------------------------------------------Handle: 97Current space: ModelLayer: 0Color: 256 (BYLAYER)Linetype: ByLayerPolyline Flags: ClosedArea: 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.0
-
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.0
-
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.
0 -
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.0
-
its a very impressive program. this is a small workable issue.0