Jump to content

Block creation units


Dayananda

Recommended Posts

 (command "-block""ZWLEADERRF" "non"(list 0 0) ssarrow"" )

When I creating a block using a selection set; How can I set the block units

In this code ssarrow is the selection set.

image.png

Link to comment
Share on other sites

I think it pulls from the drawing? so having that set before you make the block should work.

 

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-A58A87BB-482B-4042-A00A-EEF55A2B4FD8

(setvar "insunits" 4)  ;4 is mm

 

if not did a little rewrite of this lisp for less spam

;;----------------------------------------------------------------------------------------;;
;; Update all Block definions units in drawing 
(defun C:blkunits (/ u untlst)
  (vl-load-com)
  (setq untlst '(("0" "Unitless) ("1" "Inches") ("2" "Feet") ("3" "Miles") ("4" "Millimeters") ("5" "Cenimeters") ("6" "Meters") ("7" "Kilometers") ("8" "Microinches") ("9" "Mils") ("10" "Yards")
              ("11" "Angstroms" ("12" "Nanometers") ("13" "Microns") ("14" "Decimeters") ("15" "Dekameters") ("16" "Hectometers" ("17" "Gigameters") ("18" "Astronomical") ("19" "Light Years" ("20" "Parsecs")
  )
  (prompt "\nEnter Number to Change Block Units:")
  (prompt "\n0:Unitless, 1:Inches, 2:Feet, 3:Miles, 4:Millimeters, 5:Cenimeters")
  (prompt "\n6:Meters, 7:Kilometers, 8:Microinches, 9:Mils, 10:Yards")
  (prompt "\n11:Angstroms, 12:Nanometers, 13:Microns, 14:Decimeters, 15:Dekameters")
  (prompt "\n16:Hectometers ,17:Gigameters, 18:Astronomical, 19:Light Years, 20:Parsecs")
  (initget "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20")
  (setq u (getkword "\nEnter New Block Units <0>: "))
  (cond
    ((= u nil)
      (vlax-for blk (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
        (vlax-put-property blk "Units" 0)
      )
    )
    (t
      (vlax-for blk (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
        (vlax-put-property blk "Units" u)
      ) 
    )
  )
  (prompt (strcat "\nBlock Units Updated to " (cdr (assoc u untlst))))
  (princ)
)

*untested and written in notepad.

Edited by mhupp
  • Thanks 1
Link to comment
Share on other sites

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