Jump to content

Zoom Window Error What i am doing wrong??


mftbrothers

Recommended Posts

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 by mftbrothers
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...