Message 1 of 4
AutoCAD VBScript Reference

Not applicable
02-02-2004
11:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Does anyone know of any reference at all for controlling AutoCAD with
VBScript? Here is my problem, I have an application that writes VBScripts
that launch AutoCAD and perform some drawing functions. During one function
I need to translate some points from the OCS to WCS. I am trying to use the
Utility.TranslateCoordinates Method. When I do this, I get a Windows Script
Host error stating there is an Invalid agrument Point in
TranslateCoordinates.
Here is the code in the .vbs file:
'acaddoc was set previous to this point to the current
application.activedocument
'and acadutility was set to the utility object of acaddoc
AcadDoc.ActiveUCS=FrontSideUCS
Dim TranslatedPt
Dim CurrentPt(2)
CurrentPt(0)=xdim/2
CurrentPt(1)=.25
CurrentPt(2)=0
TranslatedPt=AcadUtility.TranslateCoordinates(CurrentPt, 1, 0, False)
Since this is done through vbscript, I had errors that the From/To argument
enum, so i changed it to the enum value. 1 = acUcs, 0 = acWorld
Does anyone have any ideas on how the TranslatedPt line needs to read to be
functional? When writing the .vbs file, all variables are declared, however
no object type is defined for the variables. They are all considered by
VBScript to be variants and I got errors when I used something like "Dim
myString as String". I had to truncate it to "Dim myString".
Any help is greatly appreciated either on how to fix this error, a
workaround for the error (some otherway to calculate the WCS values for the
OCS point), or a reference for AutoCAD and VBScript.
Thank you.