动态块丢失夹点wh
你好我创建了一些代码,使我能够缩放到指定的区域,然后按公式定义的量缩放所有块。问题是,当块被大量缩放时,它们有时会失去其动态夹点。我认为现在的情况是,它们在每个方向上的缩放量略有不同,这导致夹点消失。如果我选择块并使用“特性”窗口将其比例设置为已具有的相同值,则夹点将返回。
有人能建议对以下代码进行任何修复以防止这种奇怪的行为吗?我是AutoLisp的新手,如果有任何帮助,我们将不胜感激。
谢谢
(defun C:SZ()
(setq firstPoint (getpoint "\nSelect Area: ")) ; Select Area Of Interest
(setq secondPoint (getcorner "\nKeep Going: " firstPoint))
(command "._ZOOM" "W" firstPoint secondPoint) ; Zoom to AOI
(setq planDist (- (nth 1 secondPoint) (nth 1 firstPoint))) ; Get the height of the AOI
(if (> 0 planDist) ; If the height is negative, make it positive
(setq planDist (* -1 planDist))
) ; end if
(setq iconScale (+(* 0.000021 planDist) 0.2727)) ; Equation that scales the icons by the height of the AOI
(setq iconScaleStr (rtos iconScale 2 3)) ; Print some info to the screen
(setq planDistStr (rtos planDist 2 3))
(print (strcat "Icon Scale is: " iconScaleStr " times the original (2000mm) and Plan Height is: " planDistStr "mm"))
(QS) ; Call the quick scale tool
)
(defun QS()
(command "._UNDO" "Begin") ; Set Undo Group start
(setq count 0) ; Initialise count variable
(setq sSet (ssget "X" '((0 . "INSERT")))) ; Create a selection set from all blocks in the database
(setq sLeng (sslength sSet)) ; Get the length of the selection set
(while (< count sLeng) ; While the count is less than the number of objects:
(setq entName (ssname sSet count)) ; Set entname to the ssname of the object in the sset indexed by count
(setq oldScale (cdr (assoc 41 (entget entName)))) ; Get the scale from the current object
(setq insertPoint (cdr (assoc 10 (entget entName)))) ; Get the insert point
(command "._SCALE" entname "" insertPoint "REF" oldScale iconScale) ; Scale the block using ref, the old scale and the new scale
(setq count (+ 1 count)) ; Increment the count
) ; end while
(command "._UNDO" "End") ; Set Undo Group end
) 在块创建过程中解决此问题的一个方法是检查均匀缩放选项,或者如果块已经存在,则转到块的块编辑器空间,然后属性>设置“是”均匀缩放属性。 是的,它们都设置为均匀缩放。奇怪的是,块特性中的比例是正确的,并显示相同的X、Y和Z值(小数点后两位),但夹点消失了。当我使用entget检查块的属性时,看起来比例都是一样的!然后,当我在X比例中输入相同的值时(因为块被设置为均匀缩放,其他块被消隐),夹点再次出现。 你的代码似乎没问题。尝试检查精度设置。将其设置为12。如果您的设置有点低,如4,它可能会错过重要的小数位,如您的0.000021值只能读取为0.00002。 你可能喜欢这个程序,我只是在检查帖子,发现你的和这个命令类似。。。过来看。。
此例程将选定块(普通块、具有属性的块和动态块)更新为当前dimscale。它可以帮助您处理块和动态块
;;; BXY by David Harrington; Modified by Paulo Gil Soto (added annotation scale reset to 1:1)
;;; updates selected blocks x,y and z values to current Dimscale
;;;
;;; Main Program
;;;
(defun c:Bu (/ ss xs ys zs num x na lst editxyz_error olcmdecho old_err)
(defun editxyz_error (msg)
(if (or
(= msg "Function cancelled")
(/= msg "quit / exit abort")
)
(princ (strcat "Error: " msg))
)
(command ".UNDO" "E" "UNDO" "")
(setq *error*old_err
old_errnil
)
(setvar "CMDECHO" olcmdecho)
(princ)
)
(setq old_err *error*
olcmdecho (getvar "CMDECHO")
*error* editxyz_error
)
(setvar "CMDECHO" 0)
(setq dms (getvar "dimscale"))
(command ".UNDO" "BE")(prompt "\nSelect Blocks to match current dimscale: ")
(cond
((setq ss (ssget '((0 . "INSERT"))))
(command "-objectscale" ss "" "add" "1:1" "" "cannoscale" "1:1")
(setq num (sslength ss))
(setq x 0)
(repeat num
(setq na (ssname ss x))
(setq lst (entget na))
(setq lst (subst (cons 41 dms) (assoc 41 lst) lst))
(setq lst (subst (cons 42 dms) (assoc 42 lst) lst))
(setq lst (subst (cons 43 dms) (assoc 43 lst) lst))
(entmod lst)
(entupd na)
(setq x (+ x 1))
)
)
)
(command "attsync" "name" "*")
(command ".UNDO" "E")
(setq *error* old_err)
(setvar "CMDECHO" olcmdecho)
(princ)
)
我的动态块也有同样的问题。我只是手动缩放它,而不是用任何lisp。仍然不知道是否有修复。
页:
[1]