<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Inserting a UCS angle value in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9196946#M80803</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I will have a constant alignment of the text, whatever the current view. The global value for my text angle will remain constant. What I would prefer, would be when I change my orientation (e.g. ESWN with E in the place of North) the next text I generate through my command to also rotate with the axis and still have a relative angle to my current view.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here you have two functions that return angle of current UCS relative to WCS, one in radians other in degrees. To preserve rotation of a text object relative to WCS in your function subtract rotation of current UCS from text rotation relative to WCS (stored in variable "gwnia") .&amp;nbsp; In command approach to generating mtext instead "gwnia" you should use:&lt;/P&gt;&lt;PRE&gt;(- gwnia (ucsangdeg))&lt;/PRE&gt;&lt;PRE&gt;(defun ucsangrad ( / v uv *error* vect_dot vect_mod asin acos )
    (defun *error* () (princ))
    (setq v '(1.0 0.0 0.0) uv (trans v 1 0 T))
    (defun vect_dot (v1 v2)(apply '+ (mapcar '* v1 v2)))
    (defun asin (x)
      (cond 
        ((and(&amp;gt; x -1.0)(&amp;lt; x 1.0)) (atan (/ x (sqrt (- 1.0 (* x x))))))
        ((= x -1.0) (* -1.0 (/ pi 2)))
        ((= x  1) (/ pi 2))
      )
    )
    (defun acos (x)(cond ((and(&amp;gt;= x -1.0)(&amp;lt;= x 1.0)) (-(* pi 0.5) (asin x))))) 
    (setq ang (acos (vect_dot v uv)))
    (if (and (&amp;lt; (cadr uv) 0.0) (&amp;gt; (car uv) 0.0)) (setq ang (* -1 ang)))
    ang
)

