Jump to content

adjust text line


exceed

Recommended Posts

; Adjust Text Line - 2022.03.11 exceed

(vl-load-com)
(defun c:atl ( / oldosmode *error* startrange endrange p2 p4 ss_o_t ss_o_t_length ss_o_t_index ss_o_t_list ss_o_t_stack ss_o_t_ent_compare ss_o_t_y ss_o_t_ss ss_o_t_obj ss_o_t_box ss_t_lowleft_x ss_t_lowright_x ss_o_t_ent_new ss_o_t_obj_new ss_o_t_box_new ss_t_ll_x_n ss_t_lr_x_n left_delta right_delta ss_o_l ss_o_l_len index l_obj lpt1 lpt2 new_lptleft new_lptright ss_o_pl ss_o_pl_len pl_obj coords plpt1x plpt2x case1 case2 )
  (setq oldosmode (getvar 'osmode))
  (LM:startundo (LM:acdoc))
  (setvar 'cmdecho 0)
  (setvar 'osmode 0)
  ;error control
    (defun *error* ( msg )
        (LM:endundo (LM:acdoc))
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\n Error: " msg))
        )
        (setvar 'cmdecho 1)
        (setvar 'osmode oldosmode)
        ;change text edit mode system variable to multi
        (setvar 'texteditmode 0)
        (redraw)
        (princ)
    )
  ;draw gr selection box
    (if
        (and
            (setq startrange (getpoint "\n Select Range - Start Point "))
            (setq endrange (getcorner startrange "\n Select Range - End Point "))
        )
        (progn
            (setq p2 (list (car endrange) (cadr startrange))
                   p4 (list (car startrange) (cadr endrange))
            )
            (grvecs (list -1 startrange p2 p2 endrange endrange p4 p4 startrange))
         )
    )
    (redraw)
    (princ)

  ;select text  
  (if (setq ss_o_t (ssget "W" startrange endrange (list (cons 0 "*TEXT"))))
     (progn
       (setq ss_o_t_length (sslength ss_o_t))
       (setq ss_o_t_index 0) 
       (setq ss_o_t_list '())
       (setq ss_o_t_stack '())
         (repeat ss_o_t_length
           (setq ss_o_t_ent_compare (ssname ss_o_t ss_o_t_index))
           (setq ss_o_t_y (cadr (cdr (assoc 10 (entget ss_o_t_ent_compare) ) ) ))
           (setq ss_o_t_list (list ss_o_t_ent_compare ss_o_t_y))
           (setq ss_o_t_stack (cons ss_o_t_list ss_o_t_stack))
           (setq ss_o_t_index (+ ss_o_t_index 1))
         );end of repeat              
     );end of progn
  ); end of if

  ;sort text selection set by reverse y value
  (setq ss_o_t_stack (vl-sort ss_o_t_stack
                              (function
                                      (lambda (x1 x2)(> (cadr x1) (cadr x2)))
                              )
                        )
  )
 
  ;get first text
  (setq ss_o_t_ss (car (car ss_o_t_stack)))
  (setq ss_o_t_obj (vlax-ename->vla-object (cdr (assoc -1 (entget ss_o_t_ss)))))
  (setq ss_o_t_box (text-box-off (entget ss_o_t_ss) 0))

  ;get text box x coord
  (setq ss_t_lowleft_x (car (car ss_o_t_box)))
  (setq ss_t_lowright_x (car (cadr ss_o_t_box)))

  ;change text edit mode system variable to single
  (setvar 'texteditmode 1)

  ;use ddedit to get the previous value and make it easier to edit
  (command "ddedit" ss_o_t_ss pause)



  ;get changed text box and x value
  (setq ss_o_t_ent_new (entget ss_o_t_ss))
  (setq ss_o_t_obj_new (vlax-ename->vla-object (cdr (assoc -1 ss_o_t_ent_new))))
  (setq ss_o_t_box_new (text-box-off ss_o_t_ent_new 0))
  (setq ss_t_ll_x_n (car (car ss_o_t_box_new)))
  (setq ss_t_lr_x_n (car (cadr ss_o_t_box_new)))

  ;get delta value of x-axis
  (setq left_delta (- ss_t_ll_x_n ss_t_lowleft_x))
  (setq right_delta (- ss_t_lr_x_n ss_t_lowright_x))

  ;edit lines
  (if (setq ss_o_l (ssget "W" startrange endrange (list (cons 0 "LINE"))))
    (progn
     (setq ss_o_l_len (sslength ss_o_l))
     (setq index 0)
     (repeat ss_o_l_len
     (setq l_obj (vlax-ename->vla-object (cdr (assoc -1 (entget (ssname ss_o_l index))))))
     (setq lpt1 (vlax-safearray->list (vlax-variant-value (vla-get-startpoint l_obj))))
     (setq lpt2 (vlax-safearray->list (vlax-variant-value (vla-get-endpoint l_obj))))
     (setq lpt1x (car lpt1))
     (setq lpt2x (car lpt2))
     (if (/= lpt1x lpt2x)
        (if (< lpt1x lpt2x)
           (progn 
             (setq lptleft lpt1)
             (setq lptright lpt2)
             (setq new_lptleft (vlax-3d-point (list (+ (car lptleft) left_delta) (cadr lptleft) (caddr lptleft))))
             (setq new_lptright (vlax-3d-point (list (+ (car lptright) right_delta) (cadr lptright) (caddr lptright))))
             (vla-put-startpoint l_obj new_lptleft)
             (vla-put-endpoint l_obj new_lptright)
           )
           (progn 
             (setq lptleft lpt2)
             (setq lptright lpt1)
             (setq new_lptleft (vlax-3d-point (list (+ (car lptleft) left_delta) (cadr lptleft) (caddr lptleft))))
             (setq new_lptright (vlax-3d-point (list (+ (car lptright) right_delta) (cadr lptright) (caddr lptright))))
             (vla-put-startpoint l_obj new_lptright)
             (vla-put-endpoint l_obj new_lptleft)
           )
        );end of if
     );end of if
     (setq index (+ index 1))
  )
 );end of progn
);end of if


;edit lwpolylines
(if (setq ss_o_pl (ssget "W" startrange endrange (list (cons 0 "LWPOLYLINE"))))
  (progn
  (setq ss_o_pl_len (sslength ss_o_pl))
  (setq index 0)
  (repeat ss_o_pl_len
     (setq pl_obj (vlax-ename->vla-object  (cdr (assoc -1 (entget (ssname ss_o_pl index)) ) ) ) ) 
     (setq coords (vlax-get pl_obj 'coordinates))
     (setq plpt1x (car coords))
     (setq plpt2x (caddr coords))
     (setq case1 (list (+ (car coords) left_delta) (cadr coords) (+ right_delta (caddr coords)) (nth 3 coords) ) )
     (setq case2 (list (+ (car coords) right_delta) (cadr coords) (+ left_delta (caddr coords)) (nth 3 coords) ) )
     (if (/= plpt1x plpt2x)
        (if (< plpt1x plpt2x)
           (progn 
             (vlax-put pl_obj 'coordinates case1) 
           )
           (progn 
             (vlax-put pl_obj 'coordinates case2) 
           )
        );end of if
     );end of if
     (setq index (+ index 1))
  )
); end of progn
); end of if

  (princ "\n adjust text lines complete \n")

  (LM:endundo (LM:acdoc))
  (setvar 'cmdecho 1)
  (setvar 'osmode oldosmode)
  ;change text edit mode system variable to multi
  (setvar 'texteditmode 0)
  (princ)
)




;; Text Box  -  gile / Lee Mac
;; Returns an OCS point list describing a rectangular frame surrounding
;; the supplied text or mtext entity with optional offset
;; enx - [lst] Text or MText DXF data list
;; off - [rea] offset (may be zero)

(defun text-box-off ( enx off / bpt hgt jus lst ocs org rot wid )
    (cond
        (   (= "TEXT" (cdr (assoc 00 enx)))
            (setq bpt (cdr (assoc 10 enx))
                  rot (cdr (assoc 50 enx))
                  lst (textbox enx)
                  lst
                (list
                    (list (- (caar  lst) off) (- (cadar  lst) off)) (list (+ (caadr lst) off) (- (cadar  lst) off))
                    (list (+ (caadr lst) off) (+ (cadadr lst) off)) (list (- (caar  lst) off) (+ (cadadr lst) off))
                )
            )
        )
        (   (= "MTEXT" (cdr (assoc 00 enx)))
            (setq ocs  (cdr (assoc 210 enx))
                  bpt  (trans (cdr (assoc 10 enx)) 0 ocs)
                  rot  (angle '(0.0 0.0) (trans (cdr (assoc 11 enx)) 0 ocs))
                  wid  (cdr (assoc 42 enx))
                  hgt  (cdr (assoc 43 enx))
                  jus  (cdr (assoc 71 enx))
                  org  (list (cond ((member jus '(2 5 8)) (/ wid -2.0)) ((member jus '(3 6 9)) (- wid))      (0.0))
                             (cond ((member jus '(1 2 3)) (- hgt))      ((member jus '(4 5 6)) (/ hgt -2.0)) (0.0))
                       )
                  lst
                (list
                    (list (- (car org) off)     (- (cadr org) off))     (list (+ (car org) wid off) (- (cadr org) off))
                    (list (+ (car org) wid off) (+ (cadr org) hgt off)) (list (- (car org) off)     (+ (cadr org) hgt off))
                )
            )
        )
    )
    (if lst
        (   (lambda ( m ) (mapcar '(lambda ( p ) (mapcar '+ (mxv m p) bpt)) lst))
            (list
                (list (cos rot) (sin (- rot)) 0.0)
                (list (sin rot) (cos rot)     0.0)
               '(0.0 0.0 1.0)
            )
        )
    )
)



;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
 
(defun mxv ( m v )
    (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)



;; Start Undo  -  Lee Mac
;; Opens an Undo Group.

(defun LM:startundo ( doc )
    (LM:endundo doc)
    (vla-startundomark doc)
)

;; End Undo  -  Lee Mac
;; Closes an Undo Group.

(defun LM:endundo ( doc )
    (while (= 8 (logand 8 (getvar 'undoctl)))
        (vla-endundomark doc)
    )
)

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)

 

Stores the left and right gaps of the text and line before editing, and maintains the same gap in the text after editing.

This Lisp can only be used with horizontal lwpolylines, lines and text.

 

strike through lisp (http://www.lee-mac.com/strikethrough.html) is already very useful, 

but Since I mainly edit drawings made by others, I needed Lisp to edit lines in existing drawings.

 

If a smart person were to do this, after getting the angle of the text box and the angle of the line

if the angle satisfies the allowable range, can find the difference using the vector and extend or shorten it that much.

but I'm not smart. haha:)

 

I learned these things through this.

 

-  (if (ssget)) directly.

- (vlax-get/put ~ 'coordinates))

 

- Using ddedit in the middle of lisp

Edited by exceed
Link to comment
Share on other sites

Would not Mtext with a background mask be easier if you change text it hides line, oh yeah second bit click line its still true length not 2 parts with a gap. You can adjust side margin also. I seem to remember make mtext then edit entlast to get the mask. 

 

image.png.c2fdb0aa88f2a97415ba780d949e5340.png

  • Thanks 1
Link to comment
Share on other sites

frame_020_delay-0_1s.thumb.gif.5566a8f0b727b72dcc83bb3a42574c7d.gif

 

frame_035_delay-0_29s.thumb.gif.669675d0872e95f9704f13c67b489d68.gif

 

frame_039_delay-0_1s.thumb.gif.47f06c02ca8899b1f0dd46140074227d.gif

 

It was something I hadn't thought of. thank you. mtext and mtext-boxes still confuse me.

 

My first thought was to use it like this.

It can be used for things like frame titles.

 

I tried to upload a gif several times, but Even though it's 300kb, it didn't upload.

Link to comment
Share on other sites

I have same problem with Gif's ok to post at Autodesk forum and emails, have been in contact with David. I use "Screen to Gif". 

 

Any one out there what do you use to make Gif's.

Link to comment
Share on other sites

 

1 hour ago, BIGAL said:

I have same problem with Gif's ok to post at Autodesk forum and emails, have been in contact with David. I use "Screen to Gif". 

 

Any one out there what do you use to make Gif's.

 

 

I mainly use 'naver capture'. this is a local program made by search engine site. or OBS recording and converting to gif.

now that I look it up, screentogif seems to be better.

 

I tried online conversion site to compress that from 340kb to 136kb, in ( https://gifcompressor.com/ ) but the same problem appeared. 

[ Sorry, an unknown server error occurred when uploading this file. (Error code: -200) ]

I think this site is reducing capcity by delete similar frames. because this makes gif speed up.

------

and then today, I resize width and height 50% (1288px x 590px (340kb) to 644px x 295px (152kb)) in ( https://ezgif.com/resize ), and succeeded to uploading.

I don't know what the error code -200 means, I guess width and height may be related rather than capacity.

ex) width limitation 800px, because there are many sites with that limitations.

ezgif.com-gif-maker.gif

(upperleft - lwpolyline and locked layer, upperright - line

lowercenter line&lwpolyline mixed, and upper line & middle line)

Edited by exceed
Link to comment
Share on other sites

On 14/03/2022 at 00:56, exceed said:

I tried online conversion site to compress that from 340kb to 136kb, in ( https://gifcompressor.com/ ) but the same problem appeared. 

[ Sorry, an unknown server error occurred when uploading this file. (Error code: -200) ]

I think this site is reducing capcity by delete similar frames. because this makes gif speed up.

------

and then today, I resize width and height 50% (1288px x 590px (340kb) to 644px x 295px (152kb)) in ( https://ezgif.com/resize ), and succeeded to uploading.

I don't know what the error code -200 means, I guess width and height may be related rather than capacity.

ex) width limitation 800px, because there are many sites with that limitations.

 

Currently, the maximum image size is 1200px x 1200px. Files larger than this are uploaded and then auto-reduced in size. However, it looks like the software is struggling to reduce the dimensions of animated GIF files. Obviously, I need to balance the ease of use for users with storage capacity, but am happy to increase the current maximum if you think it will provide a better user experience :)

  • Thanks 1
Link to comment
Share on other sites

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