Jump to content

Recommended Posts

Posted

Hey guys I wonder if someone could write me a quick lisp file to speed up my work load.

 

i need it to do the following.

 

1. explode all the blocks in the drawing till there are no more. (i already have this lisp by itself)

2. Select everything in the drawing and place all objects on bylayer (colour, line type etc)

3. select all objects on layer 0 and place on a new layer (layer0)

 

i have about 200 drawings i need to do this to so would be very great full to anyone who could help :)

Posted

A lisp for all three?

 

You mentioned you have a routine for item 1.

Setbylayer will take care of item 2.

That leaves us with item 3.

 

 (defun c:DoAll  (/ ln ss i e)
     (setq ln "YourLayer")
     (setq ss (ssget "_X" '((8 . "0"))))
     (repeat (setq i (sslength ss))
           (entmod (subst (cons 8 ln)
                          (assoc 8
                                 (setq e (entget (ssname ss
            (setq i (1- i))))))
                          e))
           )(princ)
     )

Posted

Thanks for this :)

 

could i some how combine all three to make one long lisp? here is the one i use for exploding blocks

(defun c:exall(/ bSet)
 (setvar "qaflags" 1)
 (while(setq bSet(ssget "_X" '((0 . "INSERT"))))
   (command "_.explode" bSet "")
   ); end while
 (repeat 3(command "-purge" "all" "" "n"))
 (setvar "qaflags" 0)
(princ)
); end of c:exall

Posted
Thanks for this :) could i some how combine all three to make one long lisp? here is the one i use for exploding blocks

 

I guess it can be done. Would this be limited to Model Space? or does it include objects at Layout tabs?

Posted
I guess it can be done. Would this be limited to Model Space? or does it include objects at Layout tabs?

Just model space

Posted
Last Q:

XREF?

No xrefs in the drawing at all.

Posted (edited)

Okay

 

A bunch of code cobbled together

 

(defun c:DoAll  (/ ln aDoc blknme bSetss i e)
     (vl-load-com)
     (setq ln "YourLayer")
     (setq aDoc (vla-get-activedocument (vlax-get-acad-object)))
     (while
           (setq a (tblnext "BLOCK" (null a)))
                (setq blknme (vla-item
                                   (vla-get-blocks aDoc)
                                   (cdr (assoc 2 a))))
                (vla-put-Explodable blknme :vlax-true)
                (vlax-for
                       itm
                          blknme
                      (vla-put-color itm acByLayer)
                      (vla-put-linetype itm "ByLayer")
                      (vla-put-lineweight itm -1)))
     (while
           (setq bSet (ssget "_X" '((0 . "INSERT") (410 . "MODEL"))))
                (command "_.explode" bSet)
                )
     (if (setq ss (ssget "_X" '((8 . "0"))))
           (repeat (setq i (sslength ss))
                 (entmod (subst (cons 8 ln)
                                (assoc 8
                                       (setq e    (entget
                                                        (ssname
                                                              ss
                                                              (setq i    (1- i))))))
                                e))
                 )
           )
     (repeat 4
           (vla-purgeall aDoc)
           )
     (princ)
     )

 

EDIT: Modified to account for UnExplodable Block entity

Edited by pBe
Posted
Okay

 

A bunch of code cobbled together

 

(defun c:DoAll  (/ ln aDoc blknme bSetss i e)
     (vl-load-com)
     (setq ln "YourLayer")
     (setq aDoc (vla-get-activedocument (vlax-get-acad-object)))
     (while
           (setq a (tblnext "BLOCK" (null a)))
                (setq blknme (vla-item
                                   (vla-get-blocks aDoc)
                                   (cdr (assoc 2 a))))
                (vla-put-Explodable blknme :vlax-true)
                (vlax-for
                       itm
                          blknme
                      (vla-put-color itm acByLayer)
                      (vla-put-linetype itm "ByLayer")
                      (vla-put-lineweight itm -1)))
     (while
           (setq bSet (ssget "_X" '((0 . "INSERT") (410 . "MODEL"))))
                (command "_.explode" bSet)
                )
     (if (setq ss (ssget "_X" '((8 . "0"))))
           (repeat (setq i (sslength ss))
                 (entmod (subst (cons 8 ln)
                                (assoc 8
                                       (setq e    (entget
                                                        (ssname
                                                              ss
                                                              (setq i    (1- i))))))
                                e))
                 )
           )
     (repeat 4
           (vla-purgeall aDoc)
           )
     (princ)
     )

 

EDIT: Modified to account for UnExplodable Block entity

 

Thank you :)

but it seems to get stuck on

 

Command: _.explode

Select object:

Command: _.explode

Select object:

Command: _.explode

Select object:

Command: _.explode

 

it just keeps repeating until i cancel , any ideas?

 

Thanks for helping me out.

Posted
Thank you :)

but it seems to get stuck on

 

Command: _.explode

Select object:

Command: _.explode

Select object:

Command: _.explode

Select object:

Command: _.explode

 

it just keeps repeating until i cancel , any ideas?

 

Thanks for helping me out.

 

Is not an error, that is a result of nested blocks found (ssget) inside the while loop. [copied from you c::exall routine]

 

Command: cmdecho

Enter new value for CMDECHO : 0

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