你好
我创建了一些代码,使我能够缩放到指定的区域,然后按公式定义的量缩放所有块。问题是,当块被大量缩放时,它们有时会失去其动态夹点。我认为现在的情况是,它们在每个方向上的缩放量略有不同,这导致夹点消失。如果我选择块并使用“特性”窗口将其比例设置为已具有的相同值,则夹点将返回。
有人能建议对以下代码进行任何修复以防止这种奇怪的行为吗?我是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
- )
|