PDA

View Full Version : Cad Automation


pklj_2000
30-06-2004, 04:45 PM
Hi

I am using Autocad through VBScript (OLE Automation) and I'd like to know if
there is another way to access the array when calling Utility.GetPoint() function. I know it returns an array, but I am not able to access these values through VBScript.

Thanks
Alessandro

TCARPENTER
30-06-2004, 06:04 PM
Alessandro,

I know VBScript support only one datatype, a variant, but I'm not sure I understand why you are not able to access the points. Your code should look something like this:

Sub Test
Dim varPnt as Variant
...
varPnt = <document object>.Utility.Getpoint
...
Debug.Print "Point was: " & varPnt(0) & ", " & varPnt(1) & ", " & varPnt(2)
End Sub

What type of error are you getting, or you're not getting anything?

Sorry for the last post - I fat fingered the new keyboard! :oops:

Todd

pklj_2000
06-07-2004, 07:10 PM
Hi, I get a mismatch error, with your code, but when I use UBound, it brings me 2

Sorry for the delay, I posted this question everywhere (and it takes time) but nobody could answer me :cry:

I just copy my code to VBA and it works!!




<SCRIPT LANGUAGE="VBScript">
Dim AcadObj
Dim AcadDoc
Dim AcadUtility

set AcadObj = createobject("AutoCAD.Application")
Set AcadDoc = AcadObj.ActiveDocument
Set AcadUtility = AcadDoc.Utility
Dim Point1
Dim Point2
dim a
AcadUtility.CreateTypedArray Point1, vbDouble, 19.8161,19.7178,0
AcadUtility.CreateTypedArray Point2, vbDouble, 19.8161,18.7178,0

'it works
AcadObj.Application.ZoomWindow point1, point2


'error
a= point1(1)

</script>



Regards
Alessandro

TCARPENTER
07-07-2004, 12:05 AM
Alessandro,

Not quite sure if this is the problem or not, however, in your CreateTypedArray statement, you have forced the Point1 array to a double, and 'a' is defined as a variant, (although there should be no problem with this) VBScript may not tolerate this without a 'Set' keyword in front of a = point1(1)?

What are you executing the vbscript through? Is this HTML (web page) or something else?

Maybe a little more information would help.

Todd

pklj_2000
07-07-2004, 11:34 AM
Hi, Todd
part of the designers works remotely. They draw, i.e. a structure, but the list of material used should be drawn from the headquarter (where the database is). So we'd like to make a web interface to draw this. If this solution dont work, we will probably create a 3-tier software in VB6

I made some more tests and it behave strange. I tryed your idea w/o success. I get the same type mismatch error

I even tryed that:
the code "document.write(typename(point1))" returns me DOUBLE
the code "IsArray(point1)" brings me TRUE
then code "document.write(typename(point1(1)))" brings me an error

Strange.. as "typename(point1) " is Double, I tryed operations with a Double, but it do not work...

Regards
Alessandro