วันเสาร์ที่ 6 กุมภาพันธ์ พ.ศ. 2553

AutoCAD Tips: Visual LISP Tips คำนวณค่าแปลงหน่วยด้วยนิพจน์ LISP

คำนวณค่าแปลงหน่วยด้วยนิพจน์ LISP

ถามว่า 12 ไมล์เท่ากับกี่กิโลเมตร???
ถามว่า 15 ปอนด์เท่ากับกี่กิโลกรัม???

คำถามเหล่านี้ ถ้าถูกถามในสมัยที่แต่ละท่านยังอยู่ในวัยศึกษา
อย่างมัธยม อย่างตอนเรียนสายวิชาชีพ จนกระทั่งในรั้วมหาวิทยาลัย

ก็คงอมยิ้ม กับคำถามง่ายๆ เหล่านี้
และตอบกลับไปได้อย่างรวดเร็ว

แต่ถ้าก้าวสู่ชีวิตที่ละเลยเรื่องนี้ไปแสนนานจะตอบกลับทันทีได้หรือเปล่า?

บางท่านอาจค้นในลิ้นชักโต๊ะทำงานสักพัก
พอเจอตารางค่าแปลงหน่วย ก็กดเครื่องคิดเลขอีกเล็กน้อย เพื่อตอบคำถาม

แต่ถ้าระหว่างนั้น เราอยู่ที่หน้าจอ AutoCAD อยู่แล้ว
ก็เพียงแต่ใช้ฟังก์ชัน CVUNIT ที่มีคนกล่าวถึงน้อยมากๆ ช่วยคำนวณได้เลย

รูปแบบคือ (CVUNIT ค่าตัวเลข "หน่วยเดิม" "หน่วยใหม่")

เช่น
ข้อแรก พิมพ์ (CVUNIT 12 "mile" "kilometer") แล้วกด Enter

Command: (CVUNIT 12 "mile" "kilometer")
19.3121

ข้อสอง พิมพ์ (CVUNIT 15 "pound" "kilogram") แล้วกด Enter

Command: (CVUNIT 15 "pound" "kilogram")
6.80389

แล้วเราจะทราบหน่วยวัดที่มีให้ใช้ว่ามีอะไรบ้างได้อย่างไร
คำตอบคืออยู่ในไฟล์ acad.unt

วิธีที่จะเปิดไฟล์นี้มาอ่านได้อย่างรวดเร็วที่สุดก็คือพิมพ์
(command "notepad" (findfile "acad.unt")) แล้วกด Enter

ซึ่งเป็นดังรายการถัดไปนี้ คัดลอกมาเฉพาะส่วนชื่อหน่วยและคำ Prefix

*meter(s),metre(s),m
*kilogram(s),kg
*second(s),sec
*ampere(s),amp(s)
*kelvin,k
*candela,cd

; Derived SI units
*celsius,centigrade,c
*rankine
*fahrenheit
*gram(s),gm,g
*newton(s),n
*pascal,pa
*joule(s)

; Exponent synonyms
*square,sq
*cubic,cu

; Units of time
*centur(y.ies)
*day(s)
*decade(s)
*fortnight(s)
*hour(s),hr
*milleni(um.a)
*minute(s),min
*sidereal_year(s)
*tropical_year(s)
*week(s),wk
*year(s),yr

; Units of length
*Angstrom(s)
*astronomical_unit(s),au
*bolt(s)
*cable(s) ; U.S. cable length
*caliber
*centimeter(s),centimetre(s),cm(s)
*chain(s) ; Gunther's chain length
*cubit(s)
*decimeter(s),decimetre(s),dm
*dekameter(s),dekametre(s),dam
*fathom(s),fath
*f(oot.eet),ft,'
*furlong(s),fur
*gigameter(s),gigametre(s)
*hand(s)
*hectometer(s),hectometre(s),hm
*inch(es),in(s),"
*kilometer(s),kilometre(s),km
*league_nautical
*league_statute
*light_year(s)
*link(s) ; Gunther's link length
*microinch(es)
*micron(s)
*mil(s)
*mile_nautical,inm ; International Nautical Mile
*mile_statute,mile(s),mi
*millimeter(s),millimetre(s),mm(s)
*millimicron(s),nanometer(s),nanometre(s),nm(s)
*pace(s)
*palm(s)
*parsec(s)
*perch(es)
*pica(s)
*point(s)
*rod(s),pole(s)
*rope(s)
*skein(s)
*span(s)
*survey_f(oot.eet)
*yard(s),yd

