Setvar USERR1 Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I've recently been working on updating some code from about 20 years ago and I ran into an issue with the AutoLISP routines and using the setvar command.
The program that I'm working with begins with AutoCAD's VBA enabler, loads and calls the AutoLISP routines to make my drawing, and then returns to the VBA enabler to finish out the program. I'm trying to edit the way that the program prints to PDF, so I wanted to grab the drawing scale that was set in my AutoLISP routine and create a variable to store it in the VBA script.
I figured that the easiest way to do this was to use the USERR1 and USERR2 system variables, as those are easily callable from VBA. When I wrote out the lines of code to set the variables, however, I noticed that they never actually changed the value from its default. I tried again, this time using USERS1 and the same thing happened.
The part I found odd was that I was able to set these variables directly from the VBA script and it worked fine.
The portion of AutoLISP that I wrote is:
;grab the GSCALE value for each drawing
(setvar "USERS1" "COMPLETE")
(if (= DWGTYP "SETTING")(setvar "USERR1" GSCALE))
(if (= DWGTYP "CORE")(setvar "USERR2" GSCALE))
With the GSCALE variable being a scaling factor determined earlier on in the code - its data type is a real.
And the VBA code doing the same thing is:
ThisDrawing.SendCommand "USERS1 COMPLETE" & vbCr
ThisDrawing.SendCommand "USERR1 12.5" & vbCr
ThisDrawing.SendCommand "USERR2 13.0" & vbCr
And this one sets these system variables just fine. I spent a while this morning looking online to see if I could find some answers, but I haven't found anything that said that this shouldn't work for both of my cases.
Does anyone happen to know why this might be happening?