Jump to content

Set all blocks in a drawing to be unexplodable?


Recommended Posts

Posted

I've written routines before that use ssget and chprop to alter drawings with massive amounts of objects before, but not sure I can use this same style to set all blocks in a drawing to be unexplodable.

 

Is there a way I could write a simple script in AutoLISP that would set "allow exploding" to no for all blocks in a drawing? Any info leading me in the right direction would be appreciated, thanks!

Posted
(defun C:test ( / )
(vlax-for b (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
	(and 
		(eq (vla-get-IsLayout b) :vlax-false)
		(vl-catch-all-apply 'vla-put-Explodable (list b :vlax-false))
	)
)
(princ)
) (vl-load-com) (princ)

Posted

I would also exclude xrefs, i.e.:

(defun c:unexplodeall ( )
   (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
       (if (and (= :vlax-false (vla-get-islayout blk))
                (= :vlax-false (vla-get-isxref   blk))
           )
           (vla-put-explodable blk :vlax-false)
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

@Grrr, I don't see the need for vl-catch-all-apply in this operation?

Posted

@Grrr, I don't see the need for vl-catch-all-apply in this operation?

I've included it "just in case", no specific reason. :)

 

Some interesting questions, related to this thread:

- I don't understand why the "Layout blocks" also have "Explodable" property, how could one explode the Model/Paper space?!

- Also I was curious how it can be done with vanilla lisp, so I checked in the "BLOCK" (dxf) reference, expecting to find the explodable flag under GC 70, but no documentation about it.

Posted
I've included it "just in case", no specific reason. :)

 

OK, but that's a slippery slope - continuing with that form of error trapping & logic, you might as well enclose the entire program within a single vl-catch-all-apply expression: the code would never noticeably return an error, and when it does error, nothing is handled appropriately.

 

Some interesting questions, related to this thread:

- I don't understand why the "Layout blocks" also have "Explodable" property, how could one explode the Model/Paper space?!

 

Because they are derived from the same class as blocks & xrefs, and so all have the same properties.

 

- Also I was curious how it can be done with vanilla lisp, so I checked in the "BLOCK" (dxf) reference, expecting to find the explodable flag under GC 70, but no documentation about it.

 

Example:

(defun getexplodable ( blk / ent )
   (if (setq ent (tblobjname "block" blk))
       (cdr (assoc 280 (entget (cdr (assoc 330 (entget ent))))))
   )
)

Posted
OK, but that's a slippery slope - continuing with that form of error trapping & logic, you might as well enclose the entire program within a single vl-catch-all-apply expression: the code would never noticeably return an error, and when it does error, nothing is handled appropriately.

I've read that before, but I don't think it should be a problem for this particular case (routine).

BTW I think in some cases manual prompting might be useful:

(if (vl-catch-all-error-p (setq err (vl-catch-all-apply ...)))
(setq errLst (cons err errLst))
)
(and errLst 
(print "The following errors occured: ") 
(foreach x errLst (print (vl-catch-all-error-message x)))
)

 

 

Example:

(defun getexplodable ( blk / ent )
(if (setq ent (tblobjname "block" blk))
	(cdr (assoc 280 (entget (cdr (assoc 330 (entget ent))))))
)
)

Thanks alot!

I've just read about GC 330, its written that its "Soft-pointer handle" - is that some type of dictionary for that entity?

Posted
I've just read about GC 330, its written that its "Soft-pointer handle" - is that some type of dictionary for that entity?

 

The value of DXF group 330 is generally a pointer to the parent entity - in this case, the BLOCK_RECORD parent of the BLOCK entity.

Posted
The value of DXF group 330 is generally a pointer to the parent entity - in this case, the BLOCK_RECORD parent of the BLOCK entity.

 

Thanks Lee!

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