明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1621|回复: 3

[讨论] 这个自动画杆路的程序怎么加上标准文字方向识别

[复制链接]
发表于 2013-5-7 17:00:17 | 显示全部楼层 |阅读模式
本帖最后由 lxdz443 于 2013-5-7 17:02 编辑

需要把图一的标准文字改成图二
以下是代码:
(defun c:1()
        (setq cmdmode (getvar "cmdecho"))
        (setvar "cmdecho" 0)
        (if (= dir_lisp nil)
                (command "insert" "d:\\autolisp\\lispblock" '(quit)))
        (setq dir_lisp "d:\\autolisp\\")
        (dcl_auto)
        (prin1)
)

(defun dcl_auto()
        (setq dcl_id (load_dialog (strcat dir_lisp "dcl\\auto")))
        (new_dialog "auto" dcl_id)
        (def_auto)
        (action_tile "cyh_b00001" "(setq ddtype 1) (ok_auto)")
        (action_tile "cyh_b00002" "(setq ddtype 2) (ok_auto)")
        (action_tile "cyh_b00003" "(setq ddtype 3) (ok_auto)")
        (action_tile "cyh_b00004" "(setq ddtype 4) (ok_auto)")
        (action_tile "cyh_b00005" "(setq ddtype 5) (ok_auto)")
        (action_tile "cyh_b00010" "(setq ddtype 10) (ok_auto)")
        (action_tile "cyh_b00011" "(setq ddtype 11) (ok_auto)")
        (action_tile "cyh_b00012" "(setq ddtype 12) (ok_auto)")
        (action_tile "cyh_b00013" "(setq ddtype 13) (ok_auto)")
        (action_tile "cyh_b00014" "(setq ddtype 14) (ok_auto)")
        (action_tile "cyh_b00015" "(setq ddtype 15) (ok_auto)")
        (action_tile "cyh_b00016" "(setq ddtype 16) (ok_auto)")
        (action_tile "cyh_b00017" "(setq ddtype 17) (ok_auto)")
        (action_tile "cyh_b00018" "(setq ddtype 18) (ok_auto)")
        (action_tile "cyh_b00019" "(setq ddtype 19) (ok_auto)")
        (action_tile "cyh_b00020" "(setq ddtype 20) (ok_auto)")
        (action_tile "accept" "(ok_auto)")
        (setq dd (start_dialog))
        (if (= dd 1) (draw_auto))
)

(defun def_auto()
        (if (= bl_draw nil)
        (set_tile "bili_draw" "3000")
        (set_tile "bili_draw" (rtos bl_draw)))
        (if (= bl_auto nil)
        (set_tile "bili" "1")
        (set_tile "bili" (rtos bl_auto)))
        (if (= auto_txh nil)
        (set_tile "text_h" "2")
        (set_tile "text_h" (rtos auto_txh)))
        (if (= auto_txd nil)
        (set_tile "text_d" "1.2")
        (set_tile "text_d" (rtos auto_txd)))
        (setq sldkey_list '("cyh_b00001" "cyh_b00002" "cyh_b00003" "cyh_b00004" "cyh_b00005" "cyh_b00010" "cyh_b00011" "cyh_b00012" "cyh_b00013" "cyh_b00014" "cyh_b00015" "cyh_b00016" "cyh_b00017" "cyh_b00018" "cyh_b00019" "cyh_b00020"))
        (setq sld_list '("cyh_b00001" "cyh_b00002" "cyh_b00003" "cyh_b00004" "cyh_b00005" "cyh_b00010" "cyh_b00011" "cyh_b00012" "cyh_b00013" "cyh_b00014" "cyh_b00015" "cyh_b00016" "cyh_b00017" "cyh_b00018" "cyh_b00019" "cyh_b00020"))
        (mapcar 'show_sld sldkey_list sld_list)
        (setq ddtype 1)
        (mode_tile "cyh_b00002" 2)
)

(defun show_sld(key sld)
        (setq x (dimx_tile key))
        (setq y (dimy_tile key))
        (start_image key)
        (fill_image 0 0 x y -2)
        (slide_image 0 0 x y (strcat dir_lisp "sld\\" sld))
        (end_image)
)

(defun ok_auto()
        (setq bl_draw (atof (get_tile "bili_draw")))
        (setq bl_auto (atof (get_tile "bili")))
        (setq auto_txd (atof (get_tile "text_d")))
        (setq auto_txh (atof (get_tile "text_h")))
        (setq auto_text (get_tile "changdu"))
        (done_dialog 1)
)

(defun draw_auto()
        (setq pt0 (getpoint "/n 请输入插入点:"))
        (setq pt0 (list (car pt0) ( cadr pt0)))
        (setq r0 (getangle pt0 "/n 请输入旋转角度值:"))
        (setq myosmode (getvar "osmode"))  
        (setvar "osmode" 0)  
        (auto_detext)
        (setq i_t 0)
        (while (/= (nth i_t auto_ss) nil)
                (setq leth_auto (nth i_t auto_ss))
                 (draw_sample)
                  (setq i_t (1+ i_t))
          )
        (setvar "osmode" myosmode)
        (setvar "CMDECHO" cmdmode)
        (prin1)  
)


;分散长字符串
(defun auto_detext()
        (setq auto_textlen (strlen auto_text))
        (setq text_t "")
        (setq auto_ss nil)
        (while (> auto_textlen 0)
                  (setq txet_c (substr auto_text 1 1))
                  (if (/= txet_c "+")
                                (setq text_t (strcat text_t txet_c))
                                (if (/= text_t"")
                                (progn
                                        (setq auto_ss (cons text_t auto_ss))
                                        (setq text_t ""))))
                  (setq auto_text (substr auto_text 2 (- (strlen auto_text) 1)))
                  (if (and (< auto_textlen 2) (/= text_t""))
                        (progn
                           (setq auto_ss (cons text_t auto_ss))
                           (setq text_t "")))
        (setq auto_textlen (1- auto_textlen)))
        (setq auto_ss (reverse auto_ss))
)

;画单个组件
(defun draw_sample()
          (setq bl_draw1 (/ 1000 bl_draw))
        (setq pt1 (polar pt0 r0 (* bl_auto 1.5)))
        (setq pt2 (polar pt0 r0 (- (* (atof leth_auto) bl_draw1) (* bl_auto 1.5))))
        (setq pt1_1 (polar pt0 r0 (* bl_auto 2.1)))
        (setq pt2_1 (polar pt0 r0 (- (* (atof leth_auto) bl_draw1) (* bl_auto 2.1))))
        (setq pt3 (polar pt0 r0 (* (atof leth_auto) bl_draw1)))
        (setq pt4 (polar (polar pt0 r0 (/ (* (atof leth_auto) bl_draw1) 2)) (+ r0 (/ PI 2)) auto_txd))
        (cond ((= ddtype 1)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1 "w" 0.5 0.5 pt2 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a00001" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
              ((= ddtype 2)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1 "w" 0.5 0.5 pt2 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a00002" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
              ((= ddtype 3)
               (progn
                 (command "layer" "s" "0_rdcad" "")
                 (command "pline" pt1 "w" 0.25 0.25 pt2 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a00002" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
              ((= ddtype 4)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1 "w" 0.5 0.5 pt2 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a00003" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))
              ((= ddtype 5)
               (progn
                 (command "layer" "s" "0_rdcad" "")
                 (command "pline" pt1 "w" 0.25 0.25 pt2 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a00003" "x" bl_auto "y" bl_auto "r" 0 pt3 "")))  
              ((= ddtype 10)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1_1 "w" 0.5 0.5 pt2_1 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a10001" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
              ((= ddtype 11)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1_1 "w" 0.5 0.5 pt2_1 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a10011" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
             ((= ddtype 12)
               (progn
                 (command "layer" "s" "0_rdcad" "")
                 (command "pline" pt1_1 "w" 0.25 0.25 pt2_1 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a10011" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
              ((= ddtype 13)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt1_1 "w" 0.5 0.5 pt2_1 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a10004" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))
              ((= ddtype 14)
               (progn
                 (command "layer" "s" "0_rdcad" "")
                 (command "pline" pt1_1 "w" 0.25 0.25 pt2_1 "")
                 (command "layer" "s" "0" "")
                 (command "insert" "cyh_a10004" "x" bl_auto "y" bl_auto "r" (/ (* r0 180) PI) pt3 "")))            
              ((= ddtype 16)
               (progn
                 (command "layer" "s" "1_rdcad" "")
                 (command "pline" pt0 "w" 0.5 0.5 pt3 "")
                 (command "layer" "s" "0" "")))
              ((= ddtype 17)
               (progn
                 (command "layer" "s" "0_rdcad" "")
                 (command "pline" pt0 "w" 0.25 0.25 pt3 "")
                 (command "layer" "s" "0" "")))

              
        )         
                 (command "text" "s" "cyh_y00001" "j" "c" pt4 auto_txh (/ (* r0 180) PI) leth_auto)
          (setq pt0 pt3)
)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-5-7 20:19:58 | 显示全部楼层
上明经这么久,终于发现一个跟我同专业的
发表于 2013-5-7 20:51:49 | 显示全部楼层
仔细看了一下,这个程序好像不能连续插入杆路
至于方向的问题,在输入旋转角度时,从左到右的的选择2个点就对了
 楼主| 发表于 2013-6-3 07:06:47 | 显示全部楼层
麻烦可以给个程序吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-31 00:34 , Processed in 0.190324 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表