Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Trassformare Testo

Recommended Posts

lisp per chi non avesse gli express e funzionante anche in AutoCAD 13

; ----------------------------------------------------------------------

; (Converts Stack of TEXT to MTEXT)

; Copyright © 1998 DotSoft, All Rights Reserved

; Website: www.dotsoft.com

; ----------------------------------------------------------------------

; DISCLAIMER: DotSoft Disclaims any and all liability for any damages

; arising out of the use or operation, or inability to use the software.

; FURTHERMORE, User agrees to hold DotSoft harmless from such claims.

; DotSoft makes no warranty, either expressed or implied, as to the

; fitness of this product for a particular purpose. All materials are

; to be considered ‘as-is’, and use of this software should be

; considered as AT YOUR OWN RISK.

; ----------------------------------------------------------------------

(defun col2str (inp)


((= inp nil)(setq ret "BYLAYER"))

((= inp 256)(setq ret "BYLAYER"))

((= inp 0)(setq ret "BYBLOCK"))

((and (> inp 0)(< inp 255))(setq ret (itoa inp)))

(t nil)



(defun savprop ()

(setq clayer (getvar "CLAYER"))

(setq cecolor (getvar "CECOLOR"))

(setvar "CECOLOR" "BYLAYER")

(setq celtype (getvar "CELTYPE"))

(setvar "CELTYPE" "BYLAYER")

(setq thickness (getvar "THICKNESS"))

(setvar "THICKNESS" 0)

(if (>= (atoi (getvar "ACADVER")) 13)


(setq celtscale (getvar "CELTSCALE"))

(setvar "CELTSCALE" 1.0)




(defun resprop ()

(if (>= (atoi (getvar "ACADVER")) 13)

(setvar "CELTSCALE" celtscale)


(setvar "THICKNESS" thickness)

(setvar "CELTYPE" celtype)

(setvar "CECOLOR" cecolor)

(setvar "CLAYER" clayer)


(defun textrect (tent / ang sinrot cosrot t1 t2 p1 p2 p3 p4)

(setq p0 (cdr (assoc 10 tent))

ang (cdr (assoc 50 tent))

sinrot (sin ang)

cosrot (cos ang)

t1 (car (textbox tent))

t2 (cadr (textbox tent))

p1 (list (+ (car p0)

(- (* (car t1) cosrot) (* (cadr t1) sinrot)))

(+ (cadr p0)

(+ (* (car t1) sinrot) (* (cadr t1) cosrot))))

p2 (list (+ (car p0)

(- (* (car t2) cosrot) (* (cadr t1) sinrot)))

(+ (cadr p0)

(+ (* (car t2) sinrot) (* (cadr t1) cosrot))))

p3 (list (+ (car p0)

(- (* (car t2) cosrot) (* (cadr t2) sinrot)))

(+ (cadr p0)

(+ (* (car t2) sinrot) (* (cadr t2) cosrot))))

p4 (list (+ (car p0)

(- (* (car t1) cosrot) (* (cadr t2) sinrot)))

(+ (cadr p0)

(+ (* (car t1) sinrot) (* (cadr t2) cosrot))))


(list p1 p2 p3 p4)


(defun C:TXT2MTXT ( / mwid dset ibrk bitm bent sset rect mlay mcol mlst

bins bang tang nins num ndis chnd cent nhnd nstr

str pt1 pt2 pt3 dis dvx dvy dvz new)

(if (< (atoi (getvar "ACADVER")) 13)

(alert "This Function Requires\nRelease 13 or Higher")


(setq cmdecho (getvar "CMDECHO"))

(setvar "CMDECHO" 0)

(command "_.UNDO" "_G")

(setq mwid 0.0)

(setq dset (ssadd))


(initget "Y N")

(setq tmp (getkword "\nDS> Include Line Breaks <Y>/N: "))

(if (/= tmp "N")(setq ibrk "Y")(setq ibrk "N"))


(setq bitm (car (entsel "\nDS> Pick Base String: ")))

(setq bent (entget bitm))

(setq rect (textrect bent))

(setq chk (distance (car rect)(cadr rect)))

(if (> chk mwid)(setq mwid chk))


(if (= "TEXT" (cdr (assoc 0 bent)))


(redraw bitm 3)

(princ "\nDS> Select Remaining Text: ")

(setq sset (ssget '((0 . "TEXT"))))

(if sset


(setq rect (textrect bent))

(setq orig rect)

(setq mlay (cdr (assoc 8 bent)))

(setq mcol (cdr (assoc 62 bent)))

(setq mlst (list (cdr (assoc 1 bent))))


(if (> (cdr (assoc 72 bent)) 0)

(setq bins (cdr (assoc 11 bent)))

(setq bins (cdr (assoc 10 bent)))


(setq bang (cdr (assoc 50 bent)))

(setq tang (- bang (/ PI 2)))

(setq nins bins)

(ssdel bitm sset)

(while (> (sslength sset) 0)

(setq num (sslength sset) itm 0)

(setq ndis 99999999.9)

(while (< itm num)

(setq chnd (ssname sset itm))

(setq cent (entget chnd))

(if (> (cdr (assoc 72 cent)) 0)

(setq cins (cdr (assoc 11 cent)))

(setq cins (cdr (assoc 10 cent)))


(setq cdis (distance bins cins))

(if (< cdis ndis)

(setq ndis cdis nhnd chnd nent cent)


(setq itm (1+ itm))


(setq dset (ssadd nhnd dset))

(ssdel nhnd sset)


(setq rect (textrect nent))

(setq chk (distance (car rect)(cadr rect)))

(if (> chk mwid)(setq mwid chk))


(setq nstr (cdr (assoc 1 nent)))

(setq mlst (append mlst (list nstr)))



(entdel bitm)

(setq num (sslength dset) itm 0)

(while (< itm num)

(setq hnd (ssname dset itm))

(entdel hnd)

(setq itm (1+ itm))




(setvar "CLAYER" mlay)

(if (/= mcol nil)

(setvar "CECOLOR" (col2str mcol))


(setq mwid (+ mwid (* mwid 0.025)))

(setq pt1 (car orig))

(setq pt2 (cadr orig))

(setq dis (distance pt1 pt2))

(setq dvx (/ (- (car pt2)(car pt1)) dis))

(setq dvy (/ (- (cadr pt2)(cadr pt1)) dis))

(setq pt3 (list dvx dvy 0.0))

(setq nins (list (car (cadddr orig))

(cadr (cadddr orig))

(nth 2 (cdr (assoc 10 bent)))))


(setq new '((0 . "MTEXT")(100 . "AcDbEntity")(100 . "AcDbMText")))

(setq new (append new (list (assoc 7 bent))))

(setq new (append new (list (assoc 8 bent))))

(setq new (append new (list (cons 10 nins))))

(setq new (append new (list (cons 11 pt3))))

(foreach lin mlst

(if (= ibrk "Y")

(if (/= lin (last mlst))

(setq lin (strcat lin "\\P"))


(setq lin (strcat lin " "))


(setq new (append new (list (cons 1 lin))))


(setq new (append new (list (assoc 40 bent))))

(setq new (append new (list (cons 41 mwid))))

(setq new (append new (list (cons 71 1))))

(setq new (append new (list (cons 72 1))))

(entmake new)



(setq sset nil)

(setq dset nil)

(setq lst nil)

(command "_.UNDO" "_E")

(setvar "CMDECHO" cmdecho)


(redraw bitm 4)






(setq sset nil)

(setq mlst nil)



Share this post

Link to post
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.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...
Aspetta! x