CHANGE BLOCK UNITS - Free Lisp

CHANGE BLOCK UNITS - Free Lisp

gccdaemon
Collaborator Collaborator
4,838 Views
8 Replies
Message 1 of 9

CHANGE BLOCK UNITS - Free Lisp

gccdaemon
Collaborator
Collaborator

Wrote this quickie for anyone who has problems with their blocks getting scaled wrong. As with any of my code, it's free with no restrictions for anyone who wants to reproduce, modify, change, flip, smack, or rub it down.

 

This routine will change the block units for all blocks in the current drawing.

 

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
4,839 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Just what the doctor ordered!

 

Thanks Andrew!

0 Likes
Message 3 of 9

diepkhoi90
Contributor
Contributor

So simple but its actually work perfect

0 Likes
Message 4 of 9

11949034
Community Visitor
Community Visitor

Thanks very much!

0 Likes
Message 5 of 9

peter_pan_y_vino
Contributor
Contributor

Thank you. You can add the command 'textscr' to display the list of units on the command line before entering the units.

 

(defun C:BUNITS NIL (C:BLOCKUNITS))
(DEFUN C:BLOCKUNITS (/ UNIT)
(vl-load-com)
(PRINC "\nBlock Units:")
(PRINC "\n0. Unitless")
(PRINC "\n1. Inches")
(PRINC "\n2. Feet")
(PRINC "\n3. Miles")
(PRINC "\n4. Millimeters")
(PRINC "\n5. Centimeters")
(PRINC "\n6. Meters")
(PRINC "\n7. Kilometers")
(PRINC "\n8. Microinches")
(PRINC "\n9. Mils")
(PRINC "\n10. Yards")
(PRINC "\n11. Angstroms")
(PRINC "\n12. Nanometers")
(PRINC "\n13. Microns")
(PRINC "\n14. Decimeters")
(PRINC "\n15. Dekameters")
(PRINC "\n16. Hectometers")
(PRINC "\n17. Gigameters")
(PRINC "\n18. Astronomical Units")
(PRINC "\n19. Light Years")
(PRINC "\n20. Parsecs")

(TEXTSCR)
(initget "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20")
(setq UNIT (getkword "\nEnter New Block Units <0>: "))
(IF (= UNIT nil)
(vlax-for x (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
(vlax-put-property x "Units" 0)))
(IF (/= UNIT NIL)
(vlax-for x (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
(vlax-put-property x "Units" UNIT)))
(PRINC "\nBlock Units Changed")
(PRINC)
)
(princ "\n...Block Units: Type \"BLOCKUNITS\" or \"BUNITS\" to begin...")

Message 6 of 9

Sea-Haven
Mentor
Mentor

Maybe like this I am sure dont need all of them

 

screenshot365.png

 

; multi radio buttons.lsp Cadtutor\Downloads
(setq lst (list 
"Block Units:"
 "0. Unitless"
 "1. Inches"
 "2. Feet"
 "3. Miles"
 "4. Millimeters"
 "5. Centimeters"
 "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 Units"
 "19. Light Years"
 "20. Parsecs"
 ))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not but)(setq but 1))
(setq ans (ah:butts but "V"   lst))

 

 

 

0 Likes
Message 7 of 9

diagodose2009
Collaborator
Collaborator

Clipboard.jpgYou can select with double-radios

 

 

  (vl_load_com) (setq;|a10840|;
	 k1 (- 1)
	 k2 (- 2)
	 d1 (list "CHANGE Block.All UNITS - Free Lisp" 0 (list "01. Unitless" 1) (list "02. Inches" 1) (list "03. Feet" 1) (list "04. Miles" 1) (list "05. Millimeters" 1) (list "06. Centimeters" 1) (list "07. Meters" 1) (list "08. Kilometers" 1) (list "09. Microinches" 1) (list "10. Mils" 1) (list "11. Yards" 1) (list "12. Angstroms" 1) (list "13. Nanometers" 1) (list "14. Microns" 1) (list "15. Decimeters" 1) (list "16. Dekameters" 1) (list "17. Hectometers" 1) (list "18. Gigameters" 1) (list "19. Astronomical Units" 1) (list "20. Light Years" 1) (list "21. Parsecs" 1))) (setq;|a11412|;
	 d2 (list "Combine2" 0 (list "A1.DoSet-units for All" 1) (list "A2.Readm.txt" 1) (list "A3.Purge Block and wcMatch" 1) (list "A4.Duplicate Block" 1) (list "A5.EffectiveName" 1) (list "A6.Show OsNap" 1) (list "A7.Explorer.exe" 1) (list "A8.QuickSave.dwg" 1) (list "A9.Make Sphere" 1) (list "Tudor Gheorghe - Primavara simfonic" 0) (list "Tom and Jerry Heavenly Puss 1949 Part 1-2" 0) (list "Berry and Dolly: The Star House" 0) (list "A fost odata ca-n povesti" 0) (list "A fost ca niciodata." 0) (list "Din rude mari împaratesti," 0) (list "O prea frumoasa fata." 0))) (setq;|a11828|;
	 ask (list "Free Lisp" 1 (list 2 1) d1 d2)) (setq;|a11908|;
	 k1 (- 1)
	 k2 k1
	 b (dfn_dcl_radios ask)) (if (/= b nil) (progn  (setq;|a11992|;
	 k1 (nth 0 b)
	 k2 (nth 1 b)) (pp_codeblock k1 k2))) 

 

 

 

0 Likes
Message 8 of 9

javierautodeskid
Observer
Observer

Hi, excellent lisp. I'm just looking for this but selecting some blocks. It's possible? Thanks

0 Likes
Message 9 of 9

matthew_franksJFFQ9
Community Visitor
Community Visitor

Hi, i used this and it worked perfectly but i ran into another issue. whenever i try to insert a block that already exists in the drawing, it prompts me if i want to redefine the block and when i do it converts it back to the original units. any ideas on how to fix this beyond setting blocksredefinemode to 0? im still new to autocad so it may be obvious but i dont see it and this is a collaborative document so id rather not have to explain how to set up lisp and blockredefine to every person i give the file to. thanks in advance.

EDIT: i saw another thread of someone having a similar issue, im assuming it may be because the blocks im inserting are trying to pull reference from the original file where they were created in feet rather than inches. could this be part of the problem or am i missing a different factor?

0 Likes