AutoCAD VBScript Reference

AutoCAD VBScript Reference

Anonymous
Not applicable
3,218 Views
3 Replies
Message 1 of 4

AutoCAD VBScript Reference

Anonymous
Not applicable
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.
0 Likes
3,219 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
The values need to be Doubles so use CDbl too convert them before passing. ___________________________ Mike Tuersley CADalyst's AutoCAD Clinic Rand IMAGINiT Technologies
0 Likes
Message 3 of 4

Anonymous
Not applicable
 
0 Likes
Message 4 of 4

Anonymous
Not applicable
Hi Paul, Thank you very much for the suggestion. I believe that it worked. I made a change to my script to test and I got a different error on a line past that, so it made it past that point without an error. I tried to have a msgbox appear right after that -- msgbox TranslatedPt(0) to verify the value, however that line produced a type mismatch error. I have some other issues with how the script is formated, however once I make those changes, I will be able to tell if it indeed worked, however so far it looks very promising. Thanks again for your help. "Paul Marshall" wrote in message news:Paul.Marshall.110lcb@vbdesign.net... > > Try this: > > Dim TranslatedPt > Dim CurrentPt > > Call AcadUtility.CreateTypedArray(CurrentPt, 5, xdim / 2, 0.25, 0) > TranslatedPt = AcadUtility.TranslateCoordinates(CurrentPt, 1, 0, False) > > > -- > Paul Marshall - Toot-OR > > When a wise man does not understand, he says: "I do not understand." > The fool and the uncultured are ashamed of their ignorance. > They remain silent when a question could bring them wisdom. > . > ------------------------------------------------------------------------ > Paul Marshall's Profile: http://www.vbdesign.net/expresso/member.php?action=getinfo&userid=102 > View this thread: http://www.vbdesign.net/expresso/showthread.php?threadid=25584 >
0 Likes