AutoCAD has VBA behind it, and many of its own functions.
One of those is the function to add a block to a drawing.
Following is a routine that adds the named block, "B,"
at the location x=20, y=15, z=0,
x-scaling=1, y-scaling=1, z-scaling=1,
rotation=0:
Code:
Public Sub A()
Dim x As Object
With ThisDrawing.PaperSpace
Set x = .InsertBlock( _
Array(20, 15, 0), _
"B", 1, 1, 1, 0) ' This fails. Invalid Procedure call.
Dim r(0 To 2) As Double
r(0) = 20
r(1) = 15
Set x = .InsertBlock( _
r, _
"B", 1, 1, 1, 0) ' This flies.
End With
End Sub
So apparently, a Variant(array) will not do, but a true array of Doubles will.
So I tried to write the following:
Code:
Public Function CPoint( X_Dim As Double, _
Y_Dim As Double, _
Optional Z_Dim As Double = 0 _
) As Double()
ReDim CPoint(0 To 2)
CPoint(0) = X_Dim ' See following text.
CPoint(1) = Y_Dim
CPoint(2) = Z_Dim
End Function
Of course, the point where the comment says "See following text." tries to see the CPoint(0) as a recursive function call, making the assignation an invalid operation:
"Function call on left-side of assignment must return Variant or Object."
But I want to be able to use the format:
Code:
Set x = .InsertBlock( _
CPoint(20, 15), _
"B", 1, 1, 1, 0)
Thoughts?