Jump to content

Flatten lisp not working.


skipsophrenic

Recommended Posts

I've been using the lisp from THIS thread since i got it.

Up untill now have not had any problems, howevey when

i used it today, looking at everythin from the side, it has l

eft entities on 3 distinct elevations,

 

Any clue's on why this is happening now?

 

F.Y.I. this is a BIG drawing

Link to comment
Share on other sites

I may be way off the mark here, but have you tried the LISP with all your OSNAPs off?

 

from quickly glancing at the LISP on the hyperlinked threads, I notice that it doesn't turn OSNAPs off before moving the entities... :huh:

Link to comment
Share on other sites

This should cope with R14, and also with objects on locked layers:

 

(defun c:flat  (/ ss ssObj i j)
 (vl-load-com)
 (if (setq ss (ssget "X"
             (list (if    (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq ssObj (mapcar 'vlax-ename->vla-object
             (mapcar 'cadr (ssnamex ss))) i 0 j 0)
     (foreach Obj  ssObj
   (foreach n  '(1e99 -1e99)
     (if (vl-catch-all-error-p
       (vl-catch-all-apply
         '(lambda (x)
            (vla-move x (vlax-3d-point (list 0 0 0))
                  (vlax-3d-point (list 0 0 n))))
         (list Obj)))
       (setq i (1+ i)) (setq j (1+ j)))))
     (princ (strcat "\n" (rtos (/ j 2.0)) " Objects Flattened"
            (if (zerop i) "." (strcat ", " (rtos (/ i 2.0))
                          " were on a Locked Layer!")))))
   (princ "\n<!> No Objects Found <!>"))
 (princ))

Link to comment
Share on other sites

Will do - won't be untill afternoon tho - am at limb centre in mornin gettin me new leg (Hopefully)

 

Its not everyday you get to say that now is it... :P

Link to comment
Share on other sites

Alternatively, this will unlock all layers before performing the flatten:

 

(defun c:flat  (/ laylst ss ssObj j)
 (vl-load-com)
 (vlax-for lay
        (vla-get-layers
          (vla-get-ActiveDocument
            (vlax-get-acad-object)))
   (setq laylst (cons lay laylst)))
 (mapcar '(lambda (l) (vla-put-lock l :vlax-false)) laylst)
 (if (setq ss (ssget "X"
             (list (if    (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq ssObj (mapcar 'vlax-ename->vla-object
             (mapcar 'cadr (ssnamex ss))) j 0)
     (foreach Obj  ssObj
   (foreach n  '(1e99 -1e99)
     (if (vl-catch-all-error-p
       (vl-catch-all-apply
         '(lambda (x)
            (vla-move x (vlax-3d-point (list 0 0 0))
                  (vlax-3d-point (list 0 0 n))))
         (list Obj)))
       nil (setq j (1+ j)))))
     (princ (strcat "\n" (rtos (/ j 2.0)) " Objects Flattened.")))
   (princ "\n<!> No Objects Found <!>"))
 (princ))

Link to comment
Share on other sites

Cool - I'm deffinately gonna test these tommorraz - u don't realise how much these'll help m8.

Al I can say is thanks

Link to comment
Share on other sites

if Lees suggestion doesnt work try -exporttoautocad press enter for your first selection then give a new name for the second. It will create a new dwg file with the same info but flattened. Every once in a while we get drawings that just dont want to flatten, or flat or zero(change all z values to 0) but this seems to work even when nothing else will. hope it helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...