Jump to content

Recommended Posts

Posted

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.

image.thumb.png.8670de2b7bdfb269b45ecbc71b436cea.png

SAMPLE.dwg

Posted

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?

Posted (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))

  )

 

 

 

image.png.7c9c0e447ab3ffcc53c67fb8a1267bd7.png

Edited by devitg
ad image
Posted

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)

 

  • Like 1
Posted (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 by Sandeep RC
Posted (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 by Sandeep RC
Posted

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

Posted (edited)

@BIGAL I tried searching on internet and did some changes accordingly, but I couldn't get it work. 😥

Edited by Sandeep RC
Posted

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)

Posted

Don't do that!! If you have nearly got it working usually it is only a small thing to make it work

Posted

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

 

Posted

@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. 💚

Posted

@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.?

 

 

Posted (edited)

@devitg they are different texts but are on same layer, find one of the drawing attached here.

 

Edited by Sandeep RC
Posted
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 .

 

image.png.5d7c15cc3b63c3c76d6cb9a708799af6.png

 

Posted

@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

 

 

Posted

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.

  • Like 1
Posted
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 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...