Author Topic: help fix code for mtext to text  (Read 2288 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
help fix code for mtext to text
« on: January 29, 2008, 02:44:59 PM »
i have a partial code here to an old lisp that inserts text from a file
line by line. however it inserts it as mtext and at a set width and i would like to if anyone can tell me what to change to make it work. everything i change that i think it could be, just gives me errors when i try to run it.
any help is appreciated
Code: [Select]
(defun INSRT (/ NEWTXT INS1 TXTHT INDX TEXTLINE)
   (setq INS1    (getpoint "\nChoose Insert Point For Mtext: ")
         TXTHT   (* 0.125 (getvar "DIMSCALE"))
         COUNTER 0
         NEWTXT  ""
   ) ;_ end of setq
   (while (/= PICK "")
      (setq INDX     (read PICK)
            TEXTLINE (nth INDX TXTLIST)
      ) ;_ end of setq
      (if (/= INDX 0)
         (progn (setq COUNTER (1+ COUNTER)
                      COUNTER (itoa COUNTER)
                      NEWTXT  (strcat NEWTXT TEXTLINE)
                      COUNTER (atoi COUNTER)
                ) ;_ end of setq
         ) ;progn
      ) ;if
      (cond ((< INDX 10) (setq PICK (substr PICK 3)))
            ((and (< INDX 100) (> INDX 9)) (setq PICK (substr PICK 4)))
            ((> INDX 99) (setq PICK (substr PICK 5)))
      ) ;cond
   ) ;while
   (entmake (list '(0 . "mtext")
                  '(100 . "AcDbEntity")
                  '(67 . 0)
                  '(8 . "0")
                  '(100 . "AcDbmText")
                  (list '10 (car INS1) (cadr INS1) (caddr INS1))
                  (cons '40 TXTHT)
                  (cons '41 (* 4.0 (getvar "dimscale")))
                  '(71 . 1)
                  '(72 . 1)
                  (cons '1 NEWTXT)
                  '(7 . "ROMANS")
                  '(210 0.0 0.0 1.0)
                  '(11 1.0 0.0 0.0)
            ) ;_ end of list
   )
       
)

lispman21

  • Guest
Re: help fix code for mtext to text
« Reply #1 on: January 30, 2008, 09:44:51 AM »
Give this a try.  I noted what i changed in the code itself

Code: [Select]
(defun INSRT (/ NEWTXT INS1 TXTHT INDX TEXTLINE)
   (setq INS1    (getpoint "\nChoose Insert Point For Mtext: ")
         TXTHT   (* 0.125 (getvar "DIMSCALE"))
         COUNTER 0
         NEWTXT  ""
   ) ;_ end of setq
   (while (/= PICK "")
      (setq INDX     (read PICK)
            TEXTLINE (nth INDX TXTLIST)
      ) ;_ end of setq
      (if (/= INDX 0)
         (progn (setq COUNTER (1+ COUNTER)
                      COUNTER (itoa COUNTER)
                      NEWTXT  (strcat NEWTXT TEXTLINE)
                      COUNTER (atoi COUNTER)
                ) ;_ end of setq
         ) ;progn
      ) ;if
      (cond ((< INDX 10) (setq PICK (substr PICK 3)))
            ((and (< INDX 100) (> INDX 9)) (setq PICK (substr PICK 4)))
            ((> INDX 99) (setq PICK (substr PICK 5)))
      ) ;cond
   ) ;while
   (entmake (list '(0 . "TEXT") ;; Changed from Mtext to TEXT
                  '(100 . "AcDbEntity")
                  '(67 . 0)
                  '(8 . "0")
                  '(100 . "AcDbText") ;; Change from AcDbmText to AcDbText
                  (list '10 (car INS1) (cadr INS1) (caddr INS1))
                  (cons '40 TXTHT)
                  (cons '41 (* 4.0 (getvar "dimscale")))
                  '(71 . 1)
                  '(72 . 1)
                  (cons '1 NEWTXT)
                  '(7 . "ROMANS")
                  '(210 0.0 0.0 1.0)
                  '(11 1.0 0.0 0.0)
            ) ;_ end of list
   )
       
)

andrew_nao

  • Guest
Re: help fix code for mtext to text
« Reply #2 on: January 30, 2008, 01:23:27 PM »
thanks for the reply, i changed those lines to that before i posted it here and it didnt help untill i removed these lines

                  '(67 . 0)
                  '(8 . "0")
                  (cons '41 (* 4.0 (getvar "dimscale")))
                  '(72 . 1)
                  '(7 . "ROMANS")
                  '(210 0.0 0.0 1.0)
                  '(11 1.0 0.0 0.0)

it works how i want it now
thanks for the reply

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: help fix code for mtext to text
« Reply #3 on: January 30, 2008, 05:09:09 PM »
The DXF codes in Mtext objects are not all the same as the Text objects.
This is all you need
Code: [Select]
  (entmake (list '(0 . "TEXT")
                 '(8 . "0") ; Layer
                 (list 10 INS1)
                 (cons 40 TXTHT)
                 (cons 41 1.0) ; width factor
                 (cons 1 NEWTXT)
                 '(7 . "ROMANS") ; text style
           )
  )

May I ask what this routine is supposed to be doing?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

andrew_nao

  • Guest
Re: help fix code for mtext to text
« Reply #4 on: January 31, 2008, 11:01:36 AM »
The DXF codes in Mtext objects are not all the same as the Text objects.
This is all you need
Code: [Select]
  (entmake (list '(0 . "TEXT")
                 '(8 . "0") ; Layer
                 (list 10 INS1)
                 (cons 40 TXTHT)
                 (cons 41 1.0) ; width factor
                 (cons 1 NEWTXT)
                 '(7 . "ROMANS") ; text style
           )
  )

May I ask what this routine is supposed to be doing?


thanks for the help
this lisp is supposed to read a txt file and insert that whole line of text into cad as plain text not mtext.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: help fix code for mtext to text
« Reply #5 on: January 31, 2008, 11:09:18 AM »
I just did not see what these were for:
NEWTXT TEXTLINE COUNTER IDX
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

andrew_nao

  • Guest
Re: help fix code for mtext to text
« Reply #6 on: January 31, 2008, 01:10:46 PM »
I just did not see what these were for:
NEWTXT TEXTLINE COUNTER IDX
it was old code from another lisp that the coder before me wrote
i borrowed some of his code to make something else and just removed that bit of the code