明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3436|回复: 12

[提问] 请问e派工具箱的xy方向缩放工具的源程序是什么 ?要他的那种效果

[复制链接]
发表于 2014-6-23 17:06 | 显示全部楼层 |阅读模式
请问e派工具箱的xy方向缩放工具的源程序是什么 ?要他的那种效果



发表于 2014-6-26 09:21 | 显示全部楼层
  1. ;;; ************静态缩放缩放实体***********************
  2. (defun C:XSC(/ bp ss xscal yscal entL)

  3.   (defun errexit (s)
  4.     (princ "\nError:  ")
  5.     (princ s)
  6.     (restore)
  7.   )

  8.   (defun restore ()
  9.     (setvar "CMDECHO" (car oldvar))
  10.     (setq *error* olderr)
  11.     (princ)
  12.   )
  13.   
  14. (defun MAKEUNBLOCK (ss ip / tmp errexit mbx BLAYER)

  15.   (setq T (not nil))
  16.   (setq olderr  *error*
  17.         *error* errexit
  18.   )
  19.   (setq oldvar
  20.     (list
  21.       (getvar "CMDECHO")
  22.     )
  23.   )
  24.   (setvar "CMDECHO" 0)
  25.   (terpri)
  26.   (if BLAYER  
  27.     (command "._LAYER"
  28.       (if (tblsearch "LAYER" BLAYER) "_S" "_M")
  29.       BLAYER
  30.       ""
  31.     )
  32.   )
  33.   (if (and ip ss)
  34.     (progn
  35.       (entmake (list
  36.         (cons '0 "BLOCK")
  37.         (cons '2 "*U")
  38.         (cons '70 1)
  39.         (cons '10 ip)
  40.       ))
  41.       (setq cnt (sslength ss))
  42.       (while (>= (setq cnt (1- cnt)) 0)
  43.         (setq tmp (ssname ss cnt))
  44.         (entmake (setq el (entget tmp)))
  45.         (if (> (cdr (assoc 66 el)) 0)
  46.           (while
  47.             (/= "SEQEND"
  48.               (cdr
  49.                 (assoc 0
  50.                   (entmake (setq el (entget (entnext (cdr (assoc -1 el))))))
  51.                 )
  52.               )
  53.             )
  54.           )
  55.         )
  56.         (entdel tmp)
  57.       )
  58.       (setq tmp (entmake (list (cons '0 "ENDBLK"))))
  59.       (entmake (list
  60.         (cons '0 "INSERT")
  61.         (cons '2 tmp)
  62.         (cons '10 ip)
  63.       ))
  64.     )
  65.   )  
  66.   (restore)
  67. )

  68.   (setq ss (ssget))    ;;; 选择缩放实体
  69.   (if ss
  70.     (progn
  71.       (setvar "cmdecho" 0)
  72.       (setq bp (getpoint "缩放基准点 (<0,0,0>): "))
  73.       (if (not bp) (setq bp (list 0 0 0)))
  74.       (setq xscal (getreal "X向比例因子 <1>: "))
  75.       (if (not xscal) (setq xscal 1))
  76.       (setq yscal (getreal "Y向比例因子 <1>: "))
  77.       (if (not yscal) (setq yscal 1))
  78.       (MAKEUNBLOCK ss bp)
  79.       (setq entL (entget (entLast))
  80.     entL (subst (cons 41 xscal) (assoc 41 entL) entL)
  81.     entL (subst (cons 42 yscal) (assoc 42 entL) entL)
  82.       )
  83.       (entmod entL)
  84.       (command "_explode" "l" "")
  85.     )
  86.   )
  87.   (princ "X,Y不同比例缩放, 命令:XSC")
  88. )

回复 支持 1 反对 0

使用道具 举报

发表于 2020-9-11 11:49 | 显示全部楼层
支持支持,谢谢楼主的话题,谢谢各位大神的讨论
发表于 2014-6-23 20:15 来自手机 | 显示全部楼层
做成块,插入时不同比例,然后炸开

点评

他那个高级一些, 可以放在矩形框里,在里面点一下,或者是框选。  发表于 2014-6-25 13:41

评分

参与人数 1金钱 +20 收起 理由
bzhjl + 20 很给力!

查看全部评分

 楼主| 发表于 2014-6-25 15:57 | 显示全部楼层
他那个高级一些, 可以放在矩形框里,在里面点一下,或者是框选。
发表于 2014-6-25 20:44 来自手机 | 显示全部楼层
李青松 发表于 2014-6-25 15:57
他那个高级一些, 可以放在矩形框里,在里面点一下,或者是框选。

那你就用高飞鸟的矩阵
发表于 2014-6-26 09:20 | 显示全部楼层
  1. ;;; ************动态缩放缩放实体***********************
  2. (defun C:XYSC(/ bp ss xscal yscal entL)

  3.   (defun errexit (s)
  4.     (princ "\nError:  ")
  5.     (princ s)
  6.     (restore)
  7.   )

  8.   (defun restore ()
  9.     (setvar "CMDECHO" (car oldvar))
  10.     (setq *error* olderr)
  11.     (princ)
  12.   )
  13.   
  14. (defun MAKEUNBLOCK (ss ip / tmp errexit mbx BLAYER)

  15.   (setq T (not nil))
  16.   (setq olderr  *error*
  17.         *error* errexit
  18.   )
  19.   (setq oldvar
  20.     (list
  21.       (getvar "CMDECHO")
  22.     )
  23.   )
  24.   (setvar "CMDECHO" 0)
  25.   (terpri)
  26.   (if BLAYER  
  27.     (command "._LAYER"
  28.       (if (tblsearch "LAYER" BLAYER) "_S" "_M")
  29.       BLAYER
  30.       ""
  31.     )
  32.   )
  33.   (if (and ip ss)
  34.     (progn
  35.       (entmake (list
  36.         (cons '0 "BLOCK")
  37.         (cons '2 "*U")
  38.         (cons '70 1)
  39.         (cons '10 ip)
  40.       ))
  41.       (setq cnt (sslength ss))
  42.       (while (>= (setq cnt (1- cnt)) 0)
  43.         (setq tmp (ssname ss cnt))
  44.         (entmake (setq el (entget tmp)))
  45.         (if (> (cdr (assoc 66 el)) 0)
  46.           (while
  47.             (/= "SEQEND"
  48.               (cdr
  49.                 (assoc 0
  50.                   (entmake (setq el (entget (entnext (cdr (assoc -1 el))))))
  51.                 )
  52.               )
  53.             )
  54.           )
  55.         )
  56.         (entdel tmp)
  57.       )
  58.       (setq tmp (entmake (list (cons '0 "ENDBLK"))))
  59.       (entmake (list
  60.         (cons '0 "INSERT")
  61.         (cons '2 tmp)
  62.         (cons '10 ip)
  63.       ))
  64.     )
  65.   )  
  66.   (restore)
  67. )

  68.   (setq ss (ssget))    ;;; 选择缩放实体
  69.   (if ss
  70.     (progn
  71.       (setvar "cmdecho" 0)
  72.       (setq bp (getpoint "缩放基准点 (<0,0,0>): "))
  73.       (if (not bp) (setq bp (list 0 0 0)))
  74.       (setq px1 (getpoint bp "\n X端点:"))
  75.       (setq px2 (getpoint px1 "\n X端点移动到:"))
  76.       (setq xscal (/ (distance px2 bp) (distance px1 bp)))
  77.       (setq py1 (getpoint bp "\n Y端点:"))
  78.       (setq py2 (getpoint py1 "\n Y端点移动到:"))
  79.       (setq yscal (/ (distance py2 bp) (distance py1 bp)))
  80.       (MAKEUNBLOCK ss bp)
  81.       (setq entL (entget (entLast))
  82.     entL (subst (cons 41 xscal) (assoc 41 entL) entL)
  83.     entL (subst (cons 42 yscal) (assoc 42 entL) entL)
  84.       )
  85.       (entmod entL)
  86.       (command "_explode" "l" "")
  87.       (princ)
  88.     )
  89.   )
  90.   (princ "X,Y不同比例缩放, 命令:XYSC")
  91. )


 楼主| 发表于 2014-6-26 10:56 | 显示全部楼层
gcho 发表于 2014-6-26 09:21

程序很好,谢谢
发表于 2014-7-27 17:44 | 显示全部楼层
gcho 发表于 2014-6-26 09:21

这两程序都不实用,动态的要缩放的图原点和缩放尺寸矩行框原点重和才行,静态的要输入比例因子,提个小建议,动态的指定基点后用鼠标点下X Y的端点后,直接鼠标在要缩放的矩形框上找基点和X Y的端点即可,静态的参考原图的基点后可以直接输入具体尺寸更直观
发表于 2014-7-27 20:42 | 显示全部楼层

本帖子中包含更多资源

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

x
发表于 2014-7-30 17:06 | 显示全部楼层
学习一下,谢谢分享。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 12:24 , Processed in 0.320659 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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