Jump to content

Recommended Posts

Posted

Does anyone know if Autocad 2004 can display dual units (metres and feet) in the command bar for a distance inquiry (not a dimension inquiry which I know can display dual units)? I use drawings in meters and feet and am constantly having to calculate the distances between metres and feet. It would great if it could show both units at the same time!

Posted

I would doubt it. AutoCAD thinks in units, nothing else. Its not until you tell it how big a unit is that it can disply how many inches, meters or light years the objecct is.

Posted

So why can it display dual units in a dimension inquiry and not a distance inquiry?

Posted
So why can it display dual units in a dimension inquiry and not a distance inquiry?

 

it's a function coding, just a minor inconvienience for those of us working with multiple measuring systems.

Posted

what is a dimension inquiry? If you mean adding a dimension it will normally display units. You add the primary discriminator and optionally a scale factor and secondary discriminator.

Posted

I think he's refering to the distance command.

Posted
what is a dimension inquiry? If you mean adding a dimension it will normally display units. You add the primary discriminator and optionally a scale factor and secondary discriminator.

I'm trying to get the dual units displayed when you do a distance inquiry (not a linear or aligned dimension inquiry). It gives you the distance, bearing and dx,dy,dz when you do a distance inquiry in the command bar but I'd really like it to show the distance in both metres and feet. The dimension (Linear or Aligned) inquiry allows you to turn on dual units but it would be nice to have it show the same dual units for a distance inquiry. Thanks for the help!

Posted
Does anyone know if Autocad 2004 can display dual units (metres and feet) in the command bar for a distance inquiry (not a dimension inquiry which I know can display dual units)? I use drawings in meters and feet and am constantly having to calculate the distances between metres and feet. It would great if it could show both units at the same time!

 

You will have to use dimensions, then undo or erase. Fairly simple and the only OOTB solution.

Posted

Perhaps this one:

(vl-load-com)

(setq *DistAlt* "meters"
     *CVUnits* '("" "inches" "feet" "miles" "millimeters" "centimeters" "meters" "kilometers" "microinches" "mils"
                 "yards" "angstroms" "nanometers" "microns" "decimeters" "dekameters" "hectometers" "gigameters"
                 "astronomical_units" "light_years" "parsecs"
                )
)

;;; Command to show distance including alternate units
(defun c:DistAlt (/ base pt1 pt2)
 ;; Check if drawing has base units
 (if (= (setq base (getvar "InsUnits")) 0)
   (if (progn
         (princ "\nThe current drawing is not set to have any base units. ")
         (princ "Should ")
         (princ (if (= (getvar "MEASUREMENT") 0)
                  (setq base 1
                        pt2  "inches"
                  )
                  (setq base 4
                        pt2  "millimeters"
                  )
                )
         )
         (princ " be assumed? Or do you want to setup correctly?\n")
         (initget "Yes No Setup")
         (or (setq pt1 (getkword "[Yes/No/Setup] <Yes>: "))
             (null pt1)
         )
       )
     (cond
       ((eq pt1 "No") (setq base -2))
       ((eq pt1 "Setup") (setq base -1))
     )
   )
 )
 (cond
   ((= base -2)
    (princ "\nNo base units set, using normal Distance command.\n")
    (command "._DIST")
   )
   ((= base -1)
    (alert "Please set the correct units\nin the following dialog's\nInsertion scale group.")
    (vla-SendCommand (vla-get-ActiveDocument (vlax-get-acad-object)) "._UNITS\n")
   )
   ((progn
      (initget (+ 8 128) "Alternate")
      (princ (strcat "\nCurrent alternate units is " *DistAlt* "."))
      (setq pt1 (getpoint "\nSpecify first point [Alternate]: "))
    )
    (while (and pt1 (= (type pt1) 'Str))
      (initget
        (vl-string-trim
          " "
          (apply 'strcat
                 (mapcar '(lambda (unt) (strcat " " (strcase (vl-string-translate "_" "-" unt)))) *CVUnits*)                  
          )
        )
      )
      (if (setq pt1
                 (getkword
                   (strcat "\nChange to which alternate?\n["
                           (vl-string-trim
                             "/"
                             (apply 'strcat
                                    (mapcar '(lambda (unt) (strcat "/" (strcase (vl-string-translate "_" "-" unt)))) *CVUnits*)
                             )
                           )
                           "]: "
                   )
                 )
          )
        (progn
          (setq *DistAlt* (strcase (vl-string-translate "-" "_" pt1) t))
          (initget (+ 8 128) "Alternate")
          (princ (strcat "\nCurrent alternate units is " *DistAlt* "."))
          (setq pt1 (getpoint "\nSpecify first point [Change]: "))
        )
      )
    )
    (if (and pt1 (= (type pt1) 'List) (setq pt2 (getpoint pt1 "\nSpecify second point: ")))
      (progn
        (princ "\n-----------------------------------------------------------------")
        (princ (strcat "\nBase units in " (InsUnits<->CVUnits base) ":"))
        (princ "\n-----------------------------------------------------------------")
        (princ "\nDistance = ")
        (princ (distance pt1 pt2))
        (princ ",  Angle in XY Plane = ")
        (princ (angtos (angle (list (car pt1) (cadr pt1) 0.0)
                              (list (car pt2) (cadr pt2) 0.0)
                       )
               )
        )
        (princ ",  Angle from XY Plane = ")
        (princ (angtos (angle (list (cadr pt1) (caddr pt1) 0.0)
                              (list (cadr pt2) (caddr pt2) 0.0)
                       )
               )
        )
        (princ "\nDelta X = ")
        (princ (- (car pt1) (car pt2)))
        (princ ", Delta Y = ")
        (princ (- (cadr pt1) (cadr pt2)))
        (princ ", Delta Z = ")
        (princ (- (caddr pt1) (caddr pt2)))
        (princ "\n-----------------------------------------------------------------")
        (princ (strcat "\nAlternate units in " *DistAlt* ":"))
        (princ "\n-----------------------------------------------------------------")
        (princ "\nDistance = ")
        (princ (cvunit (distance pt1 pt2) (InsUnits<->CVUnits base) *DistAlt*))
        (princ ",  Angle in XY Plane = ")
        (princ (angtos (angle (list (car pt1) (cadr pt1) 0.0)
                              (list (car pt2) (cadr pt2) 0.0)
                       )
               )
        )
        (princ ",  Angle from XY Plane = ")
        (princ (angtos (angle (list (cadr pt1) (caddr pt1) 0.0)
                              (list (cadr pt2) (caddr pt2) 0.0)
                       )
               )
        )
        (princ "\nDelta X = ")
        (princ (cvunit (- (car pt1) (car pt2)) (InsUnits<->CVUnits base) *DistAlt*))
        (princ ", Delta Y = ")
        (princ (cvunit (- (cadr pt1) (cadr pt2)) (InsUnits<->CVUnits base) *DistAlt*))
        (princ ", Delta Z = ")
        (princ (cvunit (- (caddr pt1) (caddr pt2)) (InsUnits<->CVUnits base) *DistAlt*))
        (princ "\n-----------------------------------------------------------------")
      )
      (princ "\nCommand ended by user.")
    )
   )
   (princ "\nCommand ended by user.")
 )
 (princ)
)

;;; Helper function to convert InsUnits code to/from cvunits code
(defun InsUnits<->CVUnits (code /)
 (if (= (type code) 'INT)
   (nth code *CVUnits*)
   (vl-position (strcase code t) *CVUnits*)
 )
)

Command is DistAlt. It reads the InsUnits as the current drawing's base and defaults to meters for the alternate unit (changeable to any of the units supported in the Units command).

Posted

Great. Thanks for the help. Its exactly what I was looking for! Appreciate it!

Posted

You're welcome! It's the thing about ACad which I like the most: If there's something you want it to do which isn't available ... chances are it's possible to make it in Macro/Script/Lisp/VBA/Net/ARX. And there's probably already someone who's made such in the 30+ years of ACad's history!

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