Sponsored links

【AutoLISP ドリル】画層情報1 解答編

Sponsored links
ドリル
Sponsored links
Jagaimo
Jagaimo

画層名から画層情報を取得する練習問題 解答編です

Sponsored links

解答

(defun c:Test (/ LyInfo Tx)
		
     (setq LyInfo (tblsearch "layer" "0"))

	(setq Tx 
             (strcat "画層名: 0" 
	         "\n色 :"(itoa (cdr(assoc 62 LyInfo)))
	         "\n線種 : "(cdr(assoc 6 LyInfo))
             )
        )
		
	(alert Tx)

   (princ)
  )

Visual LISP を使った場合

(defun c:Test ( / ActiveDoc LyInfo Tx)
  
  (setq ActiveDoc (vla-get-activedocument 
                    (vlax-get-Acad-Object)
                  )
  )
  
    (setq LyInfo 
             (vla-item 
               (vla-get-layers ActiveDoc)
               "0"
             )
      )
		

     (setq Tx 
         (strcat "画層名: 0" 
	         "\n色 :"(itoa (vla-get-color LyInfo))
	         "\n線種 : "(vla-get-linetype LyInfo)
         )
      )
		
     (alert Tx)

(princ)
  )

関連記事

Comments