Code Red > VB(A)

Error adding circle

(1/1)

pjm8765:
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: ---                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

--- End code ---

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?

pjm8765:
Sorry, being a muppet!  Have converted the Point3d to an array of doubles.

pjm8765:
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?

n.yuan:

--- Quote from: 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?

--- End quote ---

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.

Navigation

[0] Message Index

Go to full version