Author Topic: Fonts for grvecs  (Read 11663 times)

0 Members and 1 Guest are viewing this topic.

reltro

  • Guest
Fonts for grvecs
« on: May 03, 2014, 02:32:39 PM »
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
« Last Edit: May 03, 2014, 02:43:52 PM by reltro »

NICK_VNV

  • Newt
  • Posts: 63
Re: Fonts for grvecs
« Reply #1 on: May 03, 2014, 03:17:48 PM »
It's interesting,  I would like to see the python script too  :-D
Sorry for my English...

reltro

  • Guest
Re: Fonts for grvecs
« Reply #2 on: May 04, 2014, 09:05:05 AM »
@NICK_VNV: sent it as PM

Greets
reltro

NICK_VNV

  • Newt
  • Posts: 63
Re: Fonts for grvecs
« Reply #3 on: May 04, 2014, 01:25:18 PM »
Thanks! It works fine  :-)
But i can't find the way for covert my font to *.pt3 format which contains not only english letters? (I want to use other languages too) Maybe somebody know?
Sorry for my English...

Inciner

  • Guest
Re: Fonts for grvecs
« Reply #4 on: May 08, 2014, 05:43:24 PM »
Excellent! Can I get python code too?

Inciner

  • Guest
Re: Fonts for grvecs
« Reply #5 on: May 08, 2014, 06:54:34 PM »
I also love solution, provided by Lee Mac at his Grtext lisp demo.
http://lee-mac.com/grtext.html
It's very flexible on my mind.

reltro

  • Guest
Re: Fonts for grvecs
« Reply #6 on: May 09, 2014, 06:02:02 AM »
@Inciner:
Python-script as PM

Oh, thats nice... I used LeeMac's Grtext too, but I never got the Point how the Chars are calculated; nice method... :)
But in use the displayed text wasn't very good to read, so I decided to go for an other approach...

@NICK_VNV:
I never used a not englisch/latin Font because I don't need them... So, I can't help.
Beside, there is much more information in the .pt3 than the python-script extract.
If u find a way to use non-latin chars/fonts let us know how to do...

Greets reltro

Inciner

  • Guest
Re: Fonts for grvecs
« Reply #7 on: May 09, 2014, 10:41:44 AM »
I was drawing cyrillic symbols for Lee Mac's solution right in Libre Office whole yesterday.
Thank you for script! =)

ymg

  • Guest
Re: Fonts for grvecs
« Reply #8 on: May 09, 2014, 03:49:35 PM »
If you entmakex your text there is no need
for transforming fonts.

Code: [Select]
(defun c:test (/ etxt p prvtext scl str txt txtp xog yof)
   (setq  xof 30
    yof -30
          scl (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
   )
   (while (= 5 (car (setq p (grread nil 13 0))))
      (setq    p (cadr p)
     str (mapcar 'rtos p)
    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 (* 15 scl))
       (cons 1 txt)
  )
      )
      (if prvtext (entdel prvtext))
      (setq prvtext  (entmakex etxt))
   )
   (entdel prvtext)
)
« Last Edit: May 09, 2014, 03:56:31 PM by ymg »

reltro

  • Guest
Re: Fonts for grvecs
« Reply #9 on: May 10, 2014, 07:49:17 AM »
Hey ymg...

it is a nice approach...
but, in this case u need also an *error*-handler, or better a vl-catch-all-apply... If not, the mtext will be there if the user hits ESC for Example; but I'm sure u knew this ;)

I prefer the grvecs-method to avoid something like this.
Also, if I need to draw a lot of stuff I prefer the grvecs-method... Put all together in a list and draw it ;)

Greets
« Last Edit: May 10, 2014, 09:27:42 AM by reltro »

ymg

  • Guest
Re: Fonts for grvecs
« Reply #10 on: May 10, 2014, 08:45:38 AM »
reltro,

If you want to catch Escape Key, here is the modified code:

Code: [Select]
(defun c:test (/ etxt p prvtext scl str txt txtp xog yof)
 
   ; Error Handler by ElpanovEvgenyi  ;
   (defun *error* (msg)
(mapcar 'eval varl)
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")))
           (princ (strcat "\nError: " msg))
        )
        (if prvtext (entdel prvtext))
(and *AcadDoc* (vla-endundomark *AcadDoc*))
        (princ)
    )
     
    (setq varl '("CLAYER" "OSMODE" "CMDECHO" "DIMZIN")
          varl (mapcar (function (lambda (a) (list 'setvar a (getvar a)))) varl)
    )

    (setq xof 30
          yof -30
          scl (/ (getvar 'viewsize) (cadr (getvar 'screensize)))
    )
    (while (= 5 (car (setq p (grread nil 13 0))))
       (setq    p (cadr p)
      str (mapcar 'rtos p)
     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 (* 15 scl))
        (cons 1 txt)
   )
       )
       (if prvtext (entdel prvtext))
       (setq prvtext  (entmakex etxt))
    )
    (entdel prvtext)
    (*error* nil)
)

reltro

  • Guest
Re: Fonts for grvecs
« Reply #11 on: May 10, 2014, 01:28:39 PM »
whats about this? ;)
Code: [Select]
(vl-catch-all-apply '(lambda (/) (C:test)))
and then pressing Escape? ;)
(sry, just trolling a lil bit)

Greets

ymg

  • Guest
Re: Fonts for grvecs
« Reply #12 on: May 10, 2014, 01:33:54 PM »
Would rather use an error handler.

The vl-catch-all-apply will not reset your sysvars or your layer.

ymg

reltro

  • Guest
Re: Fonts for grvecs
« Reply #13 on: May 10, 2014, 02:31:15 PM »
whats about a combination of *error*-handler and vl-catch-all-apply?

Code: [Select]
(defun c:test (/ etxt p prvtext scl str txt txtp xog yof ini*error* catch)
 
    (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    p (cadr p)
                      str (mapcar 'rtos p)
                     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 (* 15 scl))             
                            (cons 1 txt)
                       )
                   )
                   (if prvtext (entdel prvtext))
                   (setq prvtext  (entmakex etxt))
                )
            )
        )
    )
    (entdel prvtext)
    (if (vl-catch-all-error-p catch)
        (progn
            (*error* (vl-catch-all-error-message catch))
            catch
        )
        (*error* nil)
    )
)

I'm not sure if this is good practice...

reltro
« Last Edit: May 10, 2014, 03:03:13 PM by reltro »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Fonts for grvecs
« Reply #14 on: May 10, 2014, 11:43:21 PM »
whats about a combination of *error*-handler and vl-catch-all-apply?

Code: [Select]
(defun c:test (/ etxt p prvtext scl str txt txtp xog yof ini*error* catch)
 
    (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    p (cadr p)
                      str (mapcar 'rtos p)
                     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 (* 15 scl))             
                            (cons 1 txt)
                       )
                   )
                   (if prvtext (entdel prvtext))
                   (setq prvtext  (entmakex etxt))
                )
            )
        )
    )
    (entdel prvtext)
    (if (vl-catch-all-error-p catch)
        (progn
            (*error* (vl-catch-all-error-message catch))
            catch
        )
        (*error* nil)
    )
)

I'm not sure if this is good practice...

reltro

I did this several years ago, but it may be of interest: http://www.theswamp.org/index.php?topic=30660.0
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox