Author Topic: How to--What you see at Display is what you get at UCS?  (Read 871 times)

0 Members and 1 Guest are viewing this topic.

learner

  • Mosquito
  • Posts: 11
How to--What you see at Display is what you get at UCS?
« on: October 09, 2021, 01:18:39 PM »
Hi all! I'm sorry, Chinglish.thanks.
I want make something from Display to UCS.There are the following questions:
1.UCS&PLAN is WCS;2.UCS&PLAN is UCS;3.WCS&PLAN is WCS;4.UCS is Clockwise.(ucsxdir cross ucsydir is (0 0 -1)).
The text angle is always maintained at 0 degrees.
Here is my error code:
Code: [Select]
;;;make a text from displayed to UCS
(defun c:temp (/ GR1 GR2 LOOP OCS SC STR)
  (setq loop t
str  "Left click to draw,Right click to exit"
  )
  (while loop
    (setq gr1 (grread t 15 0)
  gr2 (cadr gr1)
  gr1 (car gr1)
  sc  (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
    )
    (cond ((= gr1 5)
   (redraw)
   (LM:DisplayGrText gr2 (LM:GrText str) 1 0 0)
  )
  ((= gr1 3)
   (setq ocs (trans '(0 0 1) 1 0 t));_My entmeke text function is to ocs.
   (entmakex (list '(0 . "text")
   '(100 . "AcDbEntity")
   '(100 . "AcDbText")
   (cons 10 (trans gr2 2 0))
   (cons 11 (trans gr2 2 0))
   (cons 1 str)
   (cons 40 (* 10 sc))
   (cons 7 "standard")
   (cons 50 0)
   (cons 210 ocs)
     )
   )
   (redraw)
  )
  ((or (= 11 gr1) (= 25 gr1)) (setq loop nil) (redraw))
    )
  )
)
;;-----------------------=={ GrText }==-----------------------;;
;;                                                            ;;
;;  Returns a grvecs pixel vector list relative to the origin ;;
;;  encoding the supplied string.                             ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright ?2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  With thanks to ElpanovEvgeniy for the method of vector    ;;
;;  encoding to save me a lot of typing.                      ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  str - String to be expressed in vector list format.       ;;
;;------------------------------------------------------------;;
;;  Returns:  GrVecs Pixel Vector List relative to the Origin ;;
;;------------------------------------------------------------;;
;;  Version 1.1    -    26-03-2011                            ;;
;;------------------------------------------------------------;;

(defun LM:GrText ( str / asc lst vec xco yco )
    (setq vec
       '(
            (033 045 045 065 135)
            (034 104 134 107 137)
            (035 043 063 046 066 084 094 087 097 115 135 118 138 072 078 103 109)
            (036 025 035 052 052 043 047 058 078 083 087 092 112 123 127 118 118 135 135)
            (037 052 052 063 063 074 074 085 085 096 096 107 107 118 118 129 129 047 048 067 068 056 056 059 059 113 114 133 134 122 122 125 125)
            (038 043 046 049 049 052 072 057 058 067 068 076 076 079 079 083 083 085 085 094 094 103 123 134 136 127 127)
            (039 105 135)
            (040 017 017 026 036 045 105 116 126 137 137)
            (041 014 014 025 035 046 106 115 125 134 134)
            (042 073 074 076 077 084 086 092 098 104 106 113 114 116 117)
            (043 055 115 082 084 086 088)
            (044 034 035 045 046 055 057)
            (045 083 088)
            (046 045 046 055 056)
            (047 052 052 063 063 074 074 085 085 096 096 107 107 118 118 129 129)
            (048 044 047 134 137 053 123 058 128)
            (049 044 048 124 125 056 136)
            (050 043 048 053 053 064 064 075 075 086 086 097 097 108 128 134 137 123 123)
            (051 053 053 044 047 058 088 095 097 108 128 134 137 123 123)
            (052 046 048 057 137 078 078 073 076 083 083 094 094 105 115 126 126)
            (053 053 053 044 047 058 088 094 097 093 133 134 138)
            (054 044 047 058 088 095 097 084 084 053 113 124 124 135 137)
            (055 044 054 065 075 086 096 107 117 128 138 133 137 123 123)
            (056 044 047 094 097 134 137 053 083 058 088 103 123 108 128)
            (057 044 046 057 057 068 128 097 097 084 086 134 137 093 123)
            (058 045 046 055 056 095 096 105 106)
            (059 034 035 045 046 055 057 095 096 105 106)
            (060 047 047 056 056 065 065 074 074 083 083 094 094 105 105 116 116 127 127)
            (061 073 078 093 098)
            (062 043 043 054 054 065 065 076 076 087 087 096 096 105 105 114 114 123 123)
            (063 045 045 065 075 086 086 097 097 108 128 134 137 123 123)
            (064 034 038 043 043 052 112 123 123 134 137 128 128 079 119 068 068 065 066 105 106 077 107 074 094)
            (065 041 043 047 049 052 062 058 068 073 077 083 093 087 097 104 114 106 116 125 135 133 134)
            (066 042 047 053 123 058 088 108 128 094 097 132 137)
            (067 044 047 053 053 058 058 062 112 123 123 134 136 127 127 108 138)
            (068 042 046 057 057 127 127 132 136 068 118 053 123)
            (069 042 048 058 058 094 095 086 106 132 137 128 138 053 123)
            (070 042 045 094 095 086 106 132 137 128 138 053 123)
            (071 044 047 053 053 058 078 086 089 062 112 123 123 134 136 127 127 108 138)
            (072 041 043 047 049 131 133 137 139 093 097 052 122 058 128)
            (073 043 047 133 137 055 125)
            (074 052 062 043 046 057 127 135 139)
            (075 042 044 048 049 132 134 136 138 053 123 084 085 095 095 106 116 127 127 076 076 067 067 058 058)
            (076 042 047 048 058 053 123 132 135)
            (077 041 043 047 049 052 122 058 128 131 132 138 139 103 113 107 117 084 094 086 096 065 075)
            (078 041 044 131 132 136 139 052 122 048 128 113 113 094 104 085 085 066 076 057 057)
            (079 044 046 053 053 057 057 123 123 127 127 134 136 062 112 068 118)
            (080 042 045 084 087 132 137 053 123 098 128)
            (081 134 136 123 123 127 127 112 062 118 068 053 053 057 057 044 046 035 036 023 024 027 028)
            (082 042 044 048 049 132 137 123 053 128 098 084 087 076 076 067 067 058 058)
            (083 042 062 053 053 044 047 058 078 086 087 093 095 102 122 133 136 127 127 118 138)
            (084 043 047 055 125 132 138 131 121 139 129)
            (085 044 046 052 053 057 058 062 122 068 128 131 133 137 139)
            (086 045 055 064 074 066 076 083 103 087 107 112 122 118 128 131 133 137 139)
            (087 043 063 047 067 072 092 074 094 076 096 078 098 101 121 105 115 109 129 131 132 138 139)
            (088 041 043 047 049 131 133 137 139 052 052 058 058 063 063 067 067 074 074 076 076 085 095 104 104 106 106 113 113 117 117 122 122 128 128)
            (089 043 047 055 085 094 094 096 096 103 113 107 117 122 122 128 128 131 133 137 139)
            (090 122 122 058 058 132 138 042 048 128 128 052 052 063 063 074 074 085 095 106 106 117 117)
            (091 015 017 135 137 025 125)
            (092 122 122 113 113 104 104 095 095 086 086 077 077 068 068 059 059)
            (093 014 016 134 136 026 126)
            (094 102 102 113 113 124 124 135 135 126 126 117 117 108 108)
            (095 021 029)
            (096 125 125 134 134)
            (097 043 046 048 048 052 072 057 097 083 086 103 106)
            (098 042 043 045 046 054 054 057 058 068 098 097 097 105 106 094 094 132 132 053 133)
            (099 044 046 053 053 057 058 052 092 093 093 104 106 097 098 108 108)
            (100 044 045 047 048 052 092 053 053 056 056 093 093 104 105 096 096 136 136 057 137)
            (101 044 046 053 053 057 058 052 092 093 093 104 106 097 098 088 088 073 078)
            (102 043 046 054 124 093 093 095 096 135 137 128 128)
            (103 013 016 022 032 027 097 107 108 066 066 096 096 054 055 104 105 063 063 093 093 062 092)
            (104 042 044 046 048 057 097 053 133 132 132 094 094 105 106)
            (105 043 047 055 105 103 104 135 135)
            (106 022 022 013 015 026 106 104 105 136 136)
            (107 042 044 046 048 053 133 132 132 057 057 066 066 074 075 085 085 096 106 107 108)
            (108 043 047 055 135 133 134)
            (109 041 043 045 046 048 049 052 102 055 105 058 108 101 101 093 093 104 104 096 096 107 107)
            (110 042 044 046 048 053 103 057 097 102 102 094 094 105 106)
            (111 044 046 104 106 053 053 057 057 093 093 097 097 052 092 058 098)
            (112 012 015 023 103 102 102 054 054 094 094 045 046 105 106 057 058 097 098 068 088)
            (113 015 018 027 107 108 108 056 056 096 096 044 045 104 105 052 053 092 093 062 082)
            (114 042 046 054 104 102 103 095 095 106 108 099 099)
            (115 052 052 043 047 058 068 073 077 082 092 103 107 098 098)
            (116 045 047 058 058 054 124 102 103 105 107)
            (117 102 102 106 106 053 103 056 056 044 045 047 107 048 048)
            (118 045 045 054 064 056 066 073 083 077 087 092 092 098 098 101 103 107 109)
            (119 043 053 047 057 062 092 064 084 066 086 068 098 101 103 095 105 107 109)
            (120 042 044 046 048 102 104 106 108 053 053 057 057 093 093 097 097 064 064 066 066 084 084 086 086 075 075)
            (121 012 013 024 024 035 045 054 064 056 066 073 083 077 087 092 092 098 098 101 103 107 109)
            (122 092 092 058 058 102 108 042 048 097 097 086 086 075 075 064 064 053 053)
            (123 016 017 025 065 073 074 085 125 136 137)
            (124 015 135)
            (125 014 015 026 066 077 078 086 126 134 135)
            (126 112 122 133 134 125 125 116 117 128 138)
        )
    )
    (eval
        (list 'defun 'LM:GrText '( str / asc lst vec xco yco )
            (list 'setq 'vec
                (list 'quote
                    (mapcar
                        (function
                            (lambda ( b )
                                (cons (car b)
                                    (mapcar
                                        (function
                                            (lambda ( a )
                                                (list (rem a 10) (/ a 10))
                                            )
                                        )
                                        (cdr b)
                                    )
                                )
                            )
                        )
                        vec
                    )
                )
            )
           '(setq xco 0 yco 0)
           '(repeat (strlen str)
                (setq asc (ascii str)
                      str (substr str 2)
                )
                (cond
                    (   (= 32 asc)
                        (setq xco (+ xco 09))
                    )
                    (   (= 09 asc)
                        (setq xco (+ xco 36))
                    )
                    (   (= 10 asc)
                        (setq xco 0
                              yco (- yco 16)
                        )
                    )
                    (   (setq lst
                            (cons
                                (mapcar
                                    (function
                                        (lambda ( a )
                                            (list (+ (car a) xco) (+ (cadr a) yco))
                                        )
                                    )
                                    (cdr (assoc asc vec))
                                )
                                lst
                            )
                        )
                        (setq xco (+ xco 9))
                    )
                )
            )
           '(apply 'append lst)
        )
    )
    (LM:GrText str)
)
;;  Author: Lee Mac, Copyright ?2013 - www.lee-mac.com       ;;
;; Display GrText  -  Lee Mac
;; pnt  -  cursor point in UCS
;; vec  -  GrText vector list
;; col  -  Text Colour (ACI Colour)
;; xof  -  x-offset from cursor in pixels
;; yof  -  y-offset from cursor in pixels
(defun LM:DisplayGrText ( pnt vec col xof yof / scl )
    (setq scl (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
          pnt (trans pnt 1 2)
    )
    (grvecs (cons col vec)
        (list
            (list scl 0.0 0.0 (+ (car  pnt) (* xof scl)))
            (list 0.0 scl 0.0 (+ (cadr pnt) (* yof scl)))
            (list 0.0 0.0 scl 0.0)
           '(0.0 0.0 0.0 1.0)
        )
    )
)
This is my maketext
Code: [Select]
(defun xty-make-text (t10 t11 t1 t50 t72 t73 t40 t41 t7 / ocs x)
  (setq ocs (trans '(0 0 1) 1 0 t)
x   (getvar "UCSYDIR")
t50 (if (equal (car x) 0 1e-10)
      t50
      (- t50 (atan (car x) (cadr x)))
    )
  )
  (entmakex (list '(0 . "text")
  '(100 . "AcDbEntity")
  '(100 . "AcDbText")
  (cons 10 (trans t10 1 ocs))
  (cons 1 t1)
  (cons 40 t40)
  (cons 41 t41)
  (cons 7 t7)
  (cons 72 t72)
  (cons 11 (trans t11 1 ocs))
  (cons 50 t50)
  (cons 73 t73)
  (cons 210 ocs)
    )
  )
)
« Last Edit: October 10, 2021, 10:00:16 AM by learner »