明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索

直线变矩形源码

[复制链接]
发表于 2019-10-7 08:39 | 显示全部楼层
在2010及以上版本不可用,提示:错误: no function definition: VLAX-CURVE-GETSTARTPOINT
发表于 2019-11-1 11:30 | 显示全部楼层
yubihai 发表于 2019-10-7 08:39
在2010及以上版本不可用,提示:错误: no function definition: VLAX-CURVE-GETSTARTPOINT

Put (vl-load-com) at top or bottom of lisp ^^
发表于 2019-11-2 00:25 | 显示全部楼层
本帖最后由 1028695446 于 2019-11-2 00:27 编辑
ketxu 发表于 2019-11-1 11:30
Put (vl-load-com) at top or bottom of lisp ^^

我把他改成动态的了
  1. (vl-load-com)
  2. (defun c:rex ( /  ss i e pts ob del-e a aa mouse elast)
  3.   (setq pac (getvar 'peditaccept))
  4.   (setvar 'peditaccept 1)
  5.   ;(if (not width) (setq width 1.00))
  6.   ;(setq width (cond
  7.   ;              ((getdist(strcat "\nEnter Width <"(rtos width 2 2)">: ")))
  8.   ;              (width)
  9.   ;            )
  10.   ;)
  11.   (setq del-e nil)
  12.   (if (and
  13.         (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE,LINE"))))
  14.         (setq pt0(getpoint "\n指定第一点:"))
  15.         ;(setq pt0 (cadr(car(cdddar(ssnamex ss 0)))))        
  16.       )
  17.     (progn
  18.       (setq elast(entlast))
  19.       (setq loop T)
  20.       (while loop
  21.         (setq mouse (grread T 12 0))
  22.         (setq a (car mouse) aa (cadr mouse))
  23.         (cond
  24.           ((= a 5)
  25.             (redraw)
  26.             ;(if (= elast(entlast))(princ)(entdel (entlast)))
  27.             (if del-e(entdel del-e)(princ))
  28.             (grdraw pt0 aa 1);画向量
  29.             (setq width(distance pt0 aa))
  30.             (if (> width 0.001)
  31.               (progn
  32.                 (setq i 0)
  33.                 (repeat (setq i (sslength ss))
  34.                   (setq e (ssname ss (Setq i (1- i))) sss (ssadd))
  35.                   (setq pts (mapcar
  36.                               '(lambda (y)
  37.                                  (list (vlax-curve-getStartPoint y)
  38.                                    (vlax-curve-getEndPoint y)
  39.                                  )
  40.                                )
  41.                               (mapcar 'car
  42.                                 (mapcar
  43.                                   '(lambda (x)
  44.                                      (setq ob (vlax-invoke
  45.                                                 (vlax-ename->vla-object e)
  46.                                                 'Offset
  47.                                                 x
  48.                                               )
  49.                                      )
  50.                                      (ssadd (entlast) sss)
  51.                                      ob
  52.                                    )
  53.                                   (list (setq h (* 0.5 width))
  54.                                     (- h)
  55.                                   )
  56.                                 )
  57.                               )
  58.                             )
  59.                   )
  60.                   (mapcar '(lambda (k l)
  61.                              (entmakex (list (cons 0 "LINE") (cons 10 k) (cons 11 l)))
  62.                              (ssadd (entlast) sss)
  63.                            )
  64.                     (car pts)(cadr pts)
  65.                   )
  66.                   (command "_.pedit" "_m" sss ""  "_j" 0.0 "")
  67.                   (setq del-e (entlast))
  68.                   ;(entdel e)
  69.                 )
  70.               )
  71.             )
  72.           )            ;;; 鼠标移动
  73.           ( (or (= 25 a) (= 11 a) ;右键
  74.               (and (= a 2) (= aa 13));回车
  75.               (and (= a 2) (= aa 32));或空格
  76.               (= a 3);鼠标左键
  77.             )
  78.             (setq loop nil)
  79.           )
  80.         )
  81.       )
  82.     )
  83.   )
  84.   (redraw)
  85.   (setvar 'peditaccept pac)
  86.   (princ)
  87. )

发表于 2021-3-16 23:42 | 显示全部楼层
错误: no function definition: VLAX-CURVE-GETSTARTPOINT
会出现这个错误
发表于 2021-3-17 16:38 | 显示全部楼层
谢谢! 1028695446 分享程序!!!!!!
发表于 2022-4-24 06:08 | 显示全部楼层
挺好的,这个我能 用到,谢谢
发表于 2022-4-26 16:33 | 显示全部楼层
要是能框选四条首尾连接的直线变成矩形就好了
发表于 2023-2-13 15:02 | 显示全部楼层
非常牛逼的代码,谢谢楼主分享啊。
发表于 2023-3-7 09:40 | 显示全部楼层
谢谢分享,支持
发表于 2023-3-9 17:58 | 显示全部楼层
1028695446 发表于 2019-11-2 00:25
我把他改成动态的了

加一个设置数值就更好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-5 06:18 , Processed in 0.227890 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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