Sandeep RC Posted March 1, 2023 Posted March 1, 2023 CAN ANYBODY HELP ME FIND LISP WHICH MOVES MULTIPLE TEXTS IN X & Y AXIS DIRECTION BY SPECIFING X & Y VALUE WHICH I WANT? PLEASE REFER IMAGE AND CAD FILE ATTACHED. FOR EXAMPLE IF I WANT TO MOVE A TEXT (+X = 100) & (+Y = 150) THEN BASED ON ITS CURRENT ROTATION ANGLE ALL TEXTS SHOULD MOVE BY THE XY DISTANCE SPECIFIED. SAMPLE.dwg Quote
fuccaro Posted March 1, 2023 Posted March 1, 2023 How do you wish to operate that Lisp? select a text and enter from the keybord the X and Y offsets? Can you please avoid ALL CAPS in your messages? Quote
devitg Posted March 1, 2023 Posted March 1, 2023 (edited) @Sandeep RC Please give it a test . The CAPITAL LETTERS, at LISP CODE , do not mean I'm yelling. ;;******************************************************************************************************** (DEFUN CODE/cod-ent (COD ENT) ;-001 (CDR (ASSOC COD (ENTGET ENT))) ) ;;************************************************************ (DEFUN MOVE-TEXT-X-Y (/ ACAD-OBJ ADOC MODEL TEXT TEXT-10 TEXT-50 TEXT-OBJ X X+100 X-Y Y ) (VL-LOAD-COM) (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ el programa ACAD (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ el DWG que esta abierto- (SETQ MODEL (VLA-GET-MODELSPACE ADOC)) (SETQ TEXT (SSNAME (SSGET "_:S+." '((0 . "text"))) 0)) (SETQ X 100) (SETQ Y 150) (SETQ TEXT-10 (CODE/COD-ENT 10 TEXT)) (SETQ TEXT-50 (CODE/COD-ENT 50 TEXT)) (SETQ X+100 (POLAR TEXT-10 TEXT-50 X)) (SETQ X-Y (POLAR X+100 (+ TEXT-50 (/ PI 2)) Y)) (SETQ TEXT-OBJ (VLAX-ENAME->VLA-OBJECT TEXT)) (VLA-MOVE TEXT-OBJ (VLAX-3D-POINT TEXT-10) (VLAX-3D-POINT X-Y)) ) Edited March 1, 2023 by devitg ad image Quote
BIGAL Posted March 1, 2023 Posted March 1, 2023 Another way is set UCS temporarily to Object then its a simple move. (defun c:wow ( / txtent txtentg x y) (setq txtent (entsel "\nPick text ")) (setq txtentg (entget (car txtent))) (command "UCS" "OB" (car txtent)) (setq x 50 y 50) (setq pt (list x y)) (command "move" txtent "" "0,0" pt) (command "UCS" "W") (princ) ) (c:wow) 1 Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 (edited) @fuccaro , Okay I will take care of it from next time. No all Caps, noted. yes, after selecting all the texts, command should prompt me for XY offset values of my choice. and after putting that, all the text should move accordingly. Edited March 2, 2023 by Sandeep RC Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 (edited) @BIGAL Ok, this is working as intended. But how can I get this to work on multiple texts at the same time? Also I will appreciate if the command prompts me for XY values. Edited March 2, 2023 by Sandeep RC Quote
BIGAL Posted March 2, 2023 Posted March 2, 2023 Good time to start learning lisp. You use SSGET to select multiple text. enter X & Y Then a repeat for each item in the selection set do my code here. end repeat Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 (edited) @BIGAL I tried searching on internet and did some changes accordingly, but I couldn't get it work. Edited March 2, 2023 by Sandeep RC Quote
Steven P Posted March 2, 2023 Posted March 2, 2023 Can you post what you did Sandeep, maybe we can suggest what went wrong... then you'll be able to do it next time!! (far better than just being given a solution) Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 @Steven P I deleted in the frustration. 1 Quote
Steven P Posted March 2, 2023 Posted March 2, 2023 Don't do that!! If you have nearly got it working usually it is only a small thing to make it work Quote
Steven P Posted March 2, 2023 Posted March 2, 2023 This is a basic selection set function, put your stuff in where it says "Do Stuff Here" You might need to adjust a few other things to make it all work, for example in BigAls code above you can change (car txtent) to just txtent, and you'll need to change either txtent (from BigAl) or MyEnt (in my code) to be the same. Hope that makes sense Code: gettexts ;;Refer to for Selection Set information: http://lee-mac.com/ssget.html (defun c:gettexts ( / ss acount x MyEnt ) (setq ss (ssget '((0 . "TEXT"))) ) ;; Selecting TEXT only ;; (setq ss (ssget '((0 . "MTEXT"))) ) ;; Selecting MTEXT only ;; (setq ss (ssget '((0 . "*TEXT"))) ) ;; Selecting all text (setq acount 0) ;; just a counter (while (< acount (sslength ss)) ;; while loop for the length / number of texts selected (setq MyEnt (ssname ss acount)) ;; get the entity name of each selected item ;; DO YOUR STUFF HERE ON EACH ENTITY / TEXT (setq acount (+ acount 1)) ;; increase the counter ) ;; end while (princ) ;; end silently ) ;; end defun Put together with BigAl to give: ;;Refer to for Selection Set information: http://lee-mac.com/ssget.html (defun c:gettexts ( / ss acount x MyEnt ) (setq ss (ssget '((0 . "TEXT"))) ) ;; Selecting TEXT only ;; (setq ss (ssget '((0 . "MTEXT"))) ) ;; Selecting MTEXT only ;; (setq ss (ssget '((0 . "*TEXT"))) ) ;; Selecting all text (setq acount 0) ;; just a counter (while (< acount (sslength ss)) ;; while loop for the length / number of texts selected (setq MyEnt (ssname ss acount)) ;; get the entity name of each selecteds item (setq txtentg (entget MyEnt)) (command "UCS" "OB" MyEnt) (setq x 50 y 50) (setq pt (list x y)) (command "move" MyEnt "" "0,0" pt) (command "UCS" "W") (setq acount (+ acount 1)) ;; increase the counter ) ;; end while (princ) ;; end silently ) ;; end defun Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 @Steven P @BIGAL @devitg Thank you all, I wish I could meet and hug you. There were around more than 500 texts rotated in different direction in each of my layout drawing which I was moving manually until now. (The work pressure is immense, I'm not been able to concentrate or to look into learn new things at the moment) Please continue your support in the future as well. You guys are AWESOME. Quote
devitg Posted March 2, 2023 Posted March 2, 2023 @Sandeep RC, please upload some true and real application dwg. I guess that all 500 text , are not the same text , or the are different ? Located at same layer.? Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 (edited) @devitg they are different texts but are on same layer, find one of the drawing attached here. Edited March 5, 2023 by Sandeep RC Quote
devitg Posted March 2, 2023 Posted March 2, 2023 Just now, Sandeep RC said: @devitg they are different texts but are on same layer ok , any character comon to all text. layer VILLAGE NAME As I can see at your sample.dwg , both the X Y and SAMPLETEXT , are at the same layer . Quote
devitg Posted March 2, 2023 Posted March 2, 2023 @Sandeep RC you say Quote each of my layout drawing So , text are at paper space or all at model space As I see there is no LAYOUT at your sample .dwg Quote
Sandeep RC Posted March 2, 2023 Author Posted March 2, 2023 see my actual file attached as CWRM. anyways @Steven P's code is now working as expected. I will now change the XY values and will test it further. 1 Quote
devitg Posted March 2, 2023 Posted March 2, 2023 1 minute ago, Sandeep RC said: see my actual file attached as CWRM. anyways @Steven P's code is now working as expected. I will now change the XY values and will test it further. I can not find CWRM.dwg Please upload 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.