2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AutoLISP 変換関数の使い方

Posted at

変換関数リファレンス(公式ヘルプ)

角度を表す文字列をラジアン単位の実数に変換

(angtof "30") 
;; -> 0.523599
(angtof "-30")
;; -> 5.75959
(angtof "360")
;; -> 0.0

ラジアン単位の角度の値を文字列に変換

(angtos (/ PI 2))
;; -> "90"
(angtos (/ PI 6))
;; -> "30"
(angtos (/ (* 5 PI) 4))
;; -> "225"

文字列の先頭文字を ASCII 文字コード(整数)に変換

(ascii "a")
;; -> 97
(ascii "bbb")
;; -> 98
(ascii "Acad")
;; -> 65
(ascii "あ")
;; -> 130
(ascii "漢字")
;; -> 138

文字列を実数に変換

(atof "0")
;; -> 0.0
(atof "1")
;; -> 1.0
(atof "-1")
;; -> -1.0
(atof "1.5")
;; -> 1.5

文字列を整数に変換

(atoi "0")
;; -> 0
(atoi "1")
;; -> 1
(atoi "-1")
;; -> -1
(atoi "1.5")
;; -> 1

ASCII 文字コードに対応する整数を 1 文字の文字列に変換

(chr 97)
;; -> "a"
(chr 32)
;; -> " " 半角スペース
(chr 63)
;; -> "?"

ある計測単位から別の計測単位に値を変換

※ acad.untファイルに存在する単位を変換

(cvunit 1 "minute" "second")
;; -> 60.0
(cvunit 1 "m" "ft")
;; -> 3.28084
(cvunit 1 "ft" "m")
;; -> 0.3048
(cvunit 1 "m" "inch")
;; -> 39.3701
(cvunit 1 "inch" "m")
;; -> 0.0254

実数(浮動小数点)を表す文字列を、実数値に変換

(distof "3.14")
;; -> 3.14
(distof "1/2")
;; -> 0.5
(distof "1/3")
;; -> 0.333333
(distof "2 1/4")
;; -> 2.25

整数を文字列に変換

(itoa 0)
;; -> "0"
(itoa 1)
;; -> "1"
(itoa -12)
;; -> "-12"
;; (itoa 1.0) -> error

数値を文字列に変換

(rtos 0)
;; -> "0"
(rtos 1.0)
;; -> "1"
(rtos 2.25)
;; -> "2.25"
(rtos 2.25 2 1)
;; -> "2.3"
(rtos 2.25 5)
;; -> "2 1/4"

ある座標系から別の座標系に、点(または変位)を変換

;; 現在のUCSの原点が 100,100,0 の場合
;; WCS -> UCS
(trans '(1.0 2.0 3.0) 0 1)
;; -> (-99.0 -982. 3.0)

;; UCS -> WCS
(trans '(1.0 2.0 3.0) 1 0)
;; -> (101.0 102. 3.0)
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?