narendra Posted September 18, 2014 Share Posted September 18, 2014 Hi, let me thank you all for your help in previous postings..........now I came with another issue an auto cad drawings with lot of texts have been provided by client and he is asking to put all the text on grid and snap (grid1 and snap1) ...which was not placed on grid and snap earlier. If any one have routine to put all text on grid at a time please provide me. Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted September 18, 2014 Share Posted September 18, 2014 (defun C:FIXTEXT ( / *error* acDoc round ss d) (defun round (n) (* d (fix (+ 0.5 (/ (abs n) d))) (if (minusp n) -1 1))) (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))) (defun *error* (msg) (and msg (not (wcmatch (strcase msg) "*EXIT*,*QUIT*,*CANCEL*")) (princ (strcat "\nError: " msg)) ) (vla-endundomark acDoc) (princ) ) (if (and (setq ss (ssget ":L" '((0 . "TEXT")))) (progn (initget 6) (setq d (getdist "\nSnap value: ")) ) ) (repeat (setq i (sslength ss)) (entmod (mapcar (function (lambda (x) (if (<= 10 (car x) 11) (cons (car x) (mapcar 'round (cdr x))) x ) ) ) (entget (ssname ss (setq i (1- i)))) ) ) ) ) (vla-endundomark acDoc) (princ) ) Quote Link to comment Share on other sites More sharing options...
rkent Posted September 18, 2014 Share Posted September 18, 2014 Stefan BMR - I loaded this in my drawing and got an error message, error: syntax error. Any ideas on how to fix it? Thanks, rkent Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted September 18, 2014 Share Posted September 18, 2014 Stefan BMR - I loaded this in my drawing and got an error message, error: syntax error. Any ideas on how to fix it? Thanks, rkent I could not reproduce the error. Started a fresh new ACAD session an copied the code from my post. It works OK. Quote Link to comment Share on other sites More sharing options...
rkent Posted September 18, 2014 Share Posted September 18, 2014 I had changed the name to FIXTEXT TO SNAP, so when I put it back to what you provided it works fine. Can this include MTEXT as well as TEXT? Thanks. Quote Link to comment Share on other sites More sharing options...
asos2000 Posted September 18, 2014 Share Posted September 18, 2014 This routine moves selected objects to be on grid (defun c:round ( / e i k l m s ) ;LEE MAC (setq l '( ("CIRCLE" 10 40) ("LINE" 10 11) ("LWPOLYLINE" 10) ("INSERT" 10) ("POINT" 10) ) ) (if (null *tol*) (setq *tol* 5.0) ) (initget 6) (if (setq m (getreal (strcat "\nSpecify rounding tolerance <" (rtos *tol*) ">: "))) (setq *tol* m) (setq m *tol*) ) (if (setq s (ssget "_:L" '((0 . "CIRCLE,LINE,LWPOLYLINE,INSERT,POINT")))) (repeat (setq i (sslength s)) (if (setq e (entget (ssname s (setq i (1- i)))) k (cdr (assoc (cdr (assoc 0 e)) l)) ) (entmod (rounddxf k m e)) ) ) ) (princ) ) (defun rounddxf ( key mod lst / rtn ) (foreach itm lst (if (member (car itm) key) (setq rtn (cons (cons (car itm) (roundvalue (cdr itm) mod)) rtn)) (setq rtn (cons itm rtn)) ) ) (reverse rtn) ) (defun roundvalue ( val mod ) (if (listp val) (mapcar '(lambda ( x ) (round x mod)) val) (round val mod) ) ) ;; Doug Broad (defun round ( value to ) (setq to (abs to)) (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to))) ) (princ) Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted September 19, 2014 Share Posted September 19, 2014 ... Can this include MTEXT as well as TEXT? Of course kent. Change (0 . "TEXT") to (0 . "*TEXT") or (0 . "TEXT,MTEXT"). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 20, 2014 Share Posted September 20, 2014 This routine moves selected objects to be on grid Thank you for the recommendation Hasan - The program can be used with Text & MText by adding the following lines to the list at the top of the code: (defun c:round ( / e i k l m s ) ; LEE MAC (setq l '( ("CIRCLE" 10 40) ("LINE" 10 11) ("LWPOLYLINE" 10) ("INSERT" 10) ("POINT" 10) [color=red] ("MTEXT" 10) ("TEXT" 10 11)[/color] ) ) ... ) Quote Link to comment Share on other sites More sharing options...
asos2000 Posted September 20, 2014 Share Posted September 20, 2014 Thank you for the recommendation Hasan - It is my pleasure Lee Quote Link to comment Share on other sites More sharing options...
narendra Posted September 21, 2014 Author Share Posted September 21, 2014 Thank you stefan BMR, RKENT, LEE MAC, ASOS 2000. for your effort and help,you all my made my work easy.......thanks........ Quote Link to comment Share on other sites More sharing options...
narendra Posted September 21, 2014 Author Share Posted September 21, 2014 Thank you for resolving how to move text on grid...while doing this I got thought is this routine can be changed to move blocks along with attribute text. ASOS 2000, round routine is only moving blocks but not text. Obviously he made routine to move only objects not blocks... Quote Link to comment Share on other sites More sharing options...
mostafa badran Posted September 21, 2014 Share Posted September 21, 2014 (edited) I think is there a missing in ssget syntax. (if (setq s (ssget "_:L" '((0 . "CIRCLE,LINE,LWPOLYLINE,INSERT,POINT,[color=red]MTEXT,[/color][color=red]TEXT[/color]")))) Edited September 21, 2014 by mostafa badran misunderstand Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 21, 2014 Share Posted September 21, 2014 I think is there a missing in ssget syntax. (if (setq s (ssget "_:L" '((0 . "CIRCLE,LINE,LWPOLYLINE,INSERT,POINT,[color=red]MTEXT,[/color][color=red]TEXT[/color]")))) Yes, this is also required - thank you. 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.