GlnGrnr Posted May 8, 2013 Share Posted May 8, 2013 (edited) Hi all, I am currently trying to learn lisp when time allows and have not gotten very far, I have this lisp routine (see below), which allows me to select an object in this case I need to select the rotated dimensions in a drawing, all of them and remove all the xdata, I cannot seem to work out how to get it to allow my to select more than one at a time, or even to select all the rotated dimensions in the drawing, i have tried a variety of ssget functions and cons etc but cant seem to get it right, i always have too few arguments or a bad argument, any help would be grateful (defun c:stripdim() (setq l (car (entsel "Pick object:"))) (if l (progn (redraw l 3) (setq le (entget l '("*")) ) (setq xdata (assoc '-3 le)) (setq le (subst (cons (car xdata) (list (list (car (car (cdr xdata)))))) xdata le)) (entmod le) (redraw l 4) le ) ) ) Edited May 8, 2013 by SLW210 Added Code Tags! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2013 Share Posted May 8, 2013 Try this [ UNTESTED ] routine . Be careful to have the dimensions on UNLOCKED layers . (defun c:Test (/ RemoveXdata ss i e sn) ;;--- Tharwat 08. May. 2013 ---;; (defun RemoveXdata (ent / app) (if (eq (type ent) 'ENAME) (if (setq app (assoc -3 (entget ent '("*")))) (entmod (append (entget ent) (list (list -3 (list (car (cadr app))))))) ) ) (princ) ) (if (setq ss (ssget "_X" '((0 . "*DIMENSION")))) (repeat (setq i (sslength ss)) (setq e (entget (setq sn (ssname ss (setq i (1- i)))))) (if (member '(100 . "AcDbRotatedDimension") e) (RemoveXdata sn) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 8, 2013 Author Share Posted May 8, 2013 @ Tharwat worked brilliantly, thanks you so very much, and completely different to how i was trying to solve it, thanks again Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2013 Share Posted May 8, 2013 @ Tharwat worked brilliantly, thanks you so very much, and completely different to how i was trying to solve it, thanks again Waw excellent , you're welcome Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 8, 2013 Share Posted May 8, 2013 (if (setq app (assoc -3 (entget ent '("*")))) (entmod (append (entget ent) (list (list -3 (list (car (cadr app))))))) ) Tharwat, Note that your program will only remove the xData for the first AppID found, not all xData as the OP has requested: I need to select the rotated dimensions in a drawing, all of them and remove all the xdata Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 8, 2013 Author Share Posted May 8, 2013 @ Lee Mac, this isnt an issue in this case as all the dimensions have the same AppID but since you pointed that out how would we enable it to allow for more AppID's Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2013 Share Posted May 8, 2013 Tharwat, Note that your program will only remove the xData for the first AppID found, not all xData as the OP has requested: I have just attached xdata to Mtexts and tried my routine on them , and it did remove all the xdata . I did not search for a specific AppID to remove ( as you for sure do know ) , so that stepped through all of them . Can you shine the light on your codes / idea a little bit more ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 8, 2013 Share Posted May 8, 2013 I did not search for a specific AppID to remove ( as you for sure do know ) , so that stepped through all of them . Yes you did, in this expression: (entmod (append (entget ent) (list (list -3 (list (car (cadr app))))))) Can you shine the light on your codes / idea a little bit more ? Try your 'RemoveXData' function with the Line created by the following program: (defun c:makeline ( ) (regapp "app1") (regapp "app2") (regapp "app3") (entmake '( (0 . "LINE") (10 0 0 0) (11 1 0 0) (-3 ("app1" (1000 . "value1")) ("app2" (1000 . "value2")) ("app3" (1000 . "value3")) ) ) ) (princ) ) Note that only the xData for 'app1' is removed. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 8, 2013 Share Posted May 8, 2013 Okay , nice approach Lee , and I did not know that we can attach more than one AppID to one object . So if we replaced the if function with while function in my previous routine , that would solve the issue . Much appreciated . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 8, 2013 Share Posted May 8, 2013 You're welcome Tharwat. For what its worth, here is how I would approach the task: ([color=BLUE]defun[/color] c:stripdim ( [color=BLUE]/[/color] e i s ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '( (0 . [color=MAROON]"DIMENSION"[/color]) (-4 . [color=MAROON]"<OR"[/color]) (70 . 032) (70 . 064) (70 . 096) (70 . 128) (70 . 160) (70 . 192) (70 . 224) (-4 . [color=MAROON]"OR>"[/color]) (-3 ([color=MAROON]"*"[/color])) ) ) ) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]entmod[/color] ([color=BLUE]append[/color] ([color=BLUE]entget[/color] ([color=BLUE]setq[/color] e ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))))) ([color=BLUE]list[/color] ([color=BLUE]cons[/color] -3 ([color=BLUE]mapcar[/color] '[color=BLUE]list[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]car[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] -3 ([color=BLUE]entget[/color] e '([color=MAROON]"*"[/color])))))))) ) ) ) ([color=BLUE]princ[/color]) ) ) Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 8, 2013 Author Share Posted May 8, 2013 Both work brilliantly guys, thanks again. made my life easier thats for sure, might even have given me a bit of free time to learn a bit more on lsps, oh the irony:D:D Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 31, 2013 Author Share Posted May 31, 2013 Tharwat, Lee Mac, Thanks again for your help on this project I posted earlier, Is there a way I can set up the same code to only pick one specific App_ID as apposed to any dimension with any app_ID so for exmaple i want to select all the rotated dimensions in the drawing but only the ones that have this ID ( Registered Application Name: STPL_DimText) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 31, 2013 Share Posted May 31, 2013 (edited) Is there a way I can set up the same code to only pick one specific App_ID as apposed to any dimension with any app_ID so for exmaple i want to select all the rotated dimensions in the drawing but only the ones that have this ID ( Registered Application Name: STPL_DimText) Try this and let me know how things are going on with you . CODES REMOVED . Edited May 31, 2013 by Tharwat Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 31, 2013 Author Share Posted May 31, 2013 i tried to edit your previous script, which seemed to work well, (defun c:StripDT (/ RemoveXdata ss i e sn) (alert "removing intelligence from Dim Text") (defun RemoveXdata (ent / app) (if (eq (type ent) 'ENAME) (if (setq app (assoc -3 (entget ent '("STPL_DimText")))) (entmod (append (entget ent) (list (list -3 (list (car (cadr app))))))) ) ) (princ) ) (if (setq ss (ssget "_X" '((0 . "*DIMENSION")))) (repeat (setq i (sslength ss)) (setq e (entget (setq sn (ssname ss (setq i (1- i)))))) (if (member '(100 . "AcDbRotatedDimension") e) (RemoveXdata sn) ) ) ) (princ) (alert "complete") ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 31, 2013 Share Posted May 31, 2013 i tried to edit your previous script, which seemed to work well, First use the CODE TAG # as shown in the reply space to obtain codes within . Second , didn't the last code in post No. 13 helped you according to your new request in post No. 12 ? Quote Link to comment Share on other sites More sharing options...
GlnGrnr Posted May 31, 2013 Author Share Posted May 31, 2013 I tried the code you posted in 'post13' and it didnt seem to work, the xdata was still attached to the dimension, it also did not select all the dimensions in the drawing it asked for me to select them individually? however my 'Botched' edit of your original script seems to have done the trick and so far with a bit of testing I have yet to find a fault in how it works, it selects all the dimensions then removes the xdata from the dimensions with the app_ID of STPL_DimText. so thanks again on both fronts Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 31, 2013 Share Posted May 31, 2013 I tried the code you posted in 'post13' and it didnt seem to work, the xdata was still attached to the dimension, it also did not select all the dimensions in the drawing it asked for me to select them individually? however my 'Botched' edit of your original script seems to have done the trick and so far with a bit of testing I have yet to find a fault in how it works, it selects all the dimensions then removes the xdata from the dimensions with the app_ID of STPL_DimText. so thanks again on both fronts Okay , I see now , actually the code that I posted in Reply No 13 was to select only rotated Dimensions that have a specific AppID . Anyway I am happy that the modification on my previous code helped you with it Good luck . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 31, 2013 Share Posted May 31, 2013 I recommend: ([color=BLUE]defun[/color] c:deldimxd ( [color=BLUE]/[/color] i s ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '((0 . [color=MAROON]"*DIMENSION"[/color]) (-3 ([color=MAROON]"STPL_DimText"[/color]))))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]entmod[/color] ([color=BLUE]append[/color] ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) '((-3 ([color=MAROON]"STPL_DimText"[/color]))))) ) ) ([color=BLUE]princ[/color]) ) Or, for rotated dimensions only: ([color=BLUE]defun[/color] c:deldimxd ( [color=BLUE]/[/color] i s ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '( (0 . [color=MAROON]"DIMENSION"[/color]) (-4 . [color=MAROON]"<OR"[/color]) (70 . 032) (70 . 064) (70 . 096) (70 . 128) (70 . 160) (70 . 192) (70 . 224) (-4 . [color=MAROON]"OR>"[/color]) (-3 ([color=MAROON]"STPL_DimText"[/color])) ) ) ) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]entmod[/color] ([color=BLUE]append[/color] ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) '((-3 ([color=MAROON]"STPL_DimText"[/color]))))) ) ) ([color=BLUE]princ[/color]) ) 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.