Simple text move

Simple text move

BB8x
Advocate Advocate
498 Views
7 Replies
Message 1 of 8

Simple text move

BB8x
Advocate
Advocate

Hello

 

I need lisp to move x/y all texts based on their rotation in direction shown on attached screenshot

99.png

I would imagine this as reading text rotation, add (or remove) 90 deg and calculate azimuth. Then move text insertion point with azimuth and distance of 0.05 units

 

Thanks

0 Likes
499 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

Yes, exactly, though as described and illustrated, always adding 90°.  Here's one way to do it:

 

(defun C:TU05 ; = Text Upwards by 0.05 units
  (/ ss n txt ins)
  (if (setq ss (ssget '((0 . "TEXT"))))
    (repeat (setq n (sslength ss))
      (setq txt (ssname ss (setq n (1- n))))
      (setpropertyvalue txt "Position"
        (polar
          (getpropertyvalue txt "Position")
          (+ (getpropertyvalue txt "Rotation") (/ pi 2))
          0.05
        )
      )
    )
  )
  (princ)
)

 

That calls for User selection.  If you really want to do all Text objects without User selection:

  (if (setq ss "_X" (ssget '((0 . "TEXT"))))

And it assumes you meant Text objects specifically, not [or not also] Mtext, but if you need Mtext too [whether or not you include the "_X"]:

  (if (setq ss (ssget '((0 . "*TEXT"))))

Kent Cooper, AIA
0 Likes
Message 3 of 8

Sea-Haven
Mentor
Mentor

Just a suggestion for "X" so moves within only current tab.

 

 

(if (setq ss "_X" (ssget '((0 . "TEXT")(cons 410 (getvar 'ctab)))))

 

 

0 Likes
Message 4 of 8

BB8x
Advocate
Advocate

I have "ads request error"

0 Likes
Message 5 of 8

TomBeauford
Advisor
Advisor

Maybe it would be best to modify the code or procedure that's placing the text incorrectly to avoid having to fix it ever again.

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 6 of 8

john.uhden
Mentor
Mentor

@BB8x 

We don't know what version of AutoCAD you are using.

@Kent1Cooper ,  @ВeekeeCZ  when did getpropertyvalue come along?

John F. Uhden

0 Likes
Message 7 of 8

TomBeauford
Advisor
Advisor

4 new AutoLISP functions in A2012

 http://www.theswamp.org/index.php?topic=39259

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

getproperty not supported in Bricscad and maybe other non acad software.

0 Likes