ALL FLATTEN

ALL FLATTEN

aliff_ahtenk
Enthusiast Enthusiast
1,277 Views
4 Replies
Message 1 of 5

ALL FLATTEN

aliff_ahtenk
Enthusiast
Enthusiast

Dear all,

I found this routine somewhere, since i dont know how this work, hopefully some one can provide a solution..

how do i change below routine, instead using move, it will be better using flatten command. i use this so far so good. but any 3d object, i will need to do it manually flatten.

 

(defun c:allflat ( / d )
   (vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object))))
       (if (= :vlax-false (vla-get-isxref b))
           (vlax-for o b
               (if (vlax-write-enabled-p o)
                   (foreach e '(1e99 -1e99)
                       (vlax-invoke o 'move '(0.0 0.0 0.0) (list 0.0 0.0 e))
                   )
               )
           )
       )
   )
   (vla-regen d acallviewports)
   (princ)
)
(vl-load-com) (princ)

 

In other word, It is flatten in nested block. flatten all item inside block, including block inside.

 

 

I do find others routine like "superflatten1.1.lsp" but that file wont do much, it stop when some block is missing or cannot be find, or found error. then if it error, some object will be missing.

0 Likes
Accepted solutions (1)
1,278 Views
4 Replies
Replies (4)
Message 2 of 5

paullimapa
Mentor
Mentor

assuming you have Express Tools loaded then you have the Flatten command and you can use this 3df.lsp to select and flatten Objects selected

 

 

 

; 3df uses ET to flatten selected objects
(defun c:3df (/ ss)
 (vl-load-com)
 ; chk if have Express Tools
 (if (member "acetutil.arx"(arx))
 ; select objects 
 (if(setq ss (ssget "_:L"))
  (progn
  ; place into previous selection set
  (command"_.select"ss"") 
  ; now flatten selection using Expess Tools Flatten 
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "Flatten _P \r\r")
  ) ; progn
 ) ; if
 (alert"Express Tools Not Loaded.")
 ) ; if
) ; defun

 

 

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 5

braudpat
Mentor
Mentor

Hello

Please find the Super Flatten routine vs 2.0C from Joe BURKE ...

Bye, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 4 of 5

aliff_ahtenk
Enthusiast
Enthusiast

I cannot accept the solution because, when i use the routine. the cad is force to close itself. if i set some area, it still have error.. i got automation error.

 

So i just use the previous move routine that i got somewhere.

 

Tq for your time.. Have a nice day.. 😉

0 Likes
Message 5 of 5

paullimapa
Mentor
Mentor
Accepted solution

I assume you don't have Express Tools or else see my reply #2


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes