Jump to content

Recommended Posts

Posted

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.

Posted

Look for LUNITS, MEASUREINIT system variables and SetVariable method.

Posted
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.

Posted

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.

Posted

For example:

 

ThisDrawing.SetVariable "LUNITS", 3

 

Set LUNITS system variable to 3 (Engineering units).

Posted
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 :)

Posted
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.

Posted
I did try this but when I type UNITS its always set as millimeters.

 

Look for INSUNITS variable.

Posted

Thanks, I finally got there. I just need to read what you guys are saying two or three times before it sinks in sometimes. :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...