乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 44|回复: 5

[编程交流] 动态块丢失夹点wh

[复制链接]

2

主题

3

帖子

1

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 12:59:22 | 显示全部楼层 |阅读模式
你好
 
我创建了一些代码,使我能够缩放到指定的区域,然后按公式定义的量缩放所有块。问题是,当块被大量缩放时,它们有时会失去其动态夹点。我认为现在的情况是,它们在每个方向上的缩放量略有不同,这导致夹点消失。如果我选择块并使用“特性”窗口将其比例设置为已具有的相同值,则夹点将返回。
 
有人能建议对以下代码进行任何修复以防止这种奇怪的行为吗?我是AutoLisp的新手,如果有任何帮助,我们将不胜感激。
 
谢谢
 
  1. (defun C:SZ()
  2. (setq firstPoint (getpoint "\nSelect Area: "))            ; Select Area Of Interest   
  3. (setq secondPoint (getcorner "\nKeep Going: " firstPoint))
  4. (command "._ZOOM" "W" firstPoint secondPoint)                ; Zoom to AOI
  5. (setq planDist (- (nth 1 secondPoint) (nth 1 firstPoint)))        ; Get the height of the AOI
  6. (if (> 0 planDist)                            ; If the height is negative, make it positive
  7.    (setq planDist (* -1 planDist))
  8. ) ; end if
  9. (setq iconScale (+(* 0.000021 planDist) 0.2727))            ; Equation that scales the icons by the height of the AOI
  10. (setq iconScaleStr (rtos iconScale 2 3))                ; Print some info to the screen
  11. (setq planDistStr (rtos planDist 2 3))
  12. (print (strcat "Icon Scale is: " iconScaleStr " times the original (2000mm) and Plan Height is: " planDistStr "mm"))
  13. (QS)                                    ; Call the quick scale tool
  14. )
  15. (defun QS()
  16. (command "._UNDO" "Begin")                        ; Set Undo Group start
  17. (setq count 0)                            ; Initialise count variable
  18. (setq sSet (ssget "X" '((0 . "INSERT"))))                ; Create a selection set from all blocks in the database
  19. (setq sLeng (sslength sSet))                        ; Get the length of the selection set
  20. (while (< count sLeng)                        ; While the count is less than the number of objects:
  21.    (setq entName (ssname sSet count))                    ; Set entname to the ssname of the object in the sset indexed by count
  22.    
  23.    (setq oldScale (cdr (assoc 41 (entget entName))))            ; Get the scale from the current object
  24.    (setq insertPoint (cdr (assoc 10 (entget entName))))        ; Get the insert point
  25.    (command "._SCALE" entname "" insertPoint "REF" oldScale iconScale)    ; Scale the block using ref, the old scale and the new scale
  26.    (setq count (+ 1 count))                        ; Increment the count
  27. )    ; end while
  28. (command "._UNDO" "End")                        ; Set Undo Group end
  29. )   
回复

使用道具 举报

1

主题

316

帖子

311

银币

初来乍到

Rank: 1

铜币
29
发表于 2022-7-6 13:12:28 | 显示全部楼层
在块创建过程中解决此问题的一个方法是检查均匀缩放选项,或者如果块已经存在,则转到块的块编辑器空间,然后属性>设置“是”均匀缩放属性。
回复

使用道具 举报

2

主题

3

帖子

1

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 13:29:42 | 显示全部楼层
是的,它们都设置为均匀缩放。奇怪的是,块特性中的比例是正确的,并显示相同的X、Y和Z值(小数点后两位),但夹点消失了。当我使用entget检查块的属性时,看起来比例都是一样的!然后,当我在X比例中输入相同的值时(因为块被设置为均匀缩放,其他块被消隐),夹点再次出现。
回复

使用道具 举报

leo

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 13:37:21 | 显示全部楼层
你的代码似乎没问题。尝试检查精度设置。将其设置为12。如果您的设置有点低,如4,它可能会错过重要的小数位,如您的0.000021值只能读取为0.00002。
回复

使用道具 举报

29

主题

196

帖子

168

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
145
发表于 2022-7-6 13:59:09 | 显示全部楼层
你可能喜欢这个程序,我只是在检查帖子,发现你的和这个命令类似。。。过来看。。
 
此例程将选定块(普通块、具有属性的块和动态块)更新为当前dimscale。它可以帮助您处理块和动态块
 
  1. ;;; BXY by David Harrington; Modified by Paulo Gil Soto (added annotation scale reset to 1:1)
  2. ;;; updates selected blocks x,y and z values to current Dimscale
  3. ;;;
  4. ;;; Main Program
  5. ;;;
  6. (defun c:Bu (/ ss xs ys zs num x na lst editxyz_error olcmdecho old_err)
  7. (defun editxyz_error (msg)
  8. (if (or
  9.    (= msg "Function cancelled")
  10.    (/= msg "quit / exit abort")
  11.   )
  12.   (princ (strcat "Error: " msg))
  13. )
  14. (command ".UNDO" "E" "UNDO" "")
  15. (setq *error*  old_err
  16.     old_err  nil
  17. )
  18. (setvar "CMDECHO" olcmdecho)
  19. (princ)
  20. )
  21. (setq old_err *error*
  22.    olcmdecho (getvar "CMDECHO")
  23.    *error* editxyz_error
  24. )
  25. (setvar "CMDECHO" 0)
  26.        (setq dms (getvar "dimscale"))
  27. (command ".UNDO" "BE")  (prompt "\nSelect Blocks to match current dimscale: ")
  28. (cond
  29. ((setq ss (ssget '((0 . "INSERT"))))
  30.         (command "-objectscale" ss "" "add" "1:1" "" "cannoscale" "1:1")
  31.   (setq num (sslength ss))
  32.   (setq x 0)
  33.   (repeat num
  34.    (setq na (ssname ss x))
  35.    (setq lst (entget na))
  36.    (setq lst (subst (cons 41 dms) (assoc 41 lst) lst))
  37.    (setq lst (subst (cons 42 dms) (assoc 42 lst) lst))
  38.    (setq lst (subst (cons 43 dms) (assoc 43 lst) lst))
  39.    (entmod lst)
  40.    (entupd na)
  41.    (setq x (+ x 1))
  42.   )
  43. )
  44. )
  45. (command "attsync" "name" "*")
  46.        (command ".UNDO" "E")
  47. (setq *error* old_err)
  48. (setvar "CMDECHO" olcmdecho)
  49. (princ)
  50. )
回复

使用道具 举报

11

主题

117

帖子

133

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
52
发表于 2022-7-6 14:01:03 | 显示全部楼层
我的动态块也有同样的问题。我只是手动缩放它,而不是用任何lisp。仍然不知道是否有修复。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 06:32 , Processed in 0.622717 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表