I get the following error
<Unable to cast object of type 'System.Object[]' to type 'Autodesk.AutoCAD.Interop.Common.AcadArc'.>
on these lines
Dim oArc3 As AcadArc
Dim oArc4 As AcadArc
If oArc1.Radius > oArc2.Radius Then
oArc3 = DirectCast(oArc1.Offset(BASE_SHELL_OFFSET), AcadArc)
oArc4 = DirectCast(oArc2.Offset(-BASE_SHELL_OFFSET), AcadArc)
Else
oArc3 = DirectCast(oArc1.Offset(-BASE_SHELL_OFFSET), AcadArc)
oArc4 = DirectCast(oArc2.Offset(BASE_SHELL_OFFSET), AcadArc)
End If
oArc1 and oArc2 are acad arcs(obviously) - but the .Offset method sig returns an object not an arc (how weird is that?)
what's the solution with option strict on?
ps without trying to cast to arc i get the following error
oArc3 = oArc1.Offset(BASE_SHELL_OFFSET)
oArc4 = oArc2.Offset(-BASE_SHELL_OFFSET)
produces the compile error
option strict on disallows implicit conversion from object to acad arc (or something close to that wording)
Well, it only goes as weird as your code goes
The Offset() method returns a variant (in VBA)/object (in .NET), which is and ARRAY of entity generated by the method. You cannot cast an array to an AcadArc/AcadEntity, of course. Depending on the original entity type, the generated entity may not be the same type. Here is the quote from VBA document:
<quote>
For many curves, the result of this operation will be a single new curve (which may not be of the same type as the original curve). For example, offsetting an ellipse will result in a spline because the result does not fit the equation of an ellipse. In some cases it may be necessary for the offset result to be several curves.
</quote>
In your case, it is lucky enough, you get a single AcadArc back (i.e. one AcadArc element in the returned array). So, your code should look like this:
oArc3 = DirectCast(oArc1.Offset(BASE_SHELL_OFFSET)(0), AcadArc)
Norman Yuan
yes, thanks
I did finally see that array business.
thanks for your response
mark