- UID
- 797690
- 积分
- 104
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2020-3-22
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2020-8-21 10:11:02
|
显示全部楼层
本帖最后由 啊龍 于 2020-8-22 18:51 编辑
(vl-load-com)
(defun c:ar1 ()
(setvar "cmdecho" 0)
(command "osmode" 0)
(command "UNDO" "BE")
(command "-layer" "s" "DIM" " ")
(command ".textstyle" "微軟正黑")
(setq x_data (prompt "點選<x>軸標註:"))
(setq x1_data (entget (car (entsel))))
(setq x1 (cdr ( assoc 42 x1_data)))
(setq y_data (prompt "點選<y>軸標註:"))
(setq y2_data (entget (car (entsel))))
(setq y2 (cdr (assoc 42 y2_data)))
(command "'CURSORSIZE" 100)
(setq pt1 (getpoint "\框選需計算雷射長度的物件:"))
(setq pt2 (getpoint))
;;;*********************************************** **
( *ss*)
(setq :t_data: (getint "\n材質[SS41(1) SUS(2) SPGC(3) SECC(4) AL(5)]<2>:"))
(if *T1*
(setq :T1: (getreal (strcat "\n輸入厚度:<" (rtos *T1* 2 2) ">:")))
(setq :T1: (getreal "\n輸入厚度:")))
( if
(null :T1:)
(setq :T1: *T1*)(setq *T1* :T1:))
(if *pcs1*
(setq :pcs1: (getint (strcat "\n輸入數量:<" (rtos *pcs1* 2 2) ">:")))
(setq :pcs1: (getint "\n輸入數量:")))
(if
(null :pcs1:)
(setq :pcs1: *pcs1*)(setq * pcs1* :pcs1:))
(if *a1*
(setq :a1: (getreal (strcat "\n輸入扣料系數:<" (rtos (abs *a1*) 2 2) ">:")))
( setq :a1: (getreal "\n輸入扣料系數:")))
(if
(null :a1:)
(setq :a1: *a1*)(setq *a1* :a1:))
(*:t_data: *)
(if *v1*
(setq :v1: (getint (strcat "\n輸入下模數:<" (rtos *v1* 2 2) ">:")))
(setq :v1: (getint "\n輸入下模數:")))
(if
(null :v1:)
(setq :v1: *v1*)(setq *v1* :v1:))
(setq kg_data (*(*(* x1 y2) *T1* ) t2_data ))
(setq KG_A ( getpoint "\n圖號、材質、數量等...的文字位置:"))
(setq kgx_data (car KG_A))
(setq kgy_data (cadr KG_A))
(setq text_size (getvar "textsize"))
(setq KG_A1 (* text_size 1.35))
(setq KG_A2 (* text_size 3.25))
(setq tx1 (+ kgx_data KG_A2))
(setq ty (+ kgy_data KG_A1))
(setq ty1 (+ kgy_data (* KG_A1 2)))
(setq ty2 ( + kgy_data (* KG_A1 3)))
(setq ty3 (+ kgy_data (* KG_A1 4)))
(setq kgxx1_data (+ kgx_data (* KG_A2 0.9)))
(setq kgxx2_data (+ kgx_data (* KG_A2 3.25)))
(setq tyy1 (list kgx_data ty))
(setq tyy2 (list kgx_data ty1))
(setq tyy3 (list kgx_data ty2))
(setq tyy4 (list kgx_data ty3))
(setq txx1 (list kgxx1_data ty))
(setq txx2 (list kgxx1_data ty1))
(setq txx3 (list kgxx1_data ty2))
(setq txx4 (list kgxx1_data ty3))
(setq taa1 (list kgxx2_data kgy_data))
(setq taa2 (list kgxx2_data ty))
(setq taa3 (list kgxx2_data ty1))
(setq ta1_data (strcat (rtos :T1: 2 2) "T"))
( setq pcsa_data (strcat (rtos *pcs1* 2 2) " pcs"))
(setq LA (strcat "切割長度:" (rtos sumlen 2 2) "mm,孔數:" (rtos nn 2 0)))
;; ;(setq KG (strcat "重量:" (rtos kg_data 2 2) "kg"))
(setq vw1 (strcat "V=" (rtos *v1* 2 2) ",0.5W=" (rtos (abs *a1 *) 2 2) "(" (rtos (abs (* *a1* 2)) 2 2)")"))
(setq ss2 (strcat "板材尺寸:" (rtos x1 2 2) "mmx" (rtos y2 2 2) "mm"))
;;;==========我想要以下文字能動態化==========
;;;能跟著十字遊標移動就好;;;或是變為屬性都可以
(command "-text" KG_A "" 0 vw1)
(command "-text" tyy1 "" 0 "數量:")
(command " -text" tyy2 "" 0 "厚度:")
(command "-text" tyy3 "" 0 "材質:")
(command "-text" tyy4 "" 0 "圖名:")
(command "-text" txx1 "" 0 pcsa_data)
(command "-text" txx2 "" 0 TA1_DATA)
(command "-text" txx3 "" 0 t_data)
(command "-text" txx4 "" 0 "-----")
;;; (command "-text"taa1 "" 0 KG)
(command "-text" taa2 "" 0 LA)
(command "-text" taa3 "" 0 ss2)
;;;==========文字能動態化結束=== =======
(command "osmode" 47) (command "'CURSORSIZE" 7)
(setvar "cmdecho" 1)
(princ)
)
(princ)
;;;****************************** ***************** **
(defun *ss*(/ ss)
(vl-load-com)
(setq c 0)
(setq SUMLEN 0)
(setq N 0)
(setq i C)
(setq ss c)
(setq ss (ssget "w" pt1 pt2 '((8 . "0")
(0 . "REGION,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC")
(-4 . "<NOT")
(- 4 . "<OR")
(62 . 1)
(62 . 4)
(-4 . "OR>")
(-4 . "NOT>")
)))
(repeat
(sslength SS)
(setq CURVE (vlax- ename->vla-object (ssname SS N) ) )
;註:vlax-ename->vla-object將AutoLISP類型的對象名轉換為VLA對象
(if
(/= (vla-get-objectname CURVE) "AcDbRegion" )
;註:vla-get-objectname 取得對象的AUTOCAD類名稱
(setq TLEN (vlax-curve-getdistatparam CURVE
;註:vlax-curve-getdistatparam返回曲線從開始到指定參數的曲線段的長度
(vlax-curve-getendparam CURVE)
;註:vlax-curve-getendparam返回曲線端點的參數
) )
(setq TLEN (vla-get-perimeter CURVE) )
;註:vla-get-perimeter獲取內部和外部區域的總循環長度。
)
(setq SUMLEN (+ SUMLEN TLEN) )
(setq N (1+ N) )
)
(setq ss2 c)
(setq ss2 (ssget "w" pt1 pt2 '((8 . "0")
(0 . "line, arc,circle,LWPOLYLINE,ellipse,spline")
(-4 . "<or")
(62 . 256)
(-4 . "or>"
)
;;;********************************************** * **
|
|