(defun ucsangdeg ( / v uv *error* vect_dot vect_mod asin acos )
    (defun *error* () (princ))
    (setq v '(1.0 0.0 0.0) uv (trans v 1 0 T))
    (defun rad_to_deg (rad)(* 180.0 (/ rad PI)))
    (defun vect_dot (v1 v2)(apply '+ (mapcar '* v1 v2)))
    (defun asin (x)
      (cond 
        ((and(&amp;gt; x -1.0)(&amp;lt; x 1.0)) (atan (/ x (sqrt (- 1.0 (* x x))))))
        ((= x -1.0) (* -1.0 (/ pi 2)))
        ((= x  1) (/ pi 2))
      )
    )
    (defun acos (x)(cond ((and(&amp;gt;= x -1.0)(&amp;lt;= x 1.0)) (-(* pi 0.5) (asin x))))) 
    (setq ang (acos (vect_dot v uv)))
    (if (and (&amp;lt; (cadr uv) 0.0) (&amp;gt; (car uv) 0.0)) (setq ang (* -1 ang)))
    (rad_to_deg ang)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; I hope this answer your question.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 19:40:56 GMT</pubDate>
    <dc:creator>hak_vz</dc:creator>
    <dc:date>2019-12-11T19:40:56Z</dc:date>
    <item>
      <title>Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193066#M80797</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a text which holds a specific alignment of X angle on UCS axis. Basically I am rotating my view regularly and I want it to understand to always rotate e.g. 45 degrees on my current and not world view. My code as of now is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(setq gwnia (getint "\n Specify angle: "))

.......

(command "mtext" shelfnamep "j" "tc" "s" "driverstyle" "r" gwnia "w" "0.8" shelfname "" )&lt;/PRE&gt;&lt;P&gt;I thought about the trans function, but it says it works on points. Basically I don't even need to ask for the user input of the angle at the start of my code, I will always have a fixed 45 degrees on the text that pops up based on my current view.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 12:04:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193066#M80797</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-10T12:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193117#M80798</link>
      <description>&lt;P&gt;You want to insert MTEXT rotated 45° to current UCS. This should be enought.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(command "mtext" shelfnamep "j" "tc" "s" "driverstyle" "r" 45 "w" 0.8 shelfname "" )&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 12:21:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193117#M80798</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2019-12-10T12:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193174#M80799</link>
      <description>&lt;P&gt;Maybe I'm phrasing my question wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I mean is, I need to keep the orientation of the generated text rotating as I rotate my screen. e.g. if I am at the normal NESW (top and clockwise) view and I generate the text with 45 degrees and I then change my view to ESWN and execute the code, the text is generated to the old 45 degree based on the WCS and not on the 45 degree I'm currently seeing on my screen.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 12:51:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193174#M80799</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-10T12:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193263#M80800</link>
      <description>&lt;P&gt;So you need the angle 45°to WCS....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 13:23:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193263#M80800</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2019-12-10T13:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193306#M80801</link>
      <description>&lt;P&gt;When you say you are rotating your screen, are you using DView;Twist?&lt;/P&gt;
&lt;P&gt;Sounds to me that you are looking for a reactor that changes the rotation of text based on (getvar "viewtwist").&lt;/P&gt;
&lt;P&gt;This is excerpted and adapted from my HTEXT routine, which makes selected text horizontal to the screen...&lt;/P&gt;
&lt;PRE&gt;   (setq 2pi (* pi 2.0)
         ucsang (angle (trans '(0.0 0.0 0.0) 0 1)(trans '(1.0 0.0 0.0) 0 1))
         vtwist (rem (- 2pi (getvar "viewtwist")) 2pi)
         0ang   (+ ucsang vtwist)
        ;; So for your case...
        45ang (+ 0ang (/ pi 4))
   )
&lt;/PRE&gt;
&lt;P&gt;You just have to figure out what filter to use to ssget the text candidates, and then learn about reactors.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 13:35:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193306#M80801</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2019-12-10T13:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193396#M80802</link>
      <description>&lt;P&gt;Let me explain more in depth.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to generate text based on the orientation of my view. I don't need the already generated text to change when I do change views. For example I work in a drawing and the orientation is normal (NESW). If I set an arbitrary number of degrees there for my text with the following code excerpt:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(setq gwnia (getint "\nPlease specify angle: "))
....
(setq shelfnamep (getpoint "\n Insert shelf name insertion point: "))
(setq shelfname (getstring T "\n Insert shelf base name: ")) 
.....
(command "mtext" shelfnamep "j" "tc" "s" "driverstyle" "r" gwnia "w" "0.8" shelfname "" )&lt;/PRE&gt;&lt;P&gt;I will have a constant alignment of the text, whatever the current view. The global value for my text angle will remain constant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would prefer, would be when I change my orientation (e.g. ESWN with E in the place of North) the next text I generate through my command to also rotate with the axis and still have a relative "gwnia" angle to my current view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 14:14:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9193396#M80802</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-10T14:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a UCS angle value</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9196946#M80803</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I will have a constant alignment of the text, whatever the current view. The global value for my text angle will remain constant. What I would prefer, would be when I change my orientation (e.g. ESWN with E in the place of North) the next text I generate through my command to also rotate with the axis and still have a relative angle to my current view.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here you have two functions that return angle of current UCS relative to WCS, one in radians other in degrees. To preserve rotation of a text object relative to WCS in your function subtract rotation of current UCS from text rotation relative to WCS (stored in variable "gwnia") .&amp;nbsp; In command approach to generating mtext instead "gwnia" you should use:&lt;/P&gt;&lt;PRE&gt;(- gwnia (ucsangdeg))&lt;/PRE&gt;&lt;PRE&gt;(defun ucsangrad ( / v uv *error* vect_dot vect_mod asin acos )
    (defun *error* () (princ))
    (setq v '(1.0 0.0 0.0) uv (trans v 1 0 T))
    (defun vect_dot (v1 v2)(apply '+ (mapcar '* v1 v2)))
    (defun asin (x)
      (cond 
        ((and(&amp;gt; x -1.0)(&amp;lt; x 1.0)) (atan (/ x (sqrt (- 1.0 (* x x))))))
        ((= x -1.0) (* -1.0 (/ pi 2)))
        ((= x  1) (/ pi 2))
      )
    )
    (defun acos (x)(cond ((and(&amp;gt;= x -1.0)(&amp;lt;= x 1.0)) (-(* pi 0.5) (asin x))))) 
    (setq ang (acos (vect_dot v uv)))
    (if (and (&amp;lt; (cadr uv) 0.0) (&amp;gt; (car uv) 0.0)) (setq ang (* -1 ang)))
    ang
)

(defun ucsangdeg ( / v uv *error* vect_dot vect_mod asin acos )
    (defun *error* () (princ))
    (setq v '(1.0 0.0 0.0) uv (trans v 1 0 T))
    (defun rad_to_deg (rad)(* 180.0 (/ rad PI)))
    (defun vect_dot (v1 v2)(apply '+ (mapcar '* v1 v2)))
    (defun asin (x)
      (cond 
        ((and(&amp;gt; x -1.0)(&amp;lt; x 1.0)) (atan (/ x (sqrt (- 1.0 (* x x))))))
        ((= x -1.0) (* -1.0 (/ pi 2)))
        ((= x  1) (/ pi 2))
      )
    )
    (defun acos (x)(cond ((and(&amp;gt;= x -1.0)(&amp;lt;= x 1.0)) (-(* pi 0.5) (asin x))))) 
    (setq ang (acos (vect_dot v uv)))
    (if (and (&amp;lt; (cadr uv) 0.0) (&amp;gt; (car uv) 0.0)) (setq ang (* -1 ang)))
    (rad_to_deg ang)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; I hope this answer your question.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 19:40:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/inserting-a-ucs-angle-value/m-p/9196946#M80803</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2019-12-11T19:40:56Z</dc:date>
    </item>
  </channel>
</rss>

