Author Topic: Fonts for grvecs  (Read 11676 times)

0 Members and 1 Guest are viewing this topic.

hanhphuc

  • Newt
  • Posts: 64
Re: Fonts for grvecs
« Reply #30 on: May 25, 2014, 05:20:25 PM »
hi all, here i attempted dxf-modify method in order to justify code 71 .Then i applied a lambda to determine the best quadrant if the text reaches each end corner, so it can be seen (not exceed screen or hidden)
lastly, applied to suit current UCS. thank you
i remarked with double asterisk **
Code: [Select]

;"Grread with MTEXT by ymg"
; version: ymg -> reltro -> alanjt
; http://www.theswamp.org/index.php?action=post;msg=521731;topic=46966.30
; similar reference tread http://www.lee-mac.com/grtext.html

; ** --> partial commented with ** attempted by hanhphuc
(defun c:test (/ etxt p prvtext scl str txt txtp xog yof ini*error* catch
                              vec ); **
 
    (defun ini*error* (name sysvars / *doc*)
        (vla-startundomark (setq *doc* (vla-get-activedocument (vlax-get-acad-object))))
        (eval
            (list 'defun '*error* '(msg / )
                (list
                    (lambda (name prevErrorHandler SysVars *doc* currentcmdecho / )
                        (mapcar
                            'setvar
                            (mapcar 'car SysVars)
                            (mapcar 'cdr SysVars)
                        )
                        (vla-endundomark *doc*)
                        (setq *error* prevErrorHandler)
                        (if msg
                            (progn
                                (setvar 'cmdecho 0)
                                (command-s "_.undo" 1 "")
                                (setvar 'cmdecho currentcmdecho)
                               
                                (princ "\n*** error ***\n")
                                (princ (strcat "\t" name ": " (vl-princ-to-string msg) "\n"))
                               
                                (*error* msg)
                                (princ)
                            )
                        )
                    )
                    (vl-princ-to-string name)
                    *error*
                    (list 'quote
                        (mapcar
                            '(lambda (a / ) (cons a (getvar a)))
                            sysvars
                        )
                    )
                    *doc*
                    (getvar 'cmdecho)
                )
            )
        )
    )
   
    (ini*error*
        "Grread with MTEXT - ymg"
        '("CLAYER" "OSMODE" "CMDECHO" "DIMZIN")
    )
   
    (setvar 'osmode 0)
    (setq catch
        (vl-catch-all-apply
            '(lambda ( / )
       
;|**
              (setq
  xof 30
  yof -30
  scl (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
)|; ;**
   
(while
 
(= 5 (car (setq p (grread nil 13 0))))

(setq Vcp (trans (getvar "viewctr") 1 0)                            ; ** setq vcp
      scl (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
      p   (trans (cadr p) 1 0 t)                             ; ** trans
      vec                             ; ** setq vec
  (mapcar
    '(lambda (x)
       (equal (mapcar '>= p Vcp) x)
     )
    '((T T T) (nil T T) (nil nil T) (T nil T))
  )                                                          ; ** mapcar
)

(cond ((nth 0 vec)
       (setq xof -15
     yof -15
       )
      )
      ((nth 1 vec)
       (setq xof 15
     yof -15
       )
      )
      ((nth 2 vec)
       (setq xof 15
     yof 15
       )
      )
      ((nth 3 vec)
       (setq xof -15
     yof 15
       )
      )
) ; ** cond
 
 
                   (setq
;;; p (cadr p)                               ; ** removed
     
                      str (mapcar 'rtos (trans p 0 1))        ; ** trans UCS

     
                     txtp (list (+ (car  p) (* xof scl)) (+ (cadr p) (* yof scl)))
                      txt (strcat  "X= " (car str) "\\PY= " (cadr str))
                   )

                   (setq etxt (list (cons 0 "MTEXT")
                            (cons 100 "AcDbEntity")
                            (cons 62 2)
                            (cons 100 "AcDbMText")
                            (cons 10 txtp)
                            (cons 40 (* 10 scl)) 
                            (cons 1 txt)
                       )
                   )


;| **
(if prvtext
  (entdel prvtext)
)
|; ;**


(if
prvtext

(mapcar '(lambda (x y) (dxfmod prvtext x y))
        '(10 40 1 62) (list txtp (* 10 scl) txt 2))
 
(setq prvtext (entmakex etxt))

  ) ; ** dxfmod & entmakex


(cond ((nth 0 vec) (dxfmod prvtext 71 3))
      ((nth 1 vec) (dxfmod prvtext 71 1))
      ((nth 2 vec) (dxfmod prvtext 71 7))
      ((nth 3 vec) (dxfmod prvtext 71 9))
) ; ** cond

;;;(setq prvtext (entlast))        ; **


); while
 
(if prvtext (entdel prvtext))

(princ )
 

 
                )
            )
        )
    )

;;;(setq prvtext  (entmakex etxt)); **

    (if (vl-catch-all-error-p catch)
        (progn
            (*error* (vl-catch-all-error-message catch))
            catch
        )
        (*error* nil)
    )


; ** hp#007
(defun dxfmod (_e _i val / lst ) ; (dxfmod entity index new-value )
  (setq lst (entget _e)) ; old dxf list
  (if (assoc _i lst)
    (entmod (subst (cons _i val)
   (assoc _i lst)
   lst
    )
    ) ;subst old to new
    (entmod (append lst (list (cons _i val)))) ; add new to dxf
  ) ; if
  (princ)
); **

« Last Edit: May 25, 2014, 08:43:21 PM by hanhphuc »
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

reltro

  • Guest
Re: Fonts for grvecs
« Reply #31 on: May 28, 2014, 04:57:52 AM »
Hey People...
Short time ago I wrote a python-script to extract information out of a .pt3 (Font) to generate a lisp-function wich calculates the vertices of a text for the use with grvecs...

curves in the original font are ignored.

Wanna share some Fonts, and if somebody wants, the python-script...

greets
reltro
Great works !
dose these font-vectors maked by some tools ,which has a function tanslate shape into vectors ?

Hey chlh_jd...
Sry for the late response...
hm, I think I don't fully understand ur question... Wich kind of shapes do u mean?

The PythonScript I wrote is just a "parser" wich extracts the information found in a .pc3... Just hacked it togheter to fit my needs, so there is no functionality other than calculating the vectors of the Font... Specially for the use with (grvecs ...)

Sent u the PythonScript so u can look at ur own...

reltro
« Last Edit: May 28, 2014, 05:07:19 AM by reltro »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fonts for grvecs
« Reply #32 on: May 29, 2014, 01:04:54 PM »
reltro,

I'd like to have a look at that script too, if you don't mind.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

reltro

  • Guest
Re: Fonts for grvecs
« Reply #33 on: May 29, 2014, 01:24:25 PM »
reltro,

I'd like to have a look at that script too, if you don't mind.


sure...
attached is a .py-file (python 3.3 on windows)
use this (http://onlinefontconverter.com/) to convert a font-file to .pt3 and then drag'n'drop it on the .py

greets reltro

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Fonts for grvecs
« Reply #34 on: May 29, 2014, 03:06:53 PM »
Thanks, bookmarked.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

chlh_jd

  • Guest
Re: Fonts for grvecs
« Reply #35 on: June 02, 2014, 05:37:21 AM »
Hey People...
Short time ago I wrote a python-script to extract information out of a .pt3 (Font) to generate a lisp-function wich calculates the vertices of a text for the use with grvecs...

curves in the original font are ignored.

Wanna share some Fonts, and if somebody wants, the python-script...

greets
reltro
Great works !
dose these font-vectors maked by some tools ,which has a function tanslate shape into vectors ?

Hey chlh_jd...
Sry for the late response...
hm, I think I don't fully understand ur question... Wich kind of shapes do u mean?

The PythonScript I wrote is just a "parser" wich extracts the information found in a .pc3... Just hacked it togheter to fit my needs, so there is no functionality other than calculating the vectors of the Font... Specially for the use with (grvecs ...)

Sent u the PythonScript so u can look at ur own...

reltro

Thank you very much .