Message 1 of 16
Fix bug in Flatten lisp when deal with text objects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi my friends,
i am using this lisp to flat all lines in the cad drawings but i found in some cad files it moves the text away from its place and that is not the desired act.
(defun flatall ( / a n ss)
; (vl-load-com)
; flatten objects inside blocks
(vlax-for b (vla-get-blocks (setq a (vla-get-activedocument (vlax-get-acad-object)))) ; select all blocks
(if (= :vlax-false (vla-get-isxref b)) ; ignore xref blocks
(vlax-for o b
(if (vlax-write-enabled-p o) ; chk if object can be moved
(foreach e '(1e99 -1e99)
(vlax-invoke o 'move '(0.0 0.0 0.0) (list 0.0 0.0 e)) ; flatten to 1e99 -1e99 which = 0 elevation
) ; foreach
) ; if
) ; vlax-for
) ; if
) ; vlax-for
; flatten objects outside blocks
(if(setq ss (ssget"_X")) ; select all objects
(progn
(setq ss (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss)))) ; cnvert to list of entities then to vl obj
(foreach i (list 1e99 -1e99)
(mapcar(function(lambda (x) (vla-move x (vlax-3d-point (list 0 0 0)) (vlax-3d-point (list 0 0 i))))) ss) ; flatten to 1e99 -1e99 which = 0 elevation
) ; foreach
) ; progn
) ; if ss
(vla-regen a acallviewports) ; regen
(princ)
) ; defun flatall
i will attach the drawings which all the texts moved away by so far from its places with no reason.
May anyone explain why that happened and how to modify the code to avoid this kind or error?