Author Topic: Error adding circle  (Read 4801 times)

0 Members and 1 Guest are viewing this topic.

pjm8765

  • Guest
Error adding circle
« 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?

pjm8765

  • Guest
Re: Error adding circle
« Reply #1 on: June 20, 2017, 08:19:47 AM »
Sorry, being a muppet!  Have converted the Point3d to an array of doubles.

pjm8765

  • Guest
Re: Error adding circle
« Reply #2 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?

n.yuan

  • Bull Frog
  • Posts: 348
Re: Error adding circle
« Reply #3 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.