模具论坛

 找回密码
 注册

扫一扫,微信登录

QQ登录

只需一步,快速开始

搜索
热搜: 冲压 注塑 求助
    回车查看更多
    论坛可能已存在您要发布的主题帖 关闭
      查看: 2982|回复: 4

      [活动] 有一个LSP标注文件,不知道里面的功能是怎么用的。

      [复制链接]
      发表于 2010-2-4 22:12:27 | 显示全部楼层 |阅读模式
      ;(defun c:cancel(/ ctrl)
      ;  (initget "y Y n N")
      ;  (setq ctrl (getkword "\nThis will undo EVERYTHING, OK ?(y/n):"))
      ;  (if (or (= ctrl "y") (= ctrl "Y"))
      ;    (command "undo" "back")
      ;  )
      ;)
      (defun c:cancel(/ ent er_ed er_layer er_type pt1 pt2 er_all
      old_cmdecho old_osmode old_blipmode)
        (setq old_cmdecho  (getvar "cmdecho")
      old_osmode   (getvar "osmode")
      old_blipmode (getvar "blipmode")
        )
        (setvar "cmdecho" 0)
        (setvar "osmode" 0)
        (setvar "blipmode" 0)
        (setq ent (car (entsel
      "\nPlease pick the DIMENSION or TEXT OBJECT to erase:")) )
        (if (/= ent nil) (progn
          (setq er_ed (entget ent))
          (setq er_layer (cdr (assoc '8 er_ed))
         er_type  (cdr (assoc '0 er_ed)) )
          (if (or (= er_type "DIMENSION") (= er_type "TEXT")) (progn
            (setq   pt1 (getpoint "\nPlease pick the FIRST corner:")
             pt2 (getpoint "\nPlease pick the OTHER corner:")
            )
            (setq er_all (ssget "wp" (list pt1 (list (car pt2) (cadr pt1))
         pt2 (list (car pt1) (cadr pt2)) pt1)
         (list (cons 0 er_type) (cons 8 er_layer)) ))
            (command "erase" er_all "")
            ) ;end progn
            (alert "\nError: Objects are not the DIMENSION or TEXT ! ")
          ) ;end if "TEXT"
          );end progn
          (alert "\nError: Objects are not the DIMENSION or TEXT ! ")
        );end if er_ed
        (setvar "osmode"   old_osmode)
        (setvar "blipmode" old_blipmode)
        (setvar "cmdecho"  old_cmdecho)
        (princ "\n\tOK")
        (princ)
      ) ;end defun c:cancel 980414
      里面所写的不只是这一点。我自己也不知道这个LSP的文件怎么用的,是一个以前乱打工别的设计给的,内行的人应该看的出是那家厂的东西。

      本帖子中包含更多资源

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

      x
       楼主| 发表于 2010-2-4 22:14:26 | 显示全部楼层
      ;;;--------------------------------------------------------------------;
      ;;;
      ;;;                     FOXDIM.LSP   Version 1.02
      ;;;
      ;;;   (C) Copyright 1997 by College of Mechanical & Automotive
      ;;;             Engineering(MAE), Hunan University.
      ;;;  
      ;;;   This  program  is  copyrighted  by  MAE. and  is  licensed  to
      ;;;   you  under  the  following  conditions. You may not distribute
      ;;;   or  publish the  source code of this program in any form.  You
      ;;;   may  incorporate this code in object form in derivative  works
      ;;;   provided  such  derivative  works  are  (i.) are  designed and
      ;;;   intended to work solely with MAE  products,  and (ii.) contain
      ;;;   MAE's  copyright  notice  "(C)   Copyright 1997 by  College of
      ;;;   Mechanical & Automotive Engineering."
      ;;;
      ;;;   MAE  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
      ;;;   MAE  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
      ;;;   CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  MAE DOES  
      ;;;   NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
      ;;;   UNINTERRUPTED OR ERROR FREE.
      ;;;   
      ;;;   by Lu Yuanzhi, Zuo Feiyan.
      ;;;   Nov. 28, 1997
      ;;;   Tel: 086-731-8822994, or 086-731-8822125
      ;;;
      ;;;--------------------------------------------------------------------;
      ;;;  DESCRIPTION
      ;;;
      ;;;  REVISION
      ;;;
      ;;;    At Foxconn(Shenzhen), on April 15, 1998.
      ;;;   
      ;;;--------------------------------------------------------------------;

      ;(defun c:cancel(/ ctrl)
      ;  (initget "y Y n N")
      ;  (setq ctrl (getkword "\nThis will undo EVERYTHING, OK ?(y/n):"))
      ;  (if (or (= ctrl "y") (= ctrl "Y"))
      ;    (command "undo" "back")
      ;  )
      ;)
      (defun c:cancel(/ ent er_ed er_layer er_type pt1 pt2 er_all
              old_cmdecho old_osmode old_blipmode)
        (setq old_cmdecho  (getvar "cmdecho")
              old_osmode   (getvar "osmode")
              old_blipmode (getvar "blipmode")
        )
        (setvar "cmdecho" 0)
        (setvar "osmode" 0)
        (setvar "blipmode" 0)
        (setq ent (car (entsel
              "\nPlease pick the DIMENSION or TEXT OBJECT to erase:")) )
        (if (/= ent nil) (progn
          (setq er_ed (entget ent))
          (setq er_layer (cdr (assoc '8 er_ed))
                er_type  (cdr (assoc '0 er_ed)) )
          (if (or (= er_type "DIMENSION") (= er_type "TEXT")) (progn
            (setq   pt1 (getpoint "\nPlease pick the FIRST corner:")
                    pt2 (getpoint "\nPlease pick the OTHER corner:")
            )
            (setq er_all (ssget "wp" (list pt1 (list (car pt2) (cadr pt1))
                pt2 (list (car pt1) (cadr pt2)) pt1)
                (list (cons 0 er_type) (cons 8 er_layer)) ))
            (command "erase" er_all "")
            ) ;end progn
            (alert "\nError: Objects are not the DIMENSION or TEXT ! ")
          ) ;end if "TEXT"
          );end progn
          (alert "\nError: Objects are not the DIMENSION or TEXT ! ")
        );end if er_ed
        (setvar "osmode"   old_osmode)
        (setvar "blipmode" old_blipmode)
        (setvar "cmdecho"  old_cmdecho)
        (princ "\n\tOK")
        (princ)
      ) ;end defun c:cancel 980414

      ;;**********************************************************************
      ;; The sub_procedure notes dimension of the circle in the certain
      ;; center area of the drawing.
      ;; "x0","y0" is the coordinate of circle to be noted .
      ;;      If switch is "tb_row", then note the dimensions of
      ;;      coordinate "y" in horizontal.
      ;;      If switch is "tb_col", then note the dimensions of
      ;;      coordinate "x" in vertical.
      ;;**********************************************************************

      (defun dim_in(x0 y0 r decimal_sum switch / list_dalt_x list_dalt_y
              x00 y00 j x y dim_x dim_y dalt_x dalt_y text_center_x
              text_center_y loop integer_sum)
      ;   (setq x00 (abs (- x0 (car pt_preference)))
      ;         y00 (abs (- y0 (cadr pt_preference))) ;luyz 1998
      ;   ) ;dimension text
         (setq x00 (- x0 (car pt_preference))
               y00 (- y0 (cadr pt_preference))
         )
         (setq j 0)
         (while (< j m_hole_sum)
              (setq x (car (nth j tb_m_hole))
                    y (last (nth j tb_m_hole))
              )
              (if (and (< (abs (- x x0)) 0.00001) (< (abs (- y y0)) 0.00001))
                  (setq decimal_sum 1)
              )
              (setq j (+ j 1))
         );end while if it is m_hole
         (setvar "dimdec" decimal_sum) ;lu 980414
         ;
         ; Try 7 times at different positions, if not confict with another
         ; circle & dimesion, Note the dimension at the position, if confict
         ; at all the position, note the dimension at default position,
         ; evenly the first position.
         ;
         (setq j    0
               loop T
         )
      (if (= switch "tb_row")  ;y dimension
        (progn
         ;
         ; calculate the textwidth of the dimension.
         ;
          (cond ((< (abs y00) 100)
                   (setq integer_sum 2)
                );end cond 1
                ((and (>= (abs y00) 100) (< (abs y00) 1000))
                   (setq integer_sum 3)
                );end cond 2
                ((>= (abs y00) 1000)
                   (setq integer_sum 4)
                );end cond 3
          );end cond
         (setq textwidth (* (+ integer_sum decimal_sum) textheight))
         ;
         ; select the blank position to note automaticly.
         ;
         (while (and (< j 11) loop)
            (setq list_dalt_x (car (nth j list_dalt_row))
                  list_dalt_y (last (nth j list_dalt_row))
            )
            (if (> list_dalt_x 0) ;left side
                (setq dim_x (+ (+ x0 r) list_dalt_x)
                      dim_y (+ y0 list_dalt_y)
                      ;
                      ; "dim_x" "dim_y" is the coordinate of the endpoint
                      ; of the dimension.
                      ;
                      text_center_x (+ dim_x (/ textwidth 2))
                      text_center_y dim_y
                      ;            
                      ; "text_center_x" "text_center_y" is the coordinate
                      ; of the centerpoint of the dimension's text.
                      ;
                )                                    
            ;else inner
                (setq dim_x           (+ (- x0 r) list_dalt_x)
                      dim_y           (+ y0 list_dalt_y)
                      text_center_x   (- dim_x (/ textwidth 2))
                      text_center_y   dim_y
                )
            );end if
            ;
            ; Determine if conflict with others.
            ;
            (crash_in text_center_x text_center_y "tb_row")
            (if (= crashed "n")
              (progn  
      ;         (command "dim1" "ord" (list x0 y0) "y" (list dim_x dim_y)
      ;                        (rtos y00 2 decimal_sum))
              (setq dim_x00 (- dim_x (car pt_preference))
                    dim_y00 (- dim_y (cadr pt_preference))    )
              (command "dim1" "ord" (list x00 y00) "y" (list dim_x00 dim_y00) ""
                       "move" "last" "" '(0 0 0) pt_preference)
                ;
                ; Record the coordinate of the center_pointer of
                ; the dimension's text.
                ;
              (setq tb_in_row (cons (list text_center_x text_center_y) tb_in_row))
              (setq loop nil)
              )
              ;
              ; else If all of the position is inavailable , then
              ; note the dimension at first position.
              ;
              (if (= j 10)  ;crashed !!
                (progn
      ;           (command "dim1" "ord" (list x0 y0) "y" (list dim_x dim_y)
      ;                       (rtos y00 2 decimal_sum))
               (setq dim_x00 (- dim_x (car pt_preference))
                     dim_y00 (- dim_y (cadr pt_preference))    )
               (command "dim1" "ord" (list x00 y00) "y" (list dim_x00 dim_y00) ""
                       "move" "last" "" '(0 0 0) pt_preference)
               (setq conflicted_sum (+ conflicted_sum 1))
               (setq tb_in_row (cons (list text_center_x text_center_y) tb_in_row))
                )
              );end if j=10
            );end if crashed
       楼主| 发表于 2010-2-4 22:16:56 | 显示全部楼层
      如果那位是写二次开发的LSP高手,或许对你也注注LSP文件有帮助。在你学习之于,也请了告诉我一下这个LSP的用法和好处。
      发表于 2012-3-14 21:49:34 | 显示全部楼层
      怎么我就没钱了呢。下不到
      发表于 2012-3-14 22:15:44 | 显示全部楼层
      回复 楼主 的帖子
      cance 回车,(框)选择标注尺寸或文字,删除。

      回复 沙发 的帖子
      cancel 回车,选择标注尺寸或文字,删除。
      (dim_in)  回车, 需要 dim1 的程序。
      您需要登录后才可以回帖 登录 | 注册

      本版积分规则

      关闭

      招聘信息 上一条 /5 下一条

      关闭

      求职信息 上一条 /5 下一条

      关闭

      技术求助 上一条 /5 下一条

      QQ|小黑屋|手机版|模具论坛 ( 浙ICP备15037217号 )

      GMT+8, 2025-7-27 18:18

      Powered by Discuz! X3.4

      © 2001-2013 Comsenz Inc.

      快速回复
      返回顶部
      返回列表
       
      客服电话:0577-61318188
      模具论坛交流群:
      模具论坛交流群
      工作时间:
      08:30-17:30