wannabe Posted October 17, 2008 Posted October 17, 2008 How do I set the drawing units from the default to meters (or any other of the available units)? I couldnt find the information I was looking for on the Help menu. If you want to see my code there is another thread titled VBA basics; created by me. Quote
ASMI Posted October 17, 2008 Posted October 17, 2008 Look for LUNITS, MEASUREINIT system variables and SetVariable method. Quote
wannabe Posted October 17, 2008 Author Posted October 17, 2008 Look for LUNITS, MEASUREINIT system variables and SetVariable method. Sorry, I'm a total noob at the moment. This is my first week programming and I'm teaching myself in between workload tasks. But arent the commands you mentioned, for AutoLISP? If i were looking for the quickest way to do something then you would be spot on. But at the moment I am just trying to familiarise myself as much as possible with VBA until I get some books and official training. thanks. Quote
NBC Posted October 17, 2008 Posted October 17, 2008 The following code will ask the user to input an integer to set the variable INSUNITS; and then the code will set INSUNITSDEFSOURCE and INSUNITSDEFTARGET variables to the same integer value as what was inputted. Option Explicit Public Sub Example_SetVariable() Dim retVal As String Dim SysvarName As String Dim sysVarData As Variant Dim DataType As Integer ' Set INSUNITS system variable (data type Integer) to 6. NOTE that ' you need to declare a variable as the data type of system variable, ' assign data to that variable and then make it variant type retVal = ThisDrawing.Utility.GetString _ (1, vbCrLf & "Enter the Value of InsUnits (This will also change InsUnitsDefSource & InsUnitsDefTarget to the same Value): ") Dim intData As Integer SysvarName = "INSUNITS" intData = retVal sysVarData = intData ' Integer data ThisDrawing.SetVariable SysvarName, sysVarData ' Check the variable using GetVariable sysVarData = ThisDrawing.GetVariable(SysvarName) MsgBox SysvarName & " = " & sysVarData, , "SetVariable Example" SysvarName = "INSUNITSDEFSOURCE" ThisDrawing.SetVariable SysvarName, sysVarData SysvarName = "INSUNITSDEFTARGET" ThisDrawing.SetVariable SysvarName, sysVarData End Sub Not sure if this is what you are after; but it expands a little on what Asmi commented upon. Quote
ASMI Posted October 17, 2008 Posted October 17, 2008 For example: ThisDrawing.SetVariable "LUNITS", 3 Set LUNITS system variable to 3 (Engineering units). Quote
wannabe Posted October 17, 2008 Author Posted October 17, 2008 For example: ThisDrawing.SetVariable "LUNITS", 3 Set LUNITS system variable to 3 (Engineering units). Thanks I thought you were giving me lisp commands but my inexperience told. Again, I'll try these when I get to work on Monday and thankyou, Any ideas which books would be best for me to learn VBA. If im honest, I dont really understand when I set As variant, As string etc.Ok, i know string is text etc but I'd love a clear definition of each so I am not assuming etc. Any ideas where I can best find the explanations I need? Then I can come back and give you guys even more advanced questions Quote
wannabe Posted October 20, 2008 Author Posted October 20, 2008 For example: ThisDrawing.SetVariable "LUNITS", 3 Set LUNITS system variable to 3 (Engineering units). I did try this but when I type UNITS its always set as millimeters. Quote
ASMI Posted October 20, 2008 Posted October 20, 2008 I did try this but when I type UNITS its always set as millimeters. Look for INSUNITS variable. Quote
wannabe Posted October 21, 2008 Author Posted October 21, 2008 Thanks, I finally got there. I just need to read what you guys are saying two or three times before it sinks in sometimes. Quote
Recommended Posts
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.