mftbrothers Posted July 19, 2010 Share Posted July 19, 2010 (edited) Using Autocad VBA ediyor... Dim item1 As AcadObject Dim ustsx(2), altsx(2) as double 'or variant 'both not working Dim vector1 As Variant ... vector1 = item1.Coordinates If vector1(0) > vector1(4) Then ustsx(0) = vector1(0) altsx(0) = vector1(4) Else ustsx(0) = vector1(4) altsx(0) = vector1(0) End If If vector1(1) > vector1(3) Then ustsx(1) = vector1(1) altsx(1) = vector1(3) Else ustsx(1) = vector1(3) altsx(1) = vector1(1) End If ustsx(2) = 0# altsx(2) = 0# MyAcad.ZoomWindow ustsx, altsx '(error) ........ Run Time error '-2147024809 (80070057) Invalid argument LowerLeft in ZoomWindow Error... After some search on internet i found an explanation for this type of errors. It may be good to learn for other members: I find such description: [in AutoCAD, VBA input arrays are automatically converted to variants. This means that you don’t have to provide a variant array as input to the ActiveX Automation methods and properties when using them from VBA. However, all the output arrays will be in the form of variants, so remember to handle them appropriately. Converting Arrays to Variants AutoCAD ActiveX Automation provides a utility method to convert an array of data into a variant. This method is the CreateTypedArray method, which creates a variant that contains an array of integers, floating numbers, dou-bles, and so forth.] I corrected my code as follows: Dim p1, p2 As Variant Dim utilObj As Object ' late bind the Utility object Set utilObj = ThisDrawing.Utility utilObj.CreateTypedArray p1, vbDouble, ustsx(0), ustsx(1), ustsx(2) utilObj.CreateTypedArray p2, vbDouble, altsx(0), altsx(1), altsx(2) MyAcad.ZoomWindow p1, p2 Edited July 19, 2010 by mftbrothers Quote Link to comment Share on other sites More sharing options...
10west Posted July 26, 2010 Share Posted July 26, 2010 Dim p1(0 To 2) As Double Dim p2(0 To 2) As Double I think you may have to dimension the array explicitly, 0 to 2, 0 to 3, or whatever your min max dimension is Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.