Express tool does not work using AutoLISP

Express tool does not work using AutoLISP

Lucio_Faria6VXA6
Community Visitor Community Visitor
223 Views
4 Replies
Message 1 of 5

Express tool does not work using AutoLISP

Lucio_Faria6VXA6
Community Visitor
Community Visitor

Dear all.

 

I'm trying to use the BURST command in the AutoLISP but it says that the command is unknown. But I have the Express tools installed and I can use this command in AutoCAD. I have reinstalled and fixed the software, but still gets the same error message.

 

This is my AutoLISP code:

 

(defun c:BurstAll (/ ss ent obj)
(vl-load-com) ; Load Visual LISP functions

(setq ss (ssget "X" '((0 . "INSERT")))) ; Select all block references in the drawing

(if ss
(progn
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i)) ; Get entity name
(setq obj (vlax-ename->vla-object ent)) ; Convert entity name to VLA-object

; Check if the block has attributes (Burst only works on blocks with attributes)
; If you want to burst all blocks, even without attributes, you'd modify this.
; However, Burst's primary purpose is to explode blocks while retaining attribute values.
(if (vlax-property-available-p obj 'HasAttributes)
(progn
(if (eq :vlax-true (vla-get-hasattributes obj))
(progn
(command "BURST" ent "") ; Execute the Burst command on the block
(princ (strcat "\nBursting block: " (vla-get-effectivename obj))) ; Print block name to command line
)
(princ (strcat "\nSkipping block (no attributes): " (vla-get-effectivename obj)))
)
)
(princ (strcat "\nSkipping block (not an attribute block): " (vla-get-effectivename obj)))
)
(setq i (1+ i))
)
(princ "\nFinished bursting all eligible blocks.")
)
(princ "\nNo blocks found in the drawing.")
)
(princ) ; Suppress nil return
)

0 Likes
224 Views
4 Replies
Replies (4)
Message 2 of 5

Moshe-A
Mentor
Mentor

@Lucio_Faria6VXA6  hi,

 

That is absolutely true, (command) function can only run build-in\standard AutoCAD commands and BURST is AutoLISP command from ExpressTools

 

You can call though from your program as (c:burst) 

 

Moshe

 

0 Likes
Message 3 of 5

-didier-
Advisor
Advisor

Bonjour @Lucio_Faria6VXA6 

 

You must verify that express are loaded.
If you are not sure, type this line at the beginning of your program.

(acet-load-expresstools)

 

After you can use the command like that (c:burst)

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 4 of 5

DGCSCAD
Collaborator
Collaborator

To sum up all of the above in a LISP:

 

(defun c:burstall ( / ss)
(if (= (or (member "acetutil.arx" (arx)) (and (findfile "acetutil.arx") (arxload "acetutil.arx" nil))) T);check for acet
	(progn
		(setq ss (ssget "_X" '((0 . "INSERT")))) ;get all blocks
		(sssetfirst nil ss) ;highlight selection set ss
		(c:burst) ;apply the burst
	)
	(princ "\nNo Express Tools installed.")
)
)
AutoCad 2018 (full)
Win 11 Pro
Message 5 of 5

chan230984
Advocate
Advocate

(defun c:BurstAll (/ ss ent obj attribs i)
(vl-load-com)
(princ "\nStarting to burst all eligible blocks...")
(setq ss (ssget "X" '((0 . "INSERT"))))

(if ss
(progn
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))

; Add error handling for each block
(if (vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(if (and (vlax-property-available-p obj 'HasAttributes)
(eq :vlax-true (vla-get-hasattributes obj)))
(progn
; Get a list of attributes
(setq attribs (vlax-safearray->list (vlax-variant-value (vla-getattributes obj))))

; Loop through each attribute
(foreach attrib attribs
; Get attribute properties
(setq text_string (vla-get-textstring attrib))
(setq insert_point (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint attrib))))
(setq height (vla-get-height attrib))
(setq rotation (vla-get-rotation attrib))

; Add text at the same position and with the same properties as the attribute
(vla-addtext (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) text_string (vlax-3d-point insert_point) height)
(vla-put-rotation (vlax-get-acad-object) rotation)

; Delete the old attribute
(vla-delete attrib)
)

; Explode the block
(command "EXPLODE" ent "")

(princ (strcat "\nSuccessfully burst block: " (vla-get-effectivename obj)))
)
)
)
)
)
(princ (strcat "\nSkipping block due to error: " (vla-get-effectivename obj)))
)
(setq i (1+ i))
)
(princ "\nFinished bursting all eligible blocks.")
)
(princ "\nNo blocks found in the drawing.")
)
(princ)
)

0 Likes