Jump to content

automate flattening all entities residing inside blocks


Guite

Recommended Posts

Following on from prior post this is the 1st part, but please note all the ZERO defuns have to be edited to reflect the "ent" as a single object rather than selection set. So using correct entmod to reset Z back to zero.

 

(defun get-block-entities ( blk / ent lst )
    (if  (setq ent (tblobjname "block" blk))
        (while (setq ent (entnext ent))
         (setq etyp (cdr (assoc 0 (entget ent))))
(cond
((= etyp "LWPLOYLINE")(pline0))
((= etyp "LINE")(line0))
((= etyp "CIRCLE")(Circ0)) ; add more
)
         )
    )
)
(get-block-entities "aaa")

Will see if can find time.

Link to comment
Share on other sites

  • 3 years later...
  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Guite

    7

  • Lee Mac

    5

  • SLW210

    4

  • GP_

    2

Top Posters In This Topic

On 2/17/2021 at 8:33 AM, BIGAL said:
text0 

Thank you for the code.
I tried but the z of the text is not good, not equal to 0.
Can you edit it again?
Thank you very much.

 

Z TEXT 30 NOT 0.dwg

 

Edited by itssme
Link to comment
Share on other sites

  • 3 weeks later...
On 11/15/2013 at 7:57 AM, Lee Mac said:

Here is a very simple program to flatten all objects in all blocks & layouts:

(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)

You can very easily run the above program on multiple drawings using a batch processing program, such as my Script Writer program.

Hi Lee,

I copied and loaded the above code, but it is not working on a file one of my users sent me. The file consists of LOTS of blocks nested within blocks. is there any sort of "nesting limit" within your code (I'm a lisp guy, but not real comfortable with the VL stuff :) )
Any light you can shed will be appreciated!

--Craig Black

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...