>>To All,
>>
>>I am attempting to pass an array of doubles to a VBA method in AutoCAD.
>>
>
>You might try using the code I posted in FAQ 696 for creating a SafeArray as a memory structure and passing a pointer to it, assuming it wants a SafeArray. If not, you might try stringing together a ULONG for the value 3, followed by the three doubles converted to strings (there's conversionn code for creating doubles in memory in my ClsHeap class.)
I downloaed your SafeArray from UT and tried it. It did not work, giving me the "Illegal Parameter" message. See the code below:
local array anPoint1(3)
local array anPoint2(3)
anPoint1[1]=62
anPoint1[2]=420
anPoint1[3]=0
nptrPoint1 = AllocSafeArraySingleDimensional(@anPoint1,0,5)
anPoint2[1]=432
anPoint2[2]=430
anPoint2[3]=0
nptrPoint2 = AllocSafeArraySingleDimensional(@anPoint2,0,5)
oLine = oModel.AddLine(nptrPoint1,nptrPoint2) && failed
oLine = oModel.AddLine(@nptrPoint1,@nptrPoint2) && also failed
= DeAllocSafeArray(nptrPoint1)
= DeAllocSafeArray(nptrPoint2)
I do not understand "stringing together a ULONG for the value 3". Is this for the pointer to the three doubles converted to strings?
I had a little trouble with SafeArray.
When I ran :
cTemp = NumToDouble(62)
? DoubleToNum(cTemp)
I got 0 as an answer, not 62.
I tried :
cTemp = FLL_DoubletoChar(62) && FLL_DoubleToChar from convert.fll
** && Christof Lange/Mark Wilden
? DoubleToNum(cTemp)
I got 62 as I should. I replaced NumToDouble with FLL_DoubletoChar in SafeArray and still got my error.
Also there were some minor typos in the version I downloaded:
#DEFINE SINGLE_DIMENSION_ARRAY 1
should be :
#DEFINE SINGLE_DIMENSIONAL_ARRAY 1
also:
CASE tnElementType = 5 && 8 byte DOUBLE
unResult = NumToDOUBLE(tuElementType)
should be (I believe) :
CASE tnElementType = 5 && 8 byte DOUBLE
uResult = NumToDOUBLE(tuElementSource)
and my version of clsheap 9/29/2000 did not contain the function NumToSingle().
Thank you for your time.
Best Regards
Don Simpson