dber Posted Friday at 10:53 PM Posted Friday at 10:53 PM Hi, I have a LISP code to help clean up some incoming files from Civils as we work on projects. I wanted to add to this code that I got, and was wondering if there are any lines of code that could make AutoCAD: 1. Change Allow Exploding to "Yes" for all blocks 2. Select all hatches in drawing and change Annotative to "No" I heard the commands can be limited, so just wondering if its possible and what it might look like. Thanks! Quote
troggarf Posted Saturday at 06:05 PM Posted Saturday at 06:05 PM Here is a quick find from Google for setting all blocks as explodable: ;; Set every block as explodable ;; http://forums.augi.com/showthread.php?33008-Allow-block-exploding&highlight=explodable&pp=10 ;; posted by whdjr (defun c:eb () (vl-load-com) (vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) '(lambda (x) (and (vlax-property-available-p x 'explodable) (eq (vlax-get-property x 'explodable) :vlax-false) (not (vlax-put-property x 'explodable :vlax-true)) ) ) ) ) 1 Quote
EnM4st3r Posted Monday at 05:48 AM Posted Monday at 05:48 AM in autocad you could change Annotative to "No" using setpropertyvalue. For example: (setpropertyvalue ent "Annotative" 0) 1 Quote
BIGAL Posted Monday at 06:36 AM Posted Monday at 06:36 AM Just a comment in Bricscad V25 the setpropertyvalue does not work, the get does work. One of those odd bugs 1 1 Quote
SLW210 Posted Monday at 11:18 AM Posted Monday at 11:18 AM Here is another for allowing explode... Solved: Re: Allow exploding outside the block editor - Autodesk Community Are these drawings from AutoCAD Civil 3D or some other CAD? (defun c:AllBlkYHtchN (/ ss i ent) (vl-load-com) ;;-------------------------------------------------- ;; Set Allow Exploding = Yes for all block definitions ;;-------------------------------------------------- (vlax-map-collection (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) '(lambda (blk) (if (vlax-property-available-p blk 'Explodable) (vlax-put-property blk 'Explodable :vlax-true) ) ) ) ;;-------------------------------------------------- ;; Set all hatches Annotative = No ;;-------------------------------------------------- (if (setq ss (ssget "_X" '((0 . "HATCH")))) (progn (setq i 0) (repeat (sslength ss) (setq ent (ssname ss i)) (vl-catch-all-apply '(lambda () (setpropertyvalue ent "Annotative" 0) ) ) (setq i (1+ i)) ) ) ) (princ (strcat "\nUpdated " (itoa (if ss (sslength ss) 0)) " hatch(es). All explodable block definitions enabled." ) ) (princ) ) Do you need nested hatches and blocks, dynamic and/or anonymous blocks? 2 Quote
SLW210 Posted yesterday at 11:02 AM Posted yesterday at 11:02 AM If you don't mind sharing what else the code you have is doing or even better what you want it to do, this probably could be improved to coordinate with what you have already. Quote
dber Posted 19 hours ago Author Posted 19 hours ago 4 hours ago, SLW210 said: If you don't mind sharing what else the code you have is doing or even better what you want it to do, this probably could be improved to coordinate with what you have already. What we have already just cleans up an incoming CAD file like unlocking all layers, color to ByLayer, Audit, PU, -PU(regapps), and changing the units. We use AutoCAD LT and I don't think we need to change nested hatches because the hatches I want to code are usually on the surface and include pavement, sidewalk, etc., and not in another block. I would want to include dynamic blocks to be able to be exploded as well since alot of utility symbols are dynamic blocks. I've never heard of anonymous blocks... (defun C:CLEANUP ( / allobjects hatchss i hobj hcount) (command "-layer" "unlock" "*" "") ; Unlocks all layers to make them editable (setq allobjects (ssget "_X" )) (command "_.CHPROP" allobjects "" "_color" "ByLAyer" "") ; Sets the color of all objects to ByLayer (command "_AUDIT" "Yes") (command "_PURGE" "Regapps" "*" "No") (command "_PURGE" "All" "*" "No") (setvar "lunits" 2) ; Set linear units to decimal (setvar "aunits" 0) ; Set angular units to decimal (command "_INSUNITS" "0") ; Specifies the drawing units as unitless ;; Turn off Annotative property on all hatch objects (vl-load-com) (setq hcount 0) (if (setq hatchss (ssget "_X" '((0 . "HATCH")))) (progn (setq i 0) (while (< i (sslength hatchss)) (setq hobj (vlax-ename->vla-object (ssname hatchss i))) (if (vlax-property-available-p hobj "Annotative") (progn (vla-put-Annotative hobj :vlax-false) (setq hcount (1+ hcount)) ) ) (setq i (1+ i)) ) ) ) (princ (strcat "\n" (itoa hcount) " hatch(es) set to non-annotative.")) (princ "\n\nFile has been cleaned.") ) (princ) 1 Quote
BIGAL Posted 11 hours ago Posted 11 hours ago I dont know if its my Bricscad V25 but this is what you get using; (vla-put-Annotative hobj :vlax-false) ; error : Automation Error. Property [ANNOTATIVE] not available Would appreciate to know if same in Acad etc. 1 Quote
EnM4st3r Posted 5 hours ago Posted 5 hours ago 6 hours ago, BIGAL said: Would appreciate to know if same in Acad etc. yes, same in acad. "Fehler: ActiveX-Server gab folgenden Fehler zurück: unbekannter Name: Annotative" There is no such property wich is why i would use setpropertyvalue for acad. As for Bricscad idk how one would do that 1 Quote
SLW210 Posted 43 minutes ago Posted 43 minutes ago Mine works in Full AutoCAD 2026. Where did (vla-put-Annotative hobj :vlax-false) come from? Mine uses (setpropertyvalue ent "Annotative" 0) What I posted is an adaptation of a larger cleanup program I have that's still in progress, so I am not sure if it would work fully in LT, I am trying to make it work with LT as much as possible and BricsCAD etc., but being without internet for the past two weeks my working at home has been limited. Quote
SLW210 Posted 36 minutes ago Posted 36 minutes ago Did my Code work on LT for you? You need to respond to queries if you desire the best results. Can you post an example drawing that needs the modifications you describe? You never answered what program was creating these drawings? If I catch up at work I'll see where I am on my cleanup routine and see if I can make it more LT friendly. Dynamic blocks among other things create anonymous blocks, so I'll double check the posted code and adjust if needed. From Autodesk: Quote The block definitions (BLOCK) table in a drawing can contain anonymous blocks (also known as unnamed blocks), that AutoCAD creates to support dynamic blocks, tables, hatch patterns, and associative dimensions. Basically if anything is changed from the original version, like stretch, rotate, flip, visibility, etc. an anonymous block is created. There is RESETBLOCK in full AutoCAD, not sure on LT. It returns the block to the original default values of the dynamic block. Quote
Recommended Posts
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.