MTE20112 Posted September 3, 2016 Posted September 3, 2016 I'm trying to see if this is possible. Drawing with many dynamic blocks, all with many attributes. Was curious if there was a routine that would select a single block - enable user to fill in the attributes click OK - then move onto the "next" block in the drawing until complete. Anything like this remotely possible? Quote
BIGAL Posted September 4, 2016 Posted September 4, 2016 You can get a selection of blocks by block name, go to the first or the one you picked and change the attributes, the order of selection is normally in creation order, you can skip the one you have already changed. Lee-mac has a dynamic block update program so would look at that first. ; get all blocks of the same name (setq blk (entget (car (entsel "Pick a block")))) (setq blkname (cdr (assoc 2 blk))) (setq ss (ssget "X" (list (cons 0 "INsert")(cons 2 blkname)))) (alert (strcat "You have " (rtos (sslength ss) 2 0) " blocks called " blkname)) Without a sample dwg no more can be done post one with say 3 blocks Quote
MTE20112 Posted September 4, 2016 Author Posted September 4, 2016 CAD blocks2.dwg You can get a selection of blocks by block name, go to the first or the one you picked and change the attributes, the order of selection is normally in creation order, you can skip the one you have already changed. Lee-mac has a dynamic block update program so would look at that first. ; get all blocks of the same name (setq blk (entget (car (entsel "Pick a block")))) (setq blkname (cdr (assoc 2 blk))) (setq ss (ssget "X" (list (cons 0 "INsert")(cons 2 blkname)))) (alert (strcat "You have " (rtos (sslength ss) 2 0) " blocks called " blkname)) Without a sample dwg no more can be done post one with say 3 blocks Here is a sample file - 3 blocks in the file, each has two attributes. How can I implement your code? Thanks. Quote
Dadgad Posted September 4, 2016 Posted September 4, 2016 I would probably just tweak them, if need be, in my QUICK PROPERTIES palette. CTRL+SHIFT+P to enable them, or turn them on in your task bar, at the bottom of the screen. I suspect that Lee's lisp, to which BIGAL alludes, is the following http://www.lee-mac.com/dynamicblockcounter.html , which is very useful if you need to keep track of the conditions of multiple blocks easily. Thanks Lee! Quote
Lee Mac Posted September 4, 2016 Posted September 4, 2016 Related: https://www.theswamp.org/index.php?topic=51947.0 Quote
Grrr Posted September 4, 2016 Posted September 4, 2016 (edited) I was wondering on which of the forums to reply, and I've decided to post my attempt here: [color=#8b4513]; Grrr[/color] [color=#8b4513]; Upon selecting an attributed, dynamic block[/color] [color=#8b4513]; user is prompted to change every attribute value, on every block with the same name, located on the current tab:[/color] [b][color=BLACK]([/color][/b]defun C:test [b][color=FUCHSIA]([/color][/b] / *error* SysVarLst e enx o sUndo EffName SSX i en SSX-Lst BlksLst TempSS ll ur str b c att[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar 'errno 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]sssetfirst nil nil[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]defun *error* [b][color=NAVY]([/color][/b] msg [b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]sssetfirst nil nil[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if sUndo [b][color=MAROON]([/color][/b]vla-EndUndoMark [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if c [b][color=MAROON]([/color][/b]vla-SendCommand [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [color=#2f4f4f]"_.undo"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][color=#8b4513]; if the user reached till this point[/color] [b][color=NAVY]([/color][/b]if SysVarLst [b][color=MAROON]([/color][/b]mapcar '[b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b] n v / [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setvar n v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]mapcar 'car SysVarLst[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]mapcar 'cadr SysVarLst[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]or [b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]member msg '[b][color=RED]([/color][/b][color=#2f4f4f]"Function cancelled"[/color] [color=#2f4f4f]"quit / exit abort"[/color][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]wcmatch [b][color=BLUE]([/color][/b]strcase msg[b][color=BLUE])[/color][/b] [color=#2f4f4f]"*BREAK,*CANCEL*,*EXIT*"[/color][b][color=GREEN])[/color][/b] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]princ [b][color=GREEN]([/color][/b]strcat [color=#2f4f4f]"\nError: "[/color] msg[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ[b][color=NAVY])[/color][/b] [b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq SysVarLst [b][color=NAVY]([/color][/b]mapcar [b][color=MAROON]([/color][/b]function [b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b] a b / [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]list a [b][color=RED]([/color][/b]getvar a[b][color=RED])[/color][/b] b[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]list [color=#2f4f4f]"CLIPROMPTLINES"[/color] [color=#2f4f4f]"CMDECHO"[/color] [color=#2f4f4f]"BLIPMODE"[/color] [color=#2f4f4f]"NOMUTT"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]list 3 0 0 0[b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b] [b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq sUndo [b][color=NAVY]([/color][/b]vla-StartUndoMark [b][color=MAROON]([/color][/b]vla-get-ActiveDocument [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]mapcar '[b][color=NAVY]([/color][/b]lambda [b][color=MAROON]([/color][/b] n v / [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setvar n v[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'car SysVarLst[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'caddr SysVarLst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]/= [b][color=MAROON]([/color][/b]getvar 'errno[b][color=MAROON])[/color][/b] 52[b][color=NAVY])[/color][/b] [color=#8b4513]; enclose in a loop, until we have the correct entity[/color] [b][color=NAVY]([/color][/b]setq e [b][color=MAROON]([/color][/b]car [b][color=GREEN]([/color][/b]entsel [color=#2f4f4f]"\nSelect attributed dynamic block: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]getvar 'errno[b][color=BLUE])[/color][/b] 7[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nMissed, try again!"[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=GREEN]([/color][/b]setvar 'errno 0[b][color=GREEN])[/color][/b][color=#8b4513]; restore the 'errno' variable[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]type e[b][color=RED])[/color][/b] 'ENAME[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][color=#8b4513]; user pressed enter[/color] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nUser pressed enter, exiting."[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setvar 'errno 52[b][color=GREEN])[/color][/b][color=#8b4513]; exit loop[/color] [b][color=GREEN]([/color][/b]setq e nil enx nil o nil[b][color=GREEN])[/color][/b][color=#8b4513]; don't proceed with the routine[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]/= [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 0 [b][color=PURPLE]([/color][/b]entget e[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [color=#2f4f4f]"INSERT"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nYou must select a block!"[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]vlax-get [b][color=RED]([/color][/b]vlax-ename->vla-object e[b][color=RED])[/color][/b] 'IsDynamicBlock[b][color=BLUE])[/color][/b] :vlax-false[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nThe selected block is not dynamic! "[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]or [b][color=BLUE]([/color][/b]/= [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 66 [b][color=TEAL]([/color][/b]entget e[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 1[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]vlax-get [b][color=PURPLE]([/color][/b]vlax-ename->vla-object e[b][color=PURPLE])[/color][/b] 'HasAttributes[b][color=RED])[/color][/b] :vlax-false[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nThe selected block is not attributed! "[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]T [b][color=GREEN]([/color][/b]setq enx [b][color=BLUE]([/color][/b]entget e[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq o [b][color=BLUE]([/color][/b]vlax-ename->vla-object e[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setvar 'errno 52[b][color=GREEN])[/color][/b][color=#8b4513]; we got the correct entity - exit loop[/color] [b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b][color=#8b4513]; cond[/color] [b][color=FUCHSIA])[/color][/b][color=#8b4513]; while[/color] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]and e enx o[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]setq EffName [b][color=GREEN]([/color][/b]vlax-get o 'EffectiveName[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq SSX [b][color=GREEN]([/color][/b]ssget [color=#2f4f4f]"_X"[/color] [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]assoc 0 enx[b][color=RED])[/color][/b][b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar 'ctab[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]repeat [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]sslength SSX[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq en [b][color=BLUE]([/color][/b]ssname SSX [b][color=RED]([/color][/b]setq i [b][color=PURPLE]([/color][/b]1- i[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq SSX-Lst [b][color=BLUE]([/color][/b]cons en SSX-Lst[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=MAROON])[/color][/b][color=#8b4513]; repeat[/color] [b][color=MAROON]([/color][/b]if SSX-Lst [b][color=GREEN]([/color][/b]progn [b][color=BLUE]([/color][/b]setq BlksLst [b][color=RED]([/color][/b]vl-remove-if-not [b][color=PURPLE]([/color][/b]function [b][color=TEAL]([/color][/b]lambda [b][color=OLIVE]([/color][/b]x[b][color=OLIVE])[/color][/b] [b][color=OLIVE]([/color][/b]eq [b][color=GRAY]([/color][/b]vlax-get x 'EffectiveName[b][color=GRAY])[/color][/b] EffName[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]mapcar 'vlax-ename->vla-object SSX-Lst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setq TempSS [b][color=RED]([/color][/b]ssadd[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]foreach b BlksLst [b][color=RED]([/color][/b]vla-GetBoundingBox b 'll 'ur[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vla-ZoomWindow [b][color=PURPLE]([/color][/b]vlax-get-acad-object[b][color=PURPLE])[/color][/b] ll ur[b][color=RED])[/color][/b][color=#8b4513]; zoom to it[/color] [b][color=RED]([/color][/b]ssadd [b][color=PURPLE]([/color][/b]vlax-vla-object->ename b[b][color=PURPLE])[/color][/b] TempSS[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]sssetfirst nil TempSS[b][color=RED])[/color][/b][color=#8b4513]; grip it[/color] [b][color=RED]([/color][/b]foreach att [b][color=PURPLE]([/color][/b]vlax-safearray->list [b][color=TEAL]([/color][/b]vlax-variant-value [b][color=OLIVE]([/color][/b]vla-GetAttributes b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]setq str [b][color=TEAL]([/color][/b]getstring t [b][color=OLIVE]([/color][/b]strcat [color=#2f4f4f]"\nInput value for the \"[/color][color=#2f4f4f]" [b][color=GRAY]([/color][/b]vla-get-TagString att[b][color=GRAY])[/color][/b] "[/color]\[color=#2f4f4f]" tag \n < \"[/color][color=#2f4f4f]" [b][color=GRAY]([/color][/b]vla-get-TextString att[b][color=GRAY])[/color][/b] "[/color]\[color=#2f4f4f]" > or press ENTER to skip :"[/color][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b] [b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]if [b][color=TEAL]([/color][/b]/= str [color=#2f4f4f]""[/color][b][color=TEAL])[/color][/b] [b][color=TEAL]([/color][/b]vlax-put att 'TextString str[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vla-update b[b][color=RED])[/color][/b][color=#8b4513]; update the block, necessary?[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]not c[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]setq c [b][color=TEAL]([/color][/b]length BlksLst[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]princ [b][color=PURPLE]([/color][/b]strcat [color=#2f4f4f]"\nMoving on to the next block, "[/color] [b][color=TEAL]([/color][/b]itoa [b][color=OLIVE]([/color][/b]setq c [b][color=GRAY]([/color][/b]1- c[b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b] [color=#2f4f4f]" remaining!"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]sssetfirst nil nil[b][color=RED])[/color][/b][color=#8b4513]; ungrip it[/color] [b][color=RED]([/color][/b]ssdel [b][color=PURPLE]([/color][/b]vlax-vla-object->ename b[b][color=PURPLE])[/color][/b] TempSS[b][color=RED])[/color][/b] [b][color=BLUE])[/color][/b][color=#8b4513]; foreach[/color] [b][color=GREEN])[/color][/b][color=#8b4513]; progn[/color] [b][color=MAROON])[/color][/b][color=#8b4513]; if SSX-Lst[/color] [b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\nCongratulations, you are done!"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]vla-ZoomExtents [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][color=#8b4513]; not sure how to restore the zoom to the original state[/color] [b][color=MAROON]([/color][/b]vla-Regen [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] acActiveViewport[b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b][color=#8b4513]; progn[/color] [b][color=FUCHSIA])[/color][/b][color=#8b4513]; if [b][color=FUCHSIA]([/color][/b]and e enx o[b][color=FUCHSIA])[/color][/b][/color] [b][color=FUCHSIA]([/color][/b]mapcar '[b][color=NAVY]([/color][/b]lambda [b][color=MAROON]([/color][/b] n v / [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setvar n v[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'car SysVarLst[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'cadr SysVarLst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if sUndo [b][color=NAVY]([/color][/b]vla-EndUndoMark [b][color=MAROON]([/color][/b]vla-get-ActiveDocument [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b] [b][color=BLACK])[/color][/b][color=#8b4513];| defun |; [b][color=BLACK]([/color][/b]vl-load-com[b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]princ[b][color=BLACK])[/color][/b][/color] Updated code. A couple of questions appeared: Is it possible to restore the original "zoomwindow" state, before calling the routine? Any comments, how to properly set the "undo" operation and the UndoMark, within the *error* defun? It was interesting to write this, and perhaps LM's code does a better job. Edited September 4, 2016 by Grrr Quote
MTE20112 Posted September 4, 2016 Author Posted September 4, 2016 I was wondering on which of the forums to reply, and I've decided to post my attempt here: [color=#8b4513]; Grrr[/color] [color=#8b4513]; Upon selecting an attributed, dynamic block[/color] [color=#8b4513]; user is prompted to change every attribute value, on every block with the same name, located on the current tab:[/color] [b][color=BLACK]([/color][/b]defun C:test [b][color=FUCHSIA]([/color][/b] / *error* SysVarLst e enx o sUndo EffName SSX i en SSX-Lst BlksLst TempSS ll ur str b c att[b][color=FUCHSIA])[/color][/b][color=#8b4513]; <- UNTESTED![/color] [b][color=FUCHSIA]([/color][/b]setvar 'errno 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]sssetfirst nil nil[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]defun *error* [b][color=NAVY]([/color][/b] msg [b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if sUndo [b][color=MAROON]([/color][/b]vla-EndUndoMark [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if c [b][color=MAROON]([/color][/b]vla-SendCommand [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [color=#2f4f4f]"_.undo"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][color=#8b4513]; if the user reached till this point[/color] [b][color=NAVY]([/color][/b]if SysVarLst [b][color=MAROON]([/color][/b]mapcar '[b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b] n v / [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setvar n v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]mapcar 'car SysVarLst[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]mapcar 'cadr SysVarLst[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]or [b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]member msg '[b][color=RED]([/color][/b][color=#2f4f4f]"Function cancelled"[/color] [color=#2f4f4f]"quit / exit abort"[/color][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]wcmatch [b][color=BLUE]([/color][/b]strcase msg[b][color=BLUE])[/color][/b] [color=#2f4f4f]"*BREAK,*CANCEL*,*EXIT*"[/color][b][color=GREEN])[/color][/b] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]princ [b][color=GREEN]([/color][/b]strcat [color=#2f4f4f]"\nError: "[/color] msg[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ[b][color=NAVY])[/color][/b] [b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq SysVarLst [b][color=NAVY]([/color][/b]mapcar [b][color=MAROON]([/color][/b]function [b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b] a b / [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]list a [b][color=RED]([/color][/b]getvar a[b][color=RED])[/color][/b] b[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]list [color=#2f4f4f]"CLIPROMPTLINES"[/color] [color=#2f4f4f]"CMDECHO"[/color] [color=#2f4f4f]"BLIPMODE"[/color] [color=#2f4f4f]"NOMUTT"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]list 3 0 0 0[b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b] [b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq sUndo [b][color=NAVY]([/color][/b]vla-StartUndoMark [b][color=MAROON]([/color][/b]vla-get-ActiveDocument [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]mapcar '[b][color=NAVY]([/color][/b]lambda [b][color=MAROON]([/color][/b] n v / [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setvar n v[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'car SysVarLst[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'caddr SysVarLst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]/= [b][color=MAROON]([/color][/b]getvar 'errno[b][color=MAROON])[/color][/b] 52[b][color=NAVY])[/color][/b] [color=#8b4513]; enclose in a loop, until we have the correct entity[/color] [b][color=NAVY]([/color][/b]setq e [b][color=MAROON]([/color][/b]car [b][color=GREEN]([/color][/b]entsel [color=#2f4f4f]"\nSelect attributed dynamic block: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]getvar 'errno[b][color=BLUE])[/color][/b] 7[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nMissed, try again!"[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=GREEN]([/color][/b]setvar 'errno 0[b][color=GREEN])[/color][/b][color=#8b4513]; restore the 'errno' variable[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]/= [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 0 [b][color=PURPLE]([/color][/b]entget e[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [color=#2f4f4f]"INSERT"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nYou must select a block!"[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]or [b][color=BLUE]([/color][/b]/= [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 66 [b][color=TEAL]([/color][/b]entget e[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] 1[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]vlax-get [b][color=PURPLE]([/color][/b]vlax-ename->vla-object e[b][color=PURPLE])[/color][/b] 'HasAttributes[b][color=RED])[/color][/b] :vlax-false[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nThe selected block is not attributed! "[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]vlax-get [b][color=RED]([/color][/b]vlax-ename->vla-object e[b][color=RED])[/color][/b] 'IsDynamicBlock[b][color=BLUE])[/color][/b] :vlax-false[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nThe selected block is not dynamic! "[/color][b][color=GREEN])[/color][/b][color=#8b4513]; non-nil return - stay in loop[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]= [b][color=RED]([/color][/b]type e[b][color=RED])[/color][/b] 'ENAME[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][color=#8b4513]; user pressed enter[/color] [b][color=GREEN]([/color][/b]princ [color=#2f4f4f]"\nUser pressed enter, exiting."[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setvar 'errno 52[b][color=GREEN])[/color][/b][color=#8b4513]; exit loop[/color] [b][color=GREEN]([/color][/b]setq e nil enx nil o nil[b][color=GREEN])[/color][/b][color=#8b4513]; don't proceed with the routine[/color] [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]T [b][color=GREEN]([/color][/b]setq enx [b][color=BLUE]([/color][/b]entget e[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq o [b][color=BLUE]([/color][/b]vlax-ename->vla-object e[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setvar 'errno 52[b][color=GREEN])[/color][/b][color=#8b4513]; we got the correct entity - exit loop[/color] [b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b][color=#8b4513]; cond[/color] [b][color=FUCHSIA])[/color][/b][color=#8b4513]; while[/color] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]and e enx o[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]setq EffName [b][color=GREEN]([/color][/b]vlax-get o 'EffectiveName[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq SSX [b][color=GREEN]([/color][/b]ssget [color=#2f4f4f]"_X"[/color] [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]assoc 0 enx[b][color=RED])[/color][/b][b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar 'ctab[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]repeat [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]sslength SSX[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq en [b][color=BLUE]([/color][/b]ssname SSX [b][color=RED]([/color][/b]setq i [b][color=PURPLE]([/color][/b]1- i[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq SSX-Lst [b][color=BLUE]([/color][/b]cons en SSX-Lst[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=MAROON])[/color][/b][color=#8b4513]; repeat[/color] [b][color=MAROON]([/color][/b]if SSX-Lst [b][color=GREEN]([/color][/b]progn [b][color=BLUE]([/color][/b]setq BlksLst [b][color=RED]([/color][/b]vl-remove-if-not [b][color=PURPLE]([/color][/b]function [b][color=TEAL]([/color][/b]lambda [b][color=OLIVE]([/color][/b]x[b][color=OLIVE])[/color][/b] [b][color=OLIVE]([/color][/b]eq [b][color=GRAY]([/color][/b]vlax-get x 'EffectiveName[b][color=GRAY])[/color][/b] EffName[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]mapcar 'vlax-ename->vla-object SSX-Lst[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]setq TempSS [b][color=RED]([/color][/b]ssadd[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]foreach b BlksLst [b][color=RED]([/color][/b]vla-GetBoundingBox b 'll 'ur[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vla-ZoomWindow [b][color=PURPLE]([/color][/b]vlax-get-acad-object[b][color=PURPLE])[/color][/b] ll ur[b][color=RED])[/color][/b][color=#8b4513]; zoom to it[/color] [b][color=RED]([/color][/b]ssadd [b][color=PURPLE]([/color][/b]vlax-vla-object->ename b[b][color=PURPLE])[/color][/b] TempSS[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]sssetfirst nil TempSS[b][color=RED])[/color][/b][color=#8b4513]; grip it[/color] [b][color=RED]([/color][/b]foreach att [b][color=PURPLE]([/color][/b]vlax-safearray->list [b][color=TEAL]([/color][/b]vlax-variant-value [b][color=OLIVE]([/color][/b]vla-GetAttributes b[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]setq str [b][color=TEAL]([/color][/b]getstring t [b][color=OLIVE]([/color][/b]strcat [color=#2f4f4f]"\nInput value for the \"[/color][color=#2f4f4f]" [b][color=GRAY]([/color][/b]vla-get-TagString att[b][color=GRAY])[/color][/b] "[/color]\[color=#2f4f4f]" tag \n < \"[/color][color=#2f4f4f]" [b][color=GRAY]([/color][/b]vla-get-TextString att[b][color=GRAY])[/color][/b] "[/color]\[color=#2f4f4f]" > or press ENTER to skip :"[/color][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b] [b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]if [b][color=TEAL]([/color][/b]/= str [color=#2f4f4f]""[/color][b][color=TEAL])[/color][/b] [b][color=TEAL]([/color][/b]vlax-put att 'TextString str[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b] [b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vla-update b[b][color=RED])[/color][/b][color=#8b4513]; update the block, nessecary?[/color] [b][color=RED]([/color][/b]if [b][color=PURPLE]([/color][/b]not c[b][color=PURPLE])[/color][/b] [b][color=PURPLE]([/color][/b]setq c [b][color=TEAL]([/color][/b]length BlksLst[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]princ [b][color=PURPLE]([/color][/b]strcat [color=#2f4f4f]"\nMoving on to the next block, "[/color] [b][color=TEAL]([/color][/b]itoa [b][color=OLIVE]([/color][/b]setq c [b][color=GRAY]([/color][/b]1- c[b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b] [color=#2f4f4f]" remaining!"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]sssetfirst nil nil[b][color=RED])[/color][/b][color=#8b4513]; ungrip it[/color] [b][color=RED]([/color][/b]ssdel [b][color=PURPLE]([/color][/b]vlax-vla-object->ename b[b][color=PURPLE])[/color][/b] TempSS[b][color=RED])[/color][/b] [b][color=BLUE])[/color][/b][color=#8b4513]; foreach[/color] [b][color=GREEN])[/color][/b][color=#8b4513]; progn[/color] [b][color=MAROON])[/color][/b][color=#8b4513]; if SSX-Lst[/color] [b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\nCongratulations, you are done!"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]vla-ZoomExtents [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][color=#8b4513]; not sure how to restore the zoom to the original state[/color] [b][color=MAROON]([/color][/b]vla-Regen [b][color=GREEN]([/color][/b]vla-get-ActiveDocument [b][color=BLUE]([/color][/b]vlax-get-acad-object[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] acActiveViewport[b][color=MAROON])[/color][/b] [b][color=NAVY])[/color][/b][color=#8b4513]; progn[/color] [b][color=FUCHSIA])[/color][/b][color=#8b4513]; if [b][color=FUCHSIA]([/color][/b]and e enx o[b][color=FUCHSIA])[/color][/b][/color] [b][color=FUCHSIA]([/color][/b]mapcar '[b][color=NAVY]([/color][/b]lambda [b][color=MAROON]([/color][/b] n v / [b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setvar n v[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'car SysVarLst[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]mapcar 'cadr SysVarLst[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if sUndo [b][color=NAVY]([/color][/b]vla-EndUndoMark [b][color=MAROON]([/color][/b]vla-get-ActiveDocument [b][color=GREEN]([/color][/b]vlax-get-acad-object[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b] [b][color=BLACK])[/color][/b][color=#8b4513];| defun |; [b][color=BLACK]([/color][/b]vl-load-com[b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]princ[b][color=BLACK])[/color][/b][/color] A couple of questions appeared: Is it possible to restore the original "zoomwindow" state, before calling the routine? Any comments, how to properly set the "undo" operation and the UndoMark, within the *error* defun? It was interesting to write this, and perhaps LM's code does a better job. THank you for posting. Unfortunately I didn't say that I am also using ACAD on Mac, and after some googling, I realized that some of these LISP routines will not run. I really appreciate you taking the time to write this though. I wish I could test. Quote
Grrr Posted September 4, 2016 Posted September 4, 2016 THank you for posting. Unfortunately I didn't say that I am also using ACAD on Mac, and after some googling, I realized that some of these LISP routines will not run. I really appreciate you taking the time to write this though. I wish I could test. I'm sure that Lee Mac could do this to work on your Mac. as I'm guessing/remembering that visual lisp is not supported on Mac OS. Quote
MTE20112 Posted September 4, 2016 Author Posted September 4, 2016 I'm sure that Lee Mac could do this to work on your Mac. as I'm guessing/remembering that visual lisp is not supported on Mac OS. I hope so! I found this online ;; Formerly TIP 1011: ME.LSP (C)1994, Gary Goode ;; (I've changed the name to DD.LSP and changed the defun to DD, B.K.) ;This program will let you pick and edit multi text and attributes ;by window, pick or crossing using dialog boxes. ;----------------------------------------------------------------- (defun C:DD (/ A B C D E F G H J K L M ) (graphscr) (setvar "BLIPMODE" 0) (setvar "CMDECHO" 0) (setvar "HIGHLIGHT" 1) (prompt "\nMulti-Edit is loaded ... ") (setq A (ssget) B (sslength A) C 0) (while (< C B) (setq D (ssname A C) E (entget D)) (setq F (car E)) (setq G (cdr E)) (setq H (car G)) (setq J (cdr H)) (setq K "TEXT") (setq L "INSERT") (setq M "DIMENSION") (if (= J K)(command ".ddedit" D "")) (if (= J L)(command ".ddatte" D )) (if (= J M)(prompt "\n You picked a dimension, I only do text or attributes ..."))(terpri) (setq C (1+ C))) (princ) ); end me.lsp That does work on MAC, and it does do the job, but I have to manually go around the entire drawing and select all the blocks I would like to work on. It is also older, I'm sure anything you or Lee (or others) can do would be more streamlined. Thank you Quote
MTE20112 Posted September 5, 2016 Author Posted September 5, 2016 THank you to LEE MAC - and others who helped me solve this and get a working solution for MAC. This has been wonderful. Quote
BIGAL Posted September 5, 2016 Posted September 5, 2016 If you only want blocks a crude patch (setq A (ssget (list (cons 0 "INSERT"))) You can expand to pick one block name only as I mentioned in my earlier post it should work on the MAC. I thought I would let you figure it out hint replace ss with A 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.