wimal Posted October 28, 2013 Posted October 28, 2013 Thanks Mr.jdiala. You have shown me the correct path to learn about that function. And even thanks Mr.Lee Quote
3dwannab Posted October 28, 2013 Author Posted October 28, 2013 Thanks everyone for your help. Hopefully this routine will help lots of people. Quote
3dwannab Posted May 16, 2014 Author Posted May 16, 2014 Note: the above is incompatible with dynamic block references. Hi Lee, I was wondering if you know a way for this to work with DYN block references now? Thanks in advance. Quote
Lee Mac Posted May 17, 2014 Posted May 17, 2014 (edited) I was wondering if you know a way for this to work with DYN block references now? Thanks in advance. Try this quick mod: ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] blk enx idx itm lst ref sel tmp ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] ([color=BLUE]list[/color] ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport)) ([color=BLUE]cons[/color] 410 ([color=BLUE]getvar[/color] 'ctab)) '(410 . [color=MAROON]"Model"[/color]) ) ) ) ) ([color=BLUE]progn[/color] ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] idx ([color=BLUE]sslength[/color] sel)) ([color=BLUE]setq[/color] enx ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] idx ([color=BLUE]1-[/color] idx))))) ([color=BLUE]if[/color] ([color=BLUE]equal[/color] '(0 . [color=MAROON]"INSERT"[/color]) ([color=BLUE]assoc[/color] 0 enx)) ([color=BLUE]setq[/color] blk (LM:name->effectivename ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 enx))) itm ([color=BLUE]list[/color] '(-4 . [color=MAROON]"<AND"[/color]) '(0 . [color=MAROON]"INSERT"[/color]) ([color=BLUE]cons[/color] 2 ([color=BLUE]cond[/color] ( ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] blk tmp))) ( ([color=BLUE]setq[/color] ref ([color=BLUE]strcat[/color] blk ([color=BLUE]apply[/color] '[color=BLUE]strcat[/color] ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]strcat[/color] [color=MAROON]",`"[/color] x)) (LM:getanonymousreferences blk)))) tmp ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] blk ref) tmp) ) ref ) ) ) ([color=BLUE]assoc[/color] 8 enx) '(-4 . [color=MAROON]"AND>"[/color]) ) ) ([color=BLUE]setq[/color] itm ([color=BLUE]list[/color] '(-4 . [color=MAROON]"<AND"[/color]) ([color=BLUE]assoc[/color] 0 enx) ([color=BLUE]assoc[/color] 8 enx) '(-4 . [color=MAROON]"AND>"[/color]) ) ) ) ([color=BLUE]or[/color] ([color=BLUE]member[/color] itm lst) ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] itm lst)) ) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]apply[/color] '[color=BLUE]ssget[/color] ([color=BLUE]append[/color] '([color=MAROON]"_C"[/color]) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]trans[/color] x 0 1)) (LM:ViewportExtents)) ([color=BLUE]list[/color] ([color=BLUE]append[/color] '((-4 . [color=MAROON]"<OR"[/color])) ([color=BLUE]apply[/color] '[color=BLUE]append[/color] lst) '((-4 . [color=MAROON]"OR>"[/color])) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport)) ([color=BLUE]list[/color] ([color=BLUE]cons[/color] 410 ([color=BLUE]getvar[/color] 'ctab))) '((410 . [color=MAROON]"Model"[/color])) ) ) ) ) ) ) ([color=BLUE]command[/color] [color=MAROON]"_.isolateobjects"[/color] sel [color=MAROON]""[/color]) ) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; Get Anonymous References - Lee Mac[/color] [color=GREEN];; Returns the names of all anonymous references of a block.[/color] [color=GREEN];; blk - [str] Block name for which to return anon. references[/color] ([color=BLUE]defun[/color] LM:getanonymousreferences ( blk [color=BLUE]/[/color] ano def lst rec ref ) ([color=BLUE]setq[/color] blk ([color=BLUE]strcase[/color] blk)) ([color=BLUE]while[/color] ([color=BLUE]setq[/color] def ([color=BLUE]tblnext[/color] [color=MAROON]"block"[/color] ([color=BLUE]null[/color] def))) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]logand[/color] 1 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 70 def)))) ([color=BLUE]setq[/color] rec ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 ([color=BLUE]entget[/color] ([color=BLUE]tblobjname[/color] [color=MAROON]"block"[/color] ([color=BLUE]setq[/color] ano ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 def))) ) ) ) ) ) ) ) ([color=BLUE]while[/color] ([color=BLUE]and[/color] ([color=BLUE]not[/color] ([color=BLUE]member[/color] ano lst)) ([color=BLUE]setq[/color] ref ([color=BLUE]assoc[/color] 331 rec)) ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] ref ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ref))) ([color=BLUE]=[/color] blk ([color=BLUE]strcase[/color] (LM:name->effectivename ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 ref))))) ) ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ano lst)) ) ([color=BLUE]setq[/color] rec ([color=BLUE]cdr[/color] ([color=BLUE]member[/color] ([color=BLUE]assoc[/color] 331 rec) rec))) ) ) ) ([color=BLUE]reverse[/color] lst) ) [color=GREEN];; Block Name -> Effective Block Name - Lee Mac[/color] [color=GREEN];; blk - [str] Block name[/color] ([color=BLUE]defun[/color] LM:name->effectivename ( blk [color=BLUE]/[/color] rep ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]wcmatch[/color] blk [color=MAROON]"`**"[/color]) ([color=BLUE]setq[/color] rep ([color=BLUE]cdadr[/color] ([color=BLUE]assoc[/color] -3 ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 ([color=BLUE]entget[/color] ([color=BLUE]tblobjname[/color] [color=MAROON]"block"[/color] blk)))) '([color=MAROON]"AcDbBlockRepBTag"[/color]) ) ) ) ) ([color=BLUE]setq[/color] rep ([color=BLUE]handent[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1005 rep)))) ) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 ([color=BLUE]entget[/color] rep))) blk ) ) [color=GREEN];; Viewport Extents - Lee Mac[/color] [color=GREEN];; Returns two WCS points describing the lower-left and[/color] [color=GREEN];; upper-right corners of the active viewport.[/color] ([color=BLUE]defun[/color] LM:ViewportExtents ( [color=BLUE]/[/color] c h v ) ([color=BLUE]setq[/color] c ([color=BLUE]trans[/color] ([color=BLUE]getvar[/color] 'viewctr) 1 0) h ([color=BLUE]/[/color] ([color=BLUE]getvar[/color] 'viewsize) 2.0) v ([color=BLUE]list[/color] ([color=BLUE]*[/color] h ([color=BLUE]apply[/color] '[color=BLUE]/[/color] ([color=BLUE]getvar[/color] 'screensize))) h) ) ([color=BLUE]list[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]-[/color] c v) ([color=BLUE]mapcar[/color] '[color=BLUE]+[/color] c v)) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Edited May 22, 2014 by Lee Mac Fixed bug Quote
3dwannab Posted May 21, 2014 Author Posted May 21, 2014 Try this quick mod: Hi Lee, thanks for this. Sorry I didn't get back as I was off ill. I've tried that but I get the error for DYN attribute blocks. Select objects: ; error: bad SSGET list value in the command line. It works for DYN blocks but its a little slow to finish the command. Roughly 5-7 seconds per command. 'Normal' objects are working just as fast. Quote
Lee Mac Posted May 22, 2014 Posted May 22, 2014 I've tried that but I get the error for DYN attribute blocks. Select objects: ; error: bad SSGET list value in the command line. Are you able to post a drawing containing a sample dynamic block for which the program is failing - I have tried the updated program with attributed dynamic blocks and cannot seem to get the program to fail. Lee Quote
3dwannab Posted May 22, 2014 Author Posted May 22, 2014 Are you able to post a drawing containing a sample dynamic block for which the program is failing - I have tried the updated program with attributed dynamic blocks and cannot seem to get the program to fail. Lee Oh, strange maybe if you send me your file too. Here's a different test file I created which gives the same error. DYN ATT test file.dwg Quote
Lee Mac Posted May 22, 2014 Posted May 22, 2014 Oh, strange maybe if you send me your file too. Here's a different test file I created which gives the same error.[ATTACH]49063[/ATTACH] Thanks 3dwannab - I have edited the above code to hopefully fix the issue. Lee Quote
3dwannab Posted May 22, 2014 Author Posted May 22, 2014 Thanks 3dwannab - I have edited the above code to hopefully fix the issue. Lee Lee, I can't thank you enough for your efforts. You are a credit to the community. One small change I made was to change the line: (command "_.isolateobjects" sel "") to: (command "_.pselect" sel "") This works better for my workflow from here I can press shortcuts I've setup SHIFT+H to hide or CTRL+ALT+E to isolate the selection made. EDIT: I will test on the same file that was slow to run the LISP and report back to you Quote
Lee Mac Posted May 22, 2014 Posted May 22, 2014 Lee, I can't thank you enough for your efforts. You are a credit to the community. Thank you 3dwannab, that's very kind of you to say One small change I made was to change the line: (command "_.isolateobjects" sel "") to: (command "_.pselect" sel "") This works better for my workflow from here I can press shortcuts I've setup SHIFT+H to hide or CTRL+ALT+E to isolate the selection made. No problem - the program could be configured to perform any action you wish on the resulting selection set by simply exchanging the line you have quoted above. Rather than using the PSELECT command, you could also use the following the highlight the selection: (sssetfirst nil sel) EDIT: I will test on the same file that was slow to run the LISP and report back to you The performance hit could be a result of the method I am using the obtain all (anonymous) references of any dynamic blocks in the initial selection - this involves iterating over all blocks defined in the drawing (which could be quite a few for large drawings). Quote
3dwannab Posted May 22, 2014 Author Posted May 22, 2014 Rather than using the PSELECT command, you could also use the following the highlight the selection: (sssetfirst nil sel) Thanks, I've done some more testing and it seems that it intermittently doesn't highlight the objects even though in the properties dialog it shows as been whatever number selected. Then if I click anywhere inside modelspace viewport they become selected. (See screen-shots attached). It's a minor bug but I'm sure I can live with that. I have done in the past with the old one but I thought you might want to know. The performance hit could be a result of the method I am using the obtain all (anonymous) references of any dynamic blocks in the initial selection - this involves iterating over all blocks defined in the drawing (which could be quite a few for large drawings). No problem. Being one of my most used scripts it's a small price to pay for what is to me an invaluable tool. Quote
3dwannab Posted May 23, 2014 Author Posted May 23, 2014 I've fixed the problem with the screen not refreshing sometimes after the LISP has run by changing: (sssetfirst nil sel) ;;(command "_.pselect" sel "") ) ) ) (princ) ) To: (sssetfirst nil sel) ;;(command "_.pselect" sel "") ) (command "._REGEN" "") ) ) (princ) ) Quote
Lee Mac Posted May 24, 2014 Posted May 24, 2014 Thanks, I've done some more testing and it seems that it intermittently doesn't highlight the objects even though in the properties dialog it shows as been whatever number selected. Then if I click anywhere inside modelspace viewport they become selected. Since the code is simply obtaining the relevant selection set and passing this selection set to the sssetfirst function to be selected & gripped, I would guess that the intermittent behaviour that you are experiencing is caused either by a bug in AutoCAD or perhaps by another selection being active when the sssetfirst function is evaluated, causing some interference. I've fixed the problem with the screen not refreshing sometimes after the LISP has run by changing: (sssetfirst nil sel) ;;(command "_.pselect" sel "") ) ) ) (princ) ) To: (sssetfirst nil sel) ;;(command "_.pselect" sel "") ) (command "._REGEN" "") ) ) (princ) ) Although regenerating all objects in the active layout is not ideal (especially for larger drawings), I'm glad you were able to find a solution. Though, I would suggest incorporating the call to the REGEN command within the 'then' argument for the if function, so that the drawing is not unnecessarily regenerated when no selection is obtained, i.e.: (progn (sssetfirst nil sel) (command "_.regen") ) (a minor point) Quote
3dwannab Posted May 25, 2014 Author Posted May 25, 2014 Thanks, I always thought there was a difference between RE (Regen) and REA (Regen All) And from the help files it says regen only refreshes all objects the current visable viewport (which i think is only what you see) but regenall does all veiwports. See: http://autode.sk/1h2xYjf. Maybe I'm picking it up wrong I trying to learn a bit about LISPs and here's my code now: (progn (sssetfirst nil sel) (princ (strcat "\n" (if sel (itoa (sslength sel)) "0") " Entities Selected.\n")) ) ((command "_.regen") (princ)) ) ) ) (princ) I know the regen command is not within the 'then' argument for the if function but what I was tring to do is hide the command regen from showing up in the CAD commandline. I've also added a code to let me know how many objects are selected. How to you suppress the regen command within the then argument. I've tried doing so but can get it to work. Quote
Lee Mac Posted May 25, 2014 Posted May 25, 2014 Perhaps something like this: (progn (sssetfirst nil sel) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.regen") (setvar 'cmdecho cmd) (princ (strcat "\n" (itoa (sslength sel)) " object(s) selected.")) ) (princ "\nNo objects selected.") And add the cmd symbol to the list of declared local variables. Quote
3dwannab Posted May 25, 2014 Author Posted May 25, 2014 Perhaps something like this: (progn (sssetfirst nil sel) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.regen") (setvar 'cmdecho cmd) (princ (strcat "\n" (itoa (sslength sel)) " object(s) selected.")) ) (princ "\nNo objects selected.") And add the cmd symbol to the list of declared local variables. Great, I'm getting an understanding of what the local variables job is. BTW I did try the cmdecho but in a different way using the command method instead of setvar but it didn't work. Thanks very much for your help in this matter Lee. Greatly appreciated. Quote
Lee Mac Posted May 25, 2014 Posted May 25, 2014 Great, I'm getting an understanding of what the local variables job is. BTW I did try the cmdecho but in a different way using the command method instead of setvar but it didn't work. Thanks very much for your help in this matter Lee. Greatly appreciated. You're most welcome 3dwannab - I'm glad to hear you are learning along the way. Quote
3dwannab Posted November 7 Author Posted November 7 (edited) I modified Lee Macs code to select similar objects including the colour of the objects. See the updated code below, btw, this is probably my most used program!! Can't believe this thread started 11 years ago! ;; ;; Selects similar objects by layer and colour of the selected objects on screen. ;; I've added the line (assoc 62 enx) to get the same colour. Modified on 2024.11.07. ;; Original code by Lee Mac found here: https://www.cadtutor.net/forum/topic/48660-selecting-similar-to-what-is-visable-on-screen/?do=findComment&comment=433598 ;; (defun c:SSS (/) (c:Sel_Screen_Selected)) (defun c:Sel_Screen_Selected (/ blk enx idx itm lst ref sel tmp cmd) (if (setq sel (ssget (list (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq enx (entget (ssname sel (setq idx (1- idx))))) (if (equal '(0 . "INSERT") (assoc 0 enx)) (setq blk (LM:name->effectivename (cdr (assoc 2 enx))) itm (list '(-4 . "<AND") '(0 . "INSERT") (cons 2 (cond ((cdr (assoc blk tmp))) ((setq ref (strcat blk (apply 'strcat (mapcar '(lambda (x) (strcat ",`" x)) (LM:getanonymousreferences blk)))) tmp (cons (cons blk ref) tmp) ) ref ) ) ) (assoc 8 enx) '(-4 . "AND>") ) ) (setq itm (list '(-4 . "<AND") (assoc 0 enx) (assoc 8 enx) (assoc 62 enx) ;; edit by 3dwannb. Select the same colour also. '(-4 . "AND>") ) ) ) (or (member itm lst) (setq lst (cons itm lst)) ) ) (if (setq sel (apply 'ssget (append '("_C") (mapcar '(lambda (x) (trans x 0 1)) (LM:ViewportExtents)) (list (append '((-4 . "<OR")) (apply 'append lst) '((-4 . "OR>")) (if (= 1 (getvar 'cvport)) (list (cons 410 (getvar 'ctab))) '((410 . "Model")) ) ) ) ) ) ) (progn (sssetfirst nil sel) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.regen") (setvar 'cmdecho cmd) (princ (strcat "\n" (itoa (sslength sel)) " object(s) selected.")) ) (princ "\nNo objects selected.") ) ) ) (princ) ) ;; Get Anonymous References - Lee Mac ;; Returns the names of all anonymous references of a block. ;; blk - [str] Block name for which to return anon. references (defun LM:getanonymousreferences (blk / ano def lst rec ref) (setq blk (strcase blk)) (while (setq def (tblnext "block" (null def))) (if (and (= 1 (logand 1 (cdr (assoc 70 def)))) (setq rec (entget (cdr (assoc 330 (entget (tblobjname "block" (setq ano (cdr (assoc 2 def))) ) ) ) ) ) ) ) (while (and (not (member ano lst)) (setq ref (assoc 331 rec)) ) (if (and (setq ref (entget (cdr ref))) (= blk (strcase (LM:name->effectivename (cdr (assoc 2 ref))))) ) (setq lst (cons ano lst)) ) (setq rec (cdr (member (assoc 331 rec) rec))) ) ) ) (reverse lst) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename (blk / rep) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) ;; Viewport Extents - Lee Mac ;; Returns two WCS points describing the lower-left and ;; upper-right corners of the active viewport. (defun LM:ViewportExtents (/ c h v) (setq c (trans (getvar 'viewctr) 1 0) h (/ (getvar 'viewsize) 2.0) v (list (* h (apply '/ (getvar 'screensize))) h) ) (list (mapcar '- c v) (mapcar '+ c v)) ) (vl-load-com) (princ) ; (c:sss) ;; Unblock for testing Edited November 7 by 3dwannab Quote
3dwannab Posted November 7 Author Posted November 7 (edited) Mmh, I couldn't get this to work if the object's colour was by layer. So, in true fashion, I did it as best I could. ;| Selects similar objects by layer and colour of the selected objects on screen. Modified on 2024.11.07. - I've added the line (assoc 62 enx) to get the same colour. - If an object is selected with an overridden layer then only that colour will get selected that is similar. Original code by Lee Mac found here: https://www.cadtutor.net/forum/topic/48660-selecting-similar-to-what-is-visable-on-screen/?do=findComment&comment=433598 |; (defun c:SSS (/) (c:Sel_Screen_Selected)) (defun c:Sel_Screen_Selected (/ blk enx idx itm lst ref sel color tmp cmd) (if (setq sel (ssget (list (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq enx (entget (ssname sel (setq idx (1- idx))))) ;; Get the colour ;; If there's no colour (dxf 62) then just assign the color variable to the layername. Very hacky I know. ;; Nonetheless, this will select the ojects regardless of colour if the object selected is bylayer. ;; If an object is selected with an overridden layer then only that colour will get selected that is similar. (setq color (cdr (assoc 62 enx))) (if color (setq color (assoc 62 enx)) (setq color (assoc 8 enx)) ;; Assign the colour to the layer name. Hacky as heck this :( ) (if (equal '(0 . "INSERT") (assoc 0 enx)) (setq blk (LM:name->effectivename (cdr (assoc 2 enx))) itm (list '(-4 . "<AND") '(0 . "INSERT") (cons 2 (cond ((cdr (assoc blk tmp))) ((setq ref (strcat blk (apply 'strcat (mapcar '(lambda (x) (strcat ",`" x)) (LM:getanonymousreferences blk)))) tmp (cons (cons blk ref) tmp) ) ref ) ) ) (assoc 8 enx) color ;; edit by 3dwannb. Select the same colour also. '(-4 . "AND>") ) ) (setq itm (list '(-4 . "<AND") (assoc 0 enx) (assoc 8 enx) color ;; edit by 3dwannb. Select the same colour also. '(-4 . "AND>") ) ) ) (or (member itm lst) (setq lst (cons itm lst)) ) ) (if (setq sel (apply 'ssget (append '("_C") (mapcar '(lambda (x) (trans x 0 1)) (LM:ViewportExtents)) (list (append '((-4 . "<OR")) (apply 'append lst) '((-4 . "OR>")) (if (= 1 (getvar 'cvport)) (list (cons 410 (getvar 'ctab))) '((410 . "Model")) ) ) ) ) ) ) (progn (sssetfirst nil sel) (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (command "_.regen") (setvar 'cmdecho cmd) (princ (strcat "\n" (itoa (sslength sel)) " object(s) selected.")) ) (princ "\nNo objects selected.") ) ) ) (princ) ) ;; Get Anonymous References - Lee Mac ;; Returns the names of all anonymous references of a block. ;; blk - [str] Block name for which to return anon. references (defun LM:getanonymousreferences (blk / ano def lst rec ref) (setq blk (strcase blk)) (while (setq def (tblnext "block" (null def))) (if (and (= 1 (logand 1 (cdr (assoc 70 def)))) (setq rec (entget (cdr (assoc 330 (entget (tblobjname "block" (setq ano (cdr (assoc 2 def))) ) ) ) ) ) ) ) (while (and (not (member ano lst)) (setq ref (assoc 331 rec)) ) (if (and (setq ref (entget (cdr ref))) (= blk (strcase (LM:name->effectivename (cdr (assoc 2 ref))))) ) (setq lst (cons ano lst)) ) (setq rec (cdr (member (assoc 331 rec) rec))) ) ) ) (reverse lst) ) ;; Block Name -> Effective Block Name - Lee Mac ;; blk - [str] Block name (defun LM:name->effectivename (blk / rep) (if (and (wcmatch blk "`**") (setq rep (cdadr (assoc -3 (entget (cdr (assoc 330 (entget (tblobjname "block" blk)))) '("AcDbBlockRepBTag") ) ) ) ) (setq rep (handent (cdr (assoc 1005 rep)))) ) (cdr (assoc 2 (entget rep))) blk ) ) ;; Viewport Extents - Lee Mac ;; Returns two WCS points describing the lower-left and ;; upper-right corners of the active viewport. (defun LM:ViewportExtents (/ c h v) (setq c (trans (getvar 'viewctr) 1 0) h (/ (getvar 'viewsize) 2.0) v (list (* h (apply '/ (getvar 'screensize))) h) ) (list (mapcar '- c v) (mapcar '+ c v)) ) (vl-load-com) (princ) ; (c:sss) ;; Unblock for testing Edited November 7 by 3dwannab 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.