Author Topic: Error adding circle  (Read 248 times)

0 Members and 1 Guest are viewing this topic.

pjm8765

  • Newt
  • Posts: 23
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

  • Newt
  • Posts: 23
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

  • Newt
  • Posts: 23
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: 240
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.