Daniel S Posted March 25, 2022 Posted March 25, 2022 (edited) Hello Everyone, I'm trying to make an auto lisp which will help me with updating my blocks default attributes. Unfortunately I can’t find the solution - so I hope that someone can help me with this problem. I’m a landscape designer and I made tree blocks for my projects. I used export and import attributes function in CAD to update all attributes values in my drawing. But I would like to have those values as default. Auto lisp code should copy every values from attributes tags from block in drawing to default attributes values of this block. Edited March 25, 2022 by Daniel S Quote
devitg Posted March 26, 2022 Posted March 26, 2022 (edited) @Daniel SFor better understanding, and maybe get further help, please upload such sample.dwg As far as I know, ACAD only can edit DWG. Edited March 28, 2022 by devitg erase email Quote
Daniel S Posted March 26, 2022 Author Posted March 26, 2022 @devitg In attachment is example file with plant blocks. There are 5 of them. I plan to have 200 plant blocks. Like you can see I drawing I added values to attributes to blocks. When you edit block you will see that blocks don't have default values in attributes. I would like to use lisp to copy vales from values in attributes in blocks in drawing to default values in attributes of this block. I would like to use then WBLOCK to save those blocks in folder to use it in other project - without to have complete attributes again. plant_blocks_example.dwg Quote
marko_ribar Posted March 26, 2022 Posted March 26, 2022 This could be usefull - but AutoCAD LT (AFAIK - it doesn't support AutoLISP/VisualLISP...) What are you expecting for an answer - LSP routine, macro, action record macro, ???? Quote
Daniel S Posted March 26, 2022 Author Posted March 26, 2022 Hi. I use also GStarCAD so I would like to have AutoLISP for a routine. Quote
BIGAL Posted March 27, 2022 Posted March 27, 2022 Does Gstarcad support dynamic blocks ? If so can have 1 block but do spread and trunk as 2 independent objects in 1 block. Quote
Daniel S Posted March 27, 2022 Author Posted March 27, 2022 7 hours ago, BIGAL said: Does Gstarcad support dynamic blocks ? If so can have 1 block but do spread and trunk as 2 independent objects in 1 block. It is of topic - but yes you can use dynamic blocks in GStarCAD but Pro version. But I think that you can't do two independent visibility states. You have to make combination with spead abd trunk. Quote
BIGAL Posted March 27, 2022 Posted March 27, 2022 (edited) Back to question using Bedit then dbl click an attribute fill in default value and Bclose and save, then insert block the default prompt value should be there. It is feasible to get at block attributes in the block table and set default values to prompt. Re trunk and spread yes trunk was a circle Rad1 property, the foliage had a stretch parameter Rad2. treedyn.dwg Edited March 28, 2022 by BIGAL Quote
devitg Posted March 28, 2022 Posted March 28, 2022 16 hours ago, Daniel S said: It is of topic - but yes you can use dynamic blocks in GStarCAD but Pro version. But I think that you can't do two independent visibility states. You have to make combination with spead abd trunk. My way to do it . ;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA ;;; Copyleft 1995-2022 by Gabriel Calos De Vit ; DEVITG@GMAIL.COM ;; ; ---------------------------------------------------------------------- ; DISCLAIMER: Gabriel Calos De Vit Disclaims any and all liability for any damages ; arising out of the use or operation, or inability to use the software. ; FURTHERMORE, User agrees to hold Gabriel Calos De Vit harmless from such claims. ; Gabriel Calos De Vit makes no warranty, either expressed or implied, as to the ; fitness of this product for a particular purpose. All materials are ; to be considered ‘as-is’, and use of this software should be ; considered as AT YOUR OWN RISK. ; ---------------------------------------------------------------------- ;************************************************************************************************************ (DEFUN G-ATT-LIST/OBJ (ENT-OBJBLK / ;;lst ) (IF (= (TYPE ENT-OBJBLK) 'ENAME) (SETQ OBJBLK (VLAX-ENAME->VLA-OBJECT ENT-OBJBLK)) (SETQ OBJBLK ENT-OBJBLK) ) (COND ((NOT OBJBLK)) ((/= (VLA-GET-HASATTRIBUTES OBJBLK) :VLAX-TRUE)) ((VL-CATCH-ALL-ERROR-P (SETQ LST (VL-CATCH-ALL-APPLY 'VLAX-SAFEARRAY->LIST (LIST (VLAX-VARIANT-VALUE (VLA-GETATTRIBUTES OBJBLK)))))) (SETQ LST NIL) ) ) ;_c.cond LST ) ;_c.defun ;************************************************************************************************************ (defun copy-att-to-empty-block (/ ACAD-OBJ ADOC BLOCK- BLOCK-OBJ BLOCK-OBJ-ESC-X BLOCK-OBJ-ESC-Y BLOCK-OBJ-ESC-Z BLOCK-OBJ-NAME BLOCK-OBJ-ROT BLOCK-SS COUNT MODEL NEW-BLK NEW-BLK-ATT-LIST NEW-BLK-ATT-LIST-QTY NEW-BLK-PT OLD-BLK-ATT-LIST ) (VL-LOAD-COM) (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ el programa ACAD (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ el DWG que esta abierto- (SETQ MODEL (VLA-GET-MODELSPACE ADOC)) (prompt "\nSelect the BLOCK to copyfrom [rigth click to end ] ") (while (/=(setq block-ss(ssget "_:S+." (list(cons 0 "INSERT")(cons 8 "*"))))nil) (setq block-(ssname block-ss 0)) (setq block-obj (VLAX-ENAME->VLA-OBJECT block-)) (setq block-obj-name(VLA-GET-NAME block-obj)) (setq new-blk-pt (getpoint (strcat "\n pick the point where to Insert the < " block-obj-name " >")) ) ;_ setq new-blk-pt (setq block-obj-esc-x (vla-get-XScaleFactor block-obj)) (setq block-obj-esc-y (vla-get-yScaleFactor block-obj)) (setq block-obj-esc-z (vla-get-zScaleFactor block-obj)) (setq block-obj-rot (VLA-GET-ROTATION block-obj)) (setq new-blk (vla-InsertBlock model (VLAX-3D-POINT new-blk-pt) block-obj-name block-obj-esc-x block-obj-esc-y block-obj-esc-z block-obj-rot ) ;_ vla-InsertBlock ) ;_ setq (setq new-blk-att-list (G-ATT-LIST/OBJ new-blk)) (setq new-blk-att-list-qty (Length new-blk-att-list)) (setq old-blk-att-list (G-ATT-LIST/OBJ block-obj)) (setq count 0) (repeat new-blk-att-list-qty (VLA-PUT-TEXTSTRING (nth count new-blk-att-list) (VLA-GET-TEXTSTRING (nth count old-blk-att-list)) ) ;_ VLA-PUT-TEXTSTRING (setq count (1+ count)) ) ;_ repeat ); end delwhile (princ) );end copy-att-to-empty-block (defun c:att2block (/ AUTOSNAP CMDECHO ORTHOMODE OSMODE ) (setq autosnap (getvar 'autosnap)) (setq osmode (getvar'osmode)) (setq orthomode (getvar 'orthomode)) (setq CMDECHO (getvar 'CMDECHO)) (setvar 'autosnap 0) (setvar 'osmode 0) (setvar 'orthomode 0) (setvar 'CMDECHO 0) (copy-att-to-empty-block) (princ) (setvar 'autosnap autosnap) (setvar 'osmode osmode ) (setvar 'orthomode orthomode) (setvar 'CMDECHO CMDECHO) );end main defun ;|«Visual LISP© Format Options» (100 2 1 2 T " " 100 6 0 0 1 nil T nil T) ;*** DO NOT add text below the comment! ***|; plant_blocks-old and new TREE_1.dwg 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.