; Units of area
*acre(s)
*are(s)
*barn(s)
*centare(s)
*hectare(s)
*rood(s)
*section(s)
*sq(uare)_centimeter(s),sq(uare)_centimetre(s),sq(uare)_cm(s)
*sq(uare)_f(oot.eet),sq(uare)_ft
*sq(uare)_inch(es),sq(uare)_in(s)
*sq(uare)_kilometer(s),sq(uare)_kilometre(s),sq(uare)_km
*sq(uare)_meter(s),sq(uare)_metre(s),sq(uare)_m
*sq(uare)_millimeter(s),sq(uare)_millimetre(s),sq(uare)_mm(s)
*sq(uare)_yard(s),sq(uare)_yd(s)
*township(s)

; Units of volume
*barrel(s),bbl ; International Petroleum barrel
*board_f(oot.eet),fbm
*bushel(s),bu ; U.S. dry bushel
*centiliter(s),cl
*cord(s)
*cc
*cu(bic)_centimeter(s),cu(bic)_centimetre(s),cu(bic)_cm(s)
*cu(bic)_f(oot.eet),cu(bic)_ft
*cu(bic)_inch(es),cu(bic)_in(s)
*cu(bic)_kilometer(s),cu(bic)_kilometre(s),cu(bic)_km
*cu(bic)_meter(s),cu(bic)_metre(s),cu(bic)_m
*cu(bic)_millimeter(s),cu(bic)_millimetre(s),cu(bic)_mm(s)
*cu(bic)_yard(s),cu(bic)_yd(s)
*decistere(s)
*dekaliter(s),dal
*dekastere(s)
*dram(s) ; U.S. fluid dram
*dry_pint(s)
*dry_quart(s)
*firkin(s)
*gallon(s),gal ; U.S. fluid gallon
*gill(s)
*hectoliter(s)
*hogshead(s),hhd
*kilderkin(s)
*kiloliter(s)
*liter(s)
*milliliter(s),ml
*minim(s)
*fluid_ounce(s)
*peck(s)
*pint(s),fluid_pint(s)
*pottle(s)
*puncheon(s)
*quart(s),qt,fluid_quart(s)
*register_ton(s)
*seam(s)
*stere(s)
*tun(s)

; Units of mass
*dalton(s)
*dyne(s)
*grain(s)
*hundredweight(s),cwt
*long_ton(s)
*ounce_weight,ounce(s),oz
*ounce_troy
*pennyweight(s),dwt,pwt
*poundal(s)
*pound(s),lb
*scruple(s)
*slug(s)
*stone
*ton(s)
*tonn(e.es)

; Units of frequency
*hertz,hz

; Electromagnetic units
*coulomb(s)
*farad(s)
*henr(y.ies)
*ohm(s)
*siemens
*tesla(s)
*volt(s),v
*watt(s),w
*weber(s)

2 ความคิดเห็น:

  1. ใช้CAD Versionไหนครับ ของผม 2008 เปิกไม่ได้ครับ ขอบคุณมากครับ

    ตอบลบ
  2. ใช้กับ AutoCAD Release 14 ก็ได้ครับ
    จนถึง AutoCAD 2011 ทดสอบแล้วครับ

    ลองดูอีกครั้งนะครับ

    (ต้องขอโทษด้วยที่ตอบช้า)

    ตอบลบ