Leaderboard
Popular Content
Showing content with the highest reputation since 07/28/2026 in Posts
-
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 points
-
Just a comment in Bricscad V25 the setpropertyvalue does not work, the get does work. One of those odd bugs2 points
-
So did you ever figure out how to do it, OP? I don't know how someone doesn't manually save like every 5 min. I can tell now that this is not a natural reaction for everyone. I am a millennial and it's been metaphorically beaten in my head throughout my all school years to save often. I save after every small bit of changes that I make. Hope you found a way that works for you, though!!2 points
-
those are attribute references of a block. Since vla-fieldcode only works on Text and mtext i used Lee Macs fieldcode instead https://www.lee-mac.com/fieldcode.html It should work on Blocks Attributereferences as well now. (defun c:change_prec (/ *error* acdoc undo-mark ss target index ename obj att field-string revised-string) (defun *error* (msg) (if undo-mark (progn (vl-catch-all-apply 'vla-EndUndoMark (list acdoc)) (setq undo-mark nil) ) ) (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) ) (princ (strcat "\nError: " msg)) ) (princ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (prompt "\nSelect text, MText, or attributed blocks: ") (while (null (setq ss (ssget '((0 . "TEXT,MTEXT,INSERT"))))) (prompt "\nNo valid text, MText, or blocks selected.") ) (initget 1 "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Current") (setq target (getkword "\nTarget precision [0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/Current]: ")) (vla-StartUndoMark acdoc) (setq undo-mark T) (repeat (setq index (sslength ss)) (setq index (1- index) ename (ssname ss index) obj (vlax-ename->vla-object ename) ) (cond ;; Text or MText ((wcmatch (vla-get-ObjectName obj) "AcDbText,AcDbMText") (setq field-string (vla-FieldCode obj)) (if (and field-string (setq revised-string (replacePrecision field-string target)) ) (vla-put-TextString obj revised-string) ) ) ;; Block reference with editable attributes ((vlax-method-applicable-p obj 'GetAttributes) (foreach att (vlax-invoke obj 'GetAttributes) (setq field-string (LM:fieldcode (vlax-vla-object->ename att))) (if (and field-string (setq revised-string (replacePrecision field-string target)) ) (vla-put-TextString att revised-string) ) ) ) ) ) (vla-EndUndoMark acdoc) (setq undo-mark nil) (vla-Regen acdoc acActiveViewport) (princ) ) (defun replacePrecision (fieldStr target / nbs prec_source return) (setq nbs 0) (cond ((vl-string-search "%<\\" fieldStr nbs) (while nbs (if (setq nbs (vl-string-search "%pr" fieldStr (setq tmp_nbs nbs))) (setq prec_source (itoa (atoi (substr fieldStr (+ nbs 4) 2))) fieldStr (vl-string-subst (if (eq target "Current") (strcat "%pr" (itoa (getvar "LUPREC"))) (strcat "%pr" target) ) (strcat "%pr" prec_source) fieldStr tmp_nbs ) nbs (1+ nbs) ) ) ) (setq return fieldStr) ) ) return ) ;; Field Code - Lee Mac ;; Returns the field expression associated with an entity (defun LM:fieldcode ( ent / replacefield replaceobject fieldstring enx ) (defun replacefield ( str enx / ent fld pos ) (if (setq pos (vl-string-search "\\_FldIdx" (setq str (replaceobject str enx)))) (progn (setq ent (assoc 360 enx) fld (entget (cdr ent)) ) (strcat (substr str 1 pos) (replacefield (fieldstring fld) fld) (replacefield (substr str (1+ (vl-string-search ">%" str pos))) (cdr (member ent enx))) ) ) str ) ) (defun replaceobject ( str enx / ent pos ) (if (setq pos (vl-string-search "ObjIdx" str)) (strcat (substr str 1 (+ pos 5)) " " (LM:ObjectID (vlax-ename->vla-object (cdr (setq ent (assoc 331 enx))))) (replaceobject (substr str (1+ (vl-string-search ">%" str pos))) (cdr (member ent enx))) ) str ) ) (defun fieldstring ( enx / itm ) (if (setq itm (assoc 3 enx)) (strcat (cdr itm) (fieldstring (cdr (member itm enx)))) (cond ((cdr (assoc 2 enx))) ("")) ) ) (if (and (wcmatch (cdr (assoc 0 (setq enx (entget ent)))) "TEXT,MTEXT,ATTRIB,MULTILEADER,*DIMENSION") (setq enx (cdr (assoc 360 enx))) (setq enx (dictsearch enx "ACAD_FIELD")) (setq enx (dictsearch (cdr (assoc -1 enx)) "TEXT")) ) (replacefield (fieldstring enx) enx) ) ) ;; ObjectID - Lee Mac ;; Returns a string containing the ObjectID of a supplied VLA-Object ;; Compatible with 32-bit & 64-bit systems (defun LM:ObjectID ( obj ) (eval (list 'defun 'LM:ObjectID '( obj ) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring) ) (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false) '(itoa (vla-get-objectid obj)) ) ) ) (LM:ObjectID obj) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) )1 point
-
in autocad you could change Annotative to "No" using setpropertyvalue. For example: (setpropertyvalue ent "Annotative" 0)1 point
-
I posted this at the swamp, this is pretty cool Proof of concept (V25, V26, V27Beta) - appload BrxBlockManXX.brx - type blockman at the prompt - select a drawing from the directory control - double click or drag a block from the List control to the current drawing - double click the main preview to insert the whole drawing - click the open folder button to add your favorite folder(s) - use the dropdown to navigate to a favorite folder - right click on a dwg to open it let me know if it crashes lol edit, posted the source and binaries here https://github.com/CEXT-Dan/BrxBlockMan1 point
-
@Danielm103 has updated the code and its running under Bricscad and is very impressive, I am sure the updated code will be posted here soon.1 point
-
1 point
-
seems ezdxf has this feature, so we can just use it. import wx from ezdxf.addons import acadctb from pyrx import Ap, Db, Ed def browse_for_ctb(): """Opens a native wxPython file dialog to browse for a CTB file.""" parent = wx.GetApp().GetTopWindow() with wx.FileDialog( parent, "Select AutoCAD CTB File", wildcard="CTB files (*.ctb)|*.ctb", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, ) as fileDialog: if fileDialog.ShowModal() == wx.ID_CANCEL: return None return fileDialog.GetPath() @Ap.Command() def doit() -> None: ctb_path = browse_for_ctb() if not ctb_path: print("\nCommand cancelled.") return try: # 2. Parse the CTB using ezdxf ctb_data = acadctb.load(ctb_path) except Exception as e: print(f"\nFailed to parse CTB file: {str(e)}") return active_colors = [] for idx in range(1, 256): style = ctb_data[idx] # Keep the entry if it overrides lineweight or screening if style.lineweight >= 0 or style.screen < 100: # Store the index along with the full style object to access all 10 properties active_colors.append((idx, style)) if not active_colors: print("\nNo explicit pen styles overrides found in this CTB. Table skipped.") return db = Db.curDb() ps, insert_pt = Ed.Editor.getPoint("\nSpecify insertion point for the CTB table: ") if ps != Ed.PromptStatus.kNormal: return table = Db.Table() table.setDatabaseDefaults(db) # 10 headers corresponding to all the available style properties headers = [ "ACI Index", "Lineweight", "Screening", "Dither", "Phys Pen", "Virt Pen", "Linetype", "Adaptive LT", "Fill Style", "Style Index" ] total_rows = len(active_colors) + 2 # Title row + Header row + Data rows table.setSize(total_rows, len(headers)) table.setPosition(insert_pt) table.generateLayout() # Title Row Configurations table.setTextString(0, 0, f"Complete CTB Profile: {ctb_path.split('\\')[-1]}") # Header Row Configurations for col_idx, header_text in enumerate(headers): table.setTextString(1, col_idx, header_text) # Populate Data rows for row_idx, (idx, style) in enumerate(active_colors, start=2): lweight_str = f"{style.lineweight:.2f} mm" if style.lineweight >= 0 else "Use Object Value" table.setBackgroundColor(row_idx, 0, Db.Color(style.aci)) table.setContentColor(row_idx, 0, Db.Color(7)) table.setTextString(row_idx, 0, str(style.aci)) table.setTextString(row_idx, 1, lweight_str) table.setTextString(row_idx, 2, f"{style.screen}%") table.setTextString(row_idx, 3, "On" if style.dithering == 1 else "Off") table.setTextString(row_idx, 4, str(style.physical_pen_number)) table.setTextString(row_idx, 5, str(style.virtual_pen_number)) table.setTextString(row_idx, 6, str(style.linetype)) table.setTextString(row_idx, 7, "Yes" if style.adaptive_linetype == 1 else "No") table.setTextString(row_idx, 8, str(style.fill_style)) table.setTextString(row_idx, 9, str(style.index)) db.addToCurrentspace(table) print(f"\nSuccessfully generated a 10-column table with {len(active_colors)} CTB overrides.")1 point
-
UPDATE: There has been a delay in the forum upgrade. I will make a further announcement in due course and let you know when it will be happening.1 point
-
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 point
-
I think the bottom line is how much are you prepared to lose in production time ? A autosave of say 1/2 hour to me sounds reasonable. Were I worked we had a power failure, a IT server disconnect. The power out showed how often people saved their work, renaming the sv$ helped. Another situation was some one just left dwg open for hours and there was some sort of problem, like SAVE I pushed our staff to always CLOSE a dwg when walking away from your PC. Yes you can go the toilet or get a coffee.1 point
-
Never have I needed Autosave. CTRL+S is just a habit now, even in non-AutoCAD programs. I also frequently Right-Click one of the Drawing Tabs and select Save All. I also know the difference between Qsave and Save and use both appropriately. (Note: they are the same in AutoCAD LT or used to be, I am not sure about newer LT versions) Saving your work is your job, not AutoCAD's. I wonder if a LISP with a reactor would be less troublesome for those that do not trust going without an Autosave? Or maybe this? A Better Autosave | AfraLISP Or... (command ".save") to Visual LISP - AutoLISP, Visual LISP & DCL - AutoCAD Forums Or... make a copy of current open drawing & place it into a predetermine folder - AutoLISP, Visual LISP & DCL - AutoCAD Forums And... LISP - Automatic Save that runs at set intervals1 point
-
You have to make two Field, once for Distance of Block, then Once for Arrray Object (item or column * row). Cause an Array Object now is include all block, all Field of length in per Array is fixed1 point
-
from pyrx import Ap, Ax, Db, Ed, Ge, Br def getAllFieldsIds(db: Db.Database): ids: list[Db.ObjectId] = [] nod = Db.Dictionary(db.namedObjectsDictionaryId()) fieldListId = nod.getAt("ACAD_FIELDLIST") fieldList = Db.Core.entGet(fieldListId) for fieldItem in fieldList: if fieldItem[0] == 330 and fieldItem[1].isDerivedFrom(Db.Field.desc()): ids.append(fieldItem[1]) return set(ids) @Ap.Command() def doit() -> None: db = Db.curDb() field_ids = getAllFieldsIds(db) for id in field_ids: field = Db.Field(id, Db.OpenMode.kForRead) fmt = field.getFormat() if 'pr3' in fmt: field.upgradeOpen() new_fmt = fmt.replace('pr3', 'pr4') field.setFormat(new_fmt) field.evaluate(Db.FieldEvalContext.kDemand, db) print(f"Updated field format from {fmt} to {new_fmt}")1 point
-
@CamDuy gave it a try it appears to only look for a text object the OP wants an attribute in a block also to be updated.1 point
-
Agreed. I am 100% on the side of [turn Autosave OFF] and use one of the many ways to save your data file every time you do something you don't want to lose.1 point
-
1 point
-
That is cool! But didn't AutoCAD 2027 released something tiny bit similar (project workspace?)1 point
-
CopyRenameBlockV1-5_byCamDuy.lsp Try using this file. @Nikon1 point
-
Nice Lisp VicoWang! This looks like a great solution to the dreaded startup suite, some suggestions; Is it possible to have the "Asset Name" be the file name by default? Could the "Version" field default to 0?1 point
-
Yes need a much better realistic sample dwg with say a couple of different scenarios, array,non array and so on, even different lengths. There is a way of getting array info, you read the 1st object for properties, then the numbers in the row and column values.1 point
