BIGAL Posted February 23, 2018 Share Posted February 23, 2018 DGRL just "WBLOCK" the block to a new dwg dont need the whole dwg just the bit you want to change. Quote Link to comment Share on other sites More sharing options...
rlx Posted February 23, 2018 Share Posted February 23, 2018 Not sure why you need this either or if there's a better / easier way , but that's not my problem try this : (defun C:DGRL ( / err blockname ss blk)(DGRL_Init) (DGRL_Select_Blocks) (DGRL_Exit) (princ)) (defun DGRL_Error (s) (princ s)(DGRL_Exit)(setq *error* err)) (defun DGRL_Init () (vl-load-com) (setq err *error* *error* DGRL_Error blockname "textblock")) (defun DGRL_Exit ()(princ "\nDone\n")) (defun SS->Lst (ss) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (defun DGRL_Select_Blocks ( / ss blk obj lst) (if (setq ss (ssget "_x" (list (cons 0 "insert") (cons 2 blockname)))) (progn (foreach blk (setq ss (mapcar 'vlax-ename->vla-object (SS->Lst ss))) (setq lst (vl-catch-all-apply 'vlax-invoke (list blk 'explode))) (foreach obj lst (if (not (eq (vla-get-objectname obj) "AcDbMText"))(vla-delete obj)))) (DGRL_ModifyBlockDefinition blockname) ) ) ) (defun DGRL_ModifyBlockDefinition ( $block / obj e dict ) (vlax-for obj (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) $block) (if (and (eq (vla-get-objectname obj) "AcDbMText") (setq e (entget (vlax-vla-object->ename obj))) (setq dict (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") e)))) (dictsearch dict "ACAD_FIELD")) (vla-delete obj)))) gr.Rlx Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted February 23, 2018 Share Posted February 23, 2018 I cant give you answer as my post does not appearsDon't know why Routine does not work it burst the block does not make new one you can buy a program call toolpac it has all the thing you need. it is a addon for autocad Quote Link to comment Share on other sites More sharing options...
rlx Posted February 23, 2018 Share Posted February 23, 2018 you can buy a program call toolpac it has all the thing you need. it is a addon for autocad and mine was for free Quote Link to comment Share on other sites More sharing options...
DGRL Posted February 23, 2018 Author Share Posted February 23, 2018 @rlx Thanks for your reply WHat does this code do? Coz all i see now it that block still being present in org state and only mtext ( not containing fields ) "being" copied out of block and placed in model space Am i correct? Quote Link to comment Share on other sites More sharing options...
rlx Posted February 23, 2018 Share Posted February 23, 2018 (edited) @rlx Thanks for your reply WHat does this code do? Coz all i see now it that block still being present in org state and only mtext ( not containing fields ) "being" copied out of block and placed in model space Am i correct? ah , think I might have reversed before and after , thought you wanted to separate the mtext from the block and update the block definition (hence the burst burst burst), but you want the attributes become mtext? oh excuse , mtext to become attributes... that's just me being tired. Think its possible to convert mtext to attribute by substitude some dxf codes like in Lee's burst program but in this case I think I agree with bigal , and I would just read the values from the current block and redefine the block by inserting the new block and copying the old values into it. Will see if I can spare some time this weekend else maybe monday when the boss goes on a trip with some colleages.. gr. Rlx Edited February 24, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted February 24, 2018 Author Share Posted February 24, 2018 hi i wanted the attribute value to become mtext ot text everything else needs to remain the same :-) Quote Link to comment Share on other sites More sharing options...
rlx Posted February 24, 2018 Share Posted February 24, 2018 hi i wanted the attribute value to become mtext ot text everything else needs to remain the same :-) have to admit fields are complete uncharted territory for me. Have studied and making some progress but very slowly. But would simply redefine the block not be enough? You probably already have the block as you want it to be on disk or in a drawing. In that case wblock it and use it to update every drawing like this : (defun c:t2 ( / new-block ss old-block ip) (if (and (setq new-block (findfile "d:/temp/lisp/Cad-tutor/dgrl/textblock-txt.dwg")) (setq ss (ssget "_x" (list (cons 0 "insert") (cons 2 "textblock")))) (setq old-block (ssname ss 0) ip (cdr (assoc 10 (entget old-block))))) (progn (setvar "expert" 3) (entdel old-block) (vl-cmdf ".-insert" (strcat "textblock=" new-block) ip 1 1 0) ) ) (princ) ) in my case I saved the version without the attributes as 'textblock-txt' and then above function deletes the attributed one and inserts the new block but the name of the block in the drawing remains the same. I assume the values of the texts are set by means of a custom variable or something? gr. Rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted February 26, 2018 Author Share Posted February 26, 2018 @rlx Many thanks for this Quote Link to comment Share on other sites More sharing options...
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.