Jump to content

Lisp to burst all blocks 'till none left


Recommended Posts

Posted

I need a lisp that would first convert all unexplodable blocks within a file to explodable blocks, then burst all blocks, but keep bursting them if there are more blocks (nested ones) within the bursted blocks, then purge the file and delete all blocks and unused layers. I do not want any block to be left in my file. Thanks in advance.

Posted (edited)

Don't have express tools loaded right now. But this should do what you want. Burst blocks with attributes and explode blocks that don't. Until their aren't any blocks left.

If burst isn't loaded it would loop forever so added a if statement to check for burst command.

 

;;----------------------------------------------------------------------------;;
;; Explode all Blocks in drawing
(defun C:EB (/ SS)
  (vl-load-com)
  (if (vl-symbol-value 'C:Burst) ;test for burst command
    (while (setq SS (ssget "_X" '((0 . "INSERT") (410 . "Model"))))
      (foreach e (mapcar 'cadr (ssnamex SS))
        (if (assoc 66 (entget e)) 
          (vl-cmdf "_.Burst" e "")
          (progn
            (vla-explode (setq blk (vlax-ename->vla-object e))) 
            (vla-delete blk)
          )
        )
      )
    )
    (prompt "\nPlease Load Burst Command before running \"EB\" Command")
  )
  (princ)
)

 

 

Edited by mhupp
  • Like 1
Posted
On 2/12/2022 at 11:30 PM, mhupp said:

Don't have express tools loaded right now. But this should do what you want. Burst blocks with attributes and explode blocks that don't. Until their aren't any blocks left.

If burst isn't loaded it would loop forever so added a if statement to check for burst command.

 

;;----------------------------------------------------------------------------;;
;; Explode all Blocks in drawing
(defun C:EB (/ SS)
  (vl-load-com)
  (if (vl-symbol-value 'Burst) ;test for burst command
    (while (setq SS (ssget "_X" '((0 . "INSERT") (410 . "Model"))))
      (foreach e (mapcar 'cadr (ssnamex SS))
        (if (assoc 66 (entget e)) 
          (vl-cmdf "_.Burst" e "")
          (progn
            (vla-explode (setq blk (vlax-ename->vla-object e))) 
            (vla-delete blk)
          )
        )
      )
    )
    (prompt "\nPlease Load Burst Command before running \"EB\" Command")
  )
  (princ)
)

 

 

 

I am trying to use this lisp but it gives the warning that I should first load burst command before running it, but express tool burst command has already been activated for quite a while now, so I could not figure out what to do.

Posted (edited)

Sorry forgot the "C:" in the if statement should be working now.

--Edit

 

At my work computer now and might have to delete all attributes after burst command. seems to leaved the attribute in BricsCAD let me know if this is the same in AutoCAD.

Edited by mhupp
  • Like 1
  • 2 weeks later...
Posted
On 14/02/2022 at 14:17, Lee Mac said:

To offer an alternative, consider the NBURST command defined by my Burst Upgraded application.

Hello Lee Mac, I am wondering if you can be able in Lisp programming to create a field for any other basic properties other than Areas, for instance Moment of Inertia? Now I download a program in Lisp language that contain the formulation to paste the Moment of inertia into the screen of AutoCAD however each time I want to modify the size of the object I need to recalculate the same property with the same command LISP (as it happens when area is modified when is constructed with field text). Is it this posible to perform in LISP AutoCAD? thank you so much!

Posted (edited)
5 hours ago, wil3000 said:

Hello Lee Mac, I am wondering if you can be able in Lisp programming to create a field for any other basic properties other than Areas, for instance Moment of Inertia? Now I download a program in Lisp language that contain the formulation to paste the Moment of inertia into the screen of AutoCAD however each time I want to modify the size of the object I need to recalculate the same property with the same command LISP (as it happens when area is modified when is constructed with field text). Is it this posible to perform in LISP AutoCAD? thank you so much!

 

Yes - although not listed by the dialog for the standard AutoCAD FIELD command, a field expression can actually reference any ActiveX property. As such, you can download & load my Quick Field utility and then define a custom command such as the following to create a field referencing the Moment of Inertia for a selected 3D Solid:

 

(defun c:test ( ) (LM:QuickField "MomentOfInertia" "" 2))

 

Edited by Lee Mac
  • Like 1
  • 3 weeks later...
Posted (edited)

 

-

Edited by wil3000
Posted (edited)
On 22/02/2022 at 23:02, Lee Mac said:

 

Yes - although not listed by the dialog for the standard AutoCAD FIELD command, a field expression can actually reference any ActiveX property. As such, you can download & load my Quick Field utility and then define a custom command such as the following to create a field referencing the Moment of Inertia for a selected 3D Solid:

 

(defun c:test ( ) (LM:QuickField "MomentOfInertia" "" 2))

 

Thank you so much Lee Mac, it is pretty awesome, however what I mean to say is not using any selected 3D solid in order to change the polygon of surface on the autocad screen when modified multiple times by the user. You have a best one, that is known as areafield, and it is pretty awesome because whenever I want to, I can change the area without having to explode or burst the 3D solid in that way I can save time when directly modifying the polygon which actually is not a region nor a 3D solid. Or I think that it would be much better to find a way (lisp) to modified a 3D solid without exploding it, Please help me. Thank you so much in advanced.

 

Edited by wil3000
Posted
On 22/02/2022 at 23:02, Lee Mac said:

 

Yes - although not listed by the dialog for the standard AutoCAD FIELD command, a field expression can actually reference any ActiveX property. As such, you can download & load my Quick Field utility and then define a custom command such as the following to create a field referencing the Moment of Inertia for a selected 3D Solid:

 

(defun c:test ( ) (LM:QuickField "MomentOfInertia" "" 2))

 

I am not pretty sure who made this code, however someone helped me to modify it to get the Ixx on the modelspace screen. 

 

(defun c:mp ( / error cmd m o s )
   (defun error ( msg )
       (if cmd (setvar 'CMDECHO cmd))
       (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
           (princ (strcat "\nError: " msg)))
       (princ))

(setq cmd (getvar 'CMDECHO))
(setvar 'CMDECHO 0)

    (if (setq s (ssget "_+.:E:S" '((000 . "REGION,3DSOLID"))))
         (progn
              (setq o (vlax-ename->vla-object (ssname s 0)))
               (command "_.ucs" "_origin" (vlax-get o 'centroid))


             (setq m (vlax-get o 'momentofinertia))
              (command "_.ucs" "_p")
                                (setq inercia (mapcar '(lambda ( x ) (/ x 10000)) m))))
                                (setq pt0 (getpoint "\NPunto en pantalla para rotular texto : "))
                                (setq X (rtos (car inercia)  2 2))
                                (setq Y (rtos (cadr inercia)))
                                (command "_text" pt0 "15" "0" (strcat "Ixx:=" x "cm4")) 

;;"," y))
                                (princ inercia)

  (setvar 'CMDECHO cmd)
     (princ)      
   )
  (vl-load-com) (princ)

  • 3 weeks later...
Posted
On 22/02/2022 at 23:02, Lee Mac said:

 

Yes - although not listed by the dialog for the standard AutoCAD FIELD command, a field expression can actually reference any ActiveX property. As such, you can download & load my Quick Field utility and then define a custom command such as the following to create a field referencing the Moment of Inertia for a selected 3D Solid:

 

(defun c:test ( ) (LM:QuickField "MomentOfInertia" "" 2))

 

hello LeeMac, please help me!

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