TheSwamp

Code Red => VB(A) => Topic started by: pjm8765 on June 20, 2017, 08:08:40 AM

Title: Error adding circle
Post by: pjm8765 on June 20, 2017, 08:08:40 AM
I am getting an error message entitled 'Value does not fall within expected range' with an error number of -2147024809 and no other information (no inner exceptions etc).  This happens when the 'circle1 = myDocuments.ThisDrawing.ModelSpace.AddCircle(point, 15)' line below is run :

Code: [Select]
                If keypair.Value.Weepholes.Count > 0 Then
                    For Each point As Point3d In keypair.Value.Weepholes
                        'Add a weephole
                        circle1 = myDocuments.ThisDrawing.ModelSpace.AddCircle(point, 15)
                        circle1.color = ACAD_COLOR.acByLayer
                        circle1.Layer = EASICAD_LAYERS.SOLIDENDWEEPHOLES

The coordinates of the 'point' variable are well within the model space limits (-40073, -77029, 0).  And essentially I have copied and pasted the basics of this code from another function which works fine.

Any ideas?
Title: Re: Error adding circle
Post by: pjm8765 on June 20, 2017, 08:19:47 AM
Sorry, being a muppet!  Have converted the Point3d to an array of doubles.
Title: Re: Error adding circle
Post by: pjm8765 on June 20, 2017, 08:21:33 AM
P.S.  Why doesn't that generate a compile time error i.e. why does it accept a Point3d variable when it needs an array of double?
Title: Re: Error adding circle
Post by: n.yuan on June 20, 2017, 03:09:36 PM
P.S.  Why doesn't that generate a compile time error i.e. why does it accept a Point3d variable when it needs an array of double?

Because:

You used COM API in the mix with .NET API (since I saw "Point3d" which is from .NET API), where the first argument of AddCircle() is an "Object" type (Variant actually), which could be anything at compiling time. It is bad (or at least not "best practice") that while you are already using .NET API, but somehow add another, unnecessary layer of dependency (to COM API) to the code.