Тема: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Программа копирует текст из:
DText, MText, Таблиц, Размер, Атрибуты, Определения Атрибутов, DText и MText в составе блоков
в:
DText, MText, Таблицы, Размеры, Атрибуты, Определения Атрибутов.
Опция Specify mode [Multiple/Pair-wise] позволяет выбрать между копированием между копированием одной строки во множество объектов (Multiple) и попарным копированием (Pair-wise) что удобно к примеру при заполнении таблиц.

(defun c:ttc (/ actDoc vlaObj sObj sText curObj
          oType oldMode conFlag errFlag *error*)
  (vl-load-com)
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-acad-object)))
      (vla-StartUndoMark actDoc)
  (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
                       hitRes Row Column)
    (setq errFlag nil)
    (if
     (setq nslLst(nentsel "\nPaste text >"))
      (progn
    (cond
      (
       (and
         (= 4(length nslLst))
         (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst)))))))
       (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
         'vla-put-TextOverride(list vlaObj pasteStr)))
           (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
       ); end condition #1
      (
       (and
         (= 4(length nslLst))
         (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst))))))
         hitPt(vlax-3D-Point(cadr nslLst))
         hitRes(vla-HitTest vlaObj hitPt
              (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
               ); end setq
       (if(= :vlax-true hitRes)
         (progn
           (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-SetText(list vlaObj Row Column pasteStr)))
         (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
           ); end progn
         ); end if
       ); end condition # 2
      (
       (and
         (= 4(length nslLst))
         (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (princ "\nCan't paste to block's DText or MText. ")
       (setq errFlag T)
       ); end condition #3
      (
       (and
         (= 2(length nslLst))
             (member(cdr(assoc 0(entget(car nslLst))))
             '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object(car nslLst)))
          (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-put-TextString(list vlaObj pasteStr)))
        (progn
           (princ "\nError. Can't pase text. ")
          (setq errFlag T)
          ); end progn
         ); end if
       ); end condition #4
      (T
       (princ "\nCan't paste. Invalid object. ")
       (setq errFlag T)
       ); end condition #5
      ); end cond
             T
        ); end progn
            nil
           ); end if
    ); end of TTC_Paste
    (defun TTC_MText_Clear(Mtext / Text Str)
    (setq Text "")
    (while(/= Mtext "")
      (cond
    ((wcmatch
       (strcase
           (setq Str
              (substr Mtext 1 2)))
                         "\\[\\{}`~]")
     (setq Mtext(substr Mtext 3)
           Text(strcat Text Str)
     ); end setq
    ); end condition #1
    ((wcmatch(substr Mtext 1 1) "[{}]")
      (setq Mtext
         (substr Mtext 2))
    ); end condition #2
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[LOP]")
      (setq Mtext(substr Mtext 3))
    ); end condition #3
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[ACFHQTW]")
      (setq Mtext
         (substr Mtext
             (+ 2
                (vl-string-search ";" Mtext))))
    ); end condition #4
    ((wcmatch
       (strcase (substr Mtext 1 2)) "\\S")
      (setq Str(substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
            Text(strcat Text (vl-string-translate "#^\\" " " Str))
            Mtext(substr Mtext (+ 4 (strlen Str)))
     ); end setq
     (print Str)
    ); end condition #5
    (T
     (setq Text(strcat Text(substr Mtext 1 1))
           Mtext (substr Mtext 2)
     )
    ); end condition #6
      ); end cond
    ); end while
  Text
); end of TTC_MText_Clear
  (defun TTC_Copy (/ sObj sText tType actDoc)
   (if
    (and
     (setq sObj(car(nentsel "\nCopy text... ")))
     (member(setq tType(cdr(assoc 0(entget sObj))))
        '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
     ); end and
    (progn
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-Acad-object))
        sText(vla-get-TextString
           (vlax-ename->vla-object sObj))
        ); end setq
      (if(= tType "MTEXT")
    (setq sText(TTC_MText_Clear sText))
    ); end if
      ); end progn
    ); end if
    sText
    ); end of TTC_Copy
  (defun CCT_Str_Echo(paseStr / comStr)
    (if(< 20(strlen paseStr))
        (setq comStr
           (strcat
             (substr paseStr 1 17)"..."))
        (setq comStr paseStr)
        ); end if
      (princ
        (strcat "\nText = \"" comStr "\""))
    (princ)
    ); end of CCT_Str_Echo
    (defun *error*(msg)
    (vla-EndUndoMark
      (vla-get-ActiveDocument
            (vlax-get-acad-object)))
    (princ "\nQuit TTC")
    (princ)
    ); end of *error*
    (if(not ttc:Mode)(setq ttc:Mode "Multiple"))
    (initget "Multiple Pair-wise")
    (setq oldMode ttc:Mode
      ttc:Mode
       (getkword
         (strcat "\nSpecify mode [Multiple/Pair-wise] <"ttc:Mode">: "))
      conFlag T
      paseStr ""
       ); end setq
    (if(null ttc:Mode)(setq ttc:Mode oldMode))
    (if(= ttc:Mode "Multiple")
      (progn
    (if(and(setq paseStr(TTC_Copy))conFlag)
      (progn
      (CCT_Str_Echo paseStr)
      (while(setq conFlag(TTC_Paste paseStr))T
        ); end while
      ); end progn
      ); end if
    ); end progn
      (progn
    (while
      (and conFlag paseStr)
      (setq paseStr(TTC_Copy))
      (if(and paseStr conFlag)
        (progn
      (CCT_Str_Echo paseStr)
      (setq errFlag T)
      (while errFlag
      (setq conFlag(TTC_Paste paseStr))
           );end while
         ); end progn
        ); end if
      ); end while
    ); end progn
      ); end if
   (vla-EndUndoMark actDoc)
   (princ "\nQuit TTC")
  (princ)
  ); end c:ttc

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Вопросы можно задавать?

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> Forma

Вопросы можно задавать?

Ты уже задал один :)
>Admin
Ой, прочитал текст своего постинга и ужаснулся! Если можно подправьте. Поздно ночью писал, на код сил хватило, а на то чтобы перечитать сообщение и заголовок нет :(

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Ничего не понял. Это как в Одессе:
"Мне стакан воды без сиропа"
"Без какого сиропа?"
Ладно. Это была шутка. Теперь по делу.
Нужно скопировать колонку однострочных текстов
На (в) другую колонку. Программа это делает?

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Нужно скопировать колонку однострочных текстов
На (в) другую колонку. Программа это делает?

Нет только по одному, зато откуда угодно и куда угодно. А почему бы не скопировать сами тексты?

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

{Smirnoff} пишет:

А почему бы не скопировать сами тексты?

По одному? Такая программа есть.
https://www.caduser.ru/forum/topic19303.html
Я ей пользуюсь постоянно. Но для повышения производительности хотелось бы и пакетом.

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> Forma
Похожая есть, но у этой функциональность намного выше. Если вы почитаете предпоследний постинг Vova по указанной ссылке, то поймёте чью просьбу я выполнял при написании данной програмы. Она и с таблицами работает, и с MText, вычищая при копировании "грязь" от форматирования и режим попарного копирования имеет.
Вот программа которая производила бы ту же самую операцию с несколькими строками одновременно, во первых более узко специализированная, во вторых вызывает много вопросов. К примеру как поступать если число строк "источников" не равно количеству строк "целей"? Или как определять порядок в котором производится копирование? Тоже кстати вопрос! Так что такую "узко-заточенную" поделку для вас конечно может кто нибудь написать, однако это програма ИМХО это только для вас лично...

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> {Smirnoff}
Понятно. У нас с Vova разные задачи и соответственно разные подходы. В любом случае спасибо.
p.s. Это не Вы сделали для меня пр-му по поиску и удалению дубликатов?

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Forma пишет:

p.s. Это не Вы сделали для меня пр-му по поиску и удалению дубликатов?

Было дело.

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> {Smirnoff}
В таком случае примите от меня благодарность.
Очень хорошая программа. Помогает каждый день.
Огромное спасибо.

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Немного подправил код. При копировании из MText в котором строки переводились нажатием Enter в месте перевода строки не вставлялся пробел и слова сливались.

(defun c:ttc (/ actDoc vlaObj sObj sText curObj oldForm
          oType oldMode conFlag errFlag *error*)
  (vl-load-com)
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-acad-object)))
      (vla-StartUndoMark actDoc)
  (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
                       hitRes Row Column)
    (setq errFlag nil)
    (if
     (setq nslLst(nentsel "\nPaste text >"))
      (progn
    (cond
      (
       (and
         (= 4(length nslLst))
         (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst)))))))
       (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
         'vla-put-TextOverride(list vlaObj pasteStr)))
           (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
       ); end condition #1
      (
       (and
         (= 4(length nslLst))
         (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst))))))
         hitPt(vlax-3D-Point(cadr nslLst))
         hitRes(vla-HitTest vlaObj hitPt
              (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
               ); end setq
       (if(= :vlax-true hitRes)
         (progn
           (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-SetText(list vlaObj Row Column pasteStr)))
         (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
           ); end progn
         ); end if
       ); end condition # 2
      (
       (and
         (= 4(length nslLst))
         (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (princ "\nCan't paste to block's DText or MText. ")
       (setq errFlag T)
       ); end condition #3
      (
       (and
         (= 2(length nslLst))
             (member(cdr(assoc 0(entget(car nslLst))))
             '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object(car nslLst)))
          (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-put-TextString(list vlaObj pasteStr)))
        (progn
           (princ "\nError. Can't pase text. ")
          (setq errFlag T)
          ); end progn
         ); end if
       ); end condition #4
      (T
       (princ "\nCan't paste. Invalid object. ")
       (setq errFlag T)
       ); end condition #5
      ); end cond
             T
        ); end progn
            nil
           ); end if
    ); end of TTC_Paste
    (defun TTC_MText_Clear(Mtext / Text Str)
    (setq Text "")
    (while(/= Mtext "")
      (cond
    ((wcmatch
       (strcase
           (setq Str
              (substr Mtext 1 2)))
                         "\\[\\{}`~]")
     (setq Mtext(substr Mtext 3)
           Text(strcat Text Str)
     ); end setq
    ); end condition #1
    ((wcmatch(substr Mtext 1 1) "[{}]")
      (setq Mtext
         (substr Mtext 2))
    ); end condition #2
    (
     (and
     (wcmatch
       (strcase
         (substr Mtext 1 2)) "\\P")
     (/=(substr Mtext 3 1) " ")
      ); end and
         (setq Mtext (substr Mtext 3)
               Text (strcat Text " ")
         ); end setq
     ); end condition #3
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[LOP]")
      (setq Mtext(substr Mtext 3))
    ); end condition #4
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[ACFHQTW]")
      (setq Mtext
         (substr Mtext
             (+ 2
                (vl-string-search ";" Mtext))))
    ); end condition #5
    ((wcmatch
       (strcase (substr Mtext 1 2)) "\\S")
      (setq Str(substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
            Text(strcat Text (vl-string-translate "#^\\" " " Str))
            Mtext(substr Mtext (+ 4 (strlen Str)))
     ); end setq
     (print Str)
    ); end condition #6
    (T
     (setq Text(strcat Text(substr Mtext 1 1))
           Mtext (substr Mtext 2)
     )
    ); end condition #7
      ); end cond
    ); end while
  Text
); end of TTC_MText_Clear
  (defun TTC_Copy (/ sObj sText tType actDoc)
   (if
    (and
     (setq sObj(car(nentsel "\nCopy text... ")))
     (member(setq tType(cdr(assoc 0(entget sObj))))
        '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
     ); end and
    (progn
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-Acad-object))
        sText(vla-get-TextString
           (vlax-ename->vla-object sObj))
        ); end setq
      (if(= tType "MTEXT")
    (setq sText(TTC_MText_Clear sText))
    ); end if
      ); end progn
    ); end if
    sText
    ); end of TTC_Copy
  (defun CCT_Str_Echo(paseStr / comStr)
    (if(< 20(strlen paseStr))
        (setq comStr
           (strcat
             (substr paseStr 1 17)"..."))
        (setq comStr paseStr)
        ); end if
      (princ
        (strcat "\nText = \"" comStr "\""))
    (princ)
    ); end of CCT_Str_Echo
    (defun *error*(msg)
    (vla-EndUndoMark
      (vla-get-ActiveDocument
            (vlax-get-acad-object)))
    (princ "\nQuit TTC")
    (princ)
    ); end of *error*
    (if(not ttc:Mode)(setq ttc:Mode "Multiple"))
    (initget "Multiple Pair-wise")
    (setq oldMode ttc:Mode
      ttc:Mode
       (getkword
         (strcat "\nSpecify mode [Multiple/Pair-wise] <"ttc:Mode">: "))
      conFlag T
      paseStr ""
       ); end setq
    (if(null ttc:Mode)(setq ttc:Mode oldMode))
    (if(= ttc:Mode "Multiple")
      (progn
    (if(and(setq paseStr(TTC_Copy))conFlag)
      (progn
      (CCT_Str_Echo paseStr)
      (while(setq conFlag(TTC_Paste paseStr))T
        ); end while
      ); end progn
      ); end if
    ); end progn
      (progn
    (while
      (and conFlag paseStr)
      (setq paseStr(TTC_Copy))
      (if(and paseStr conFlag)
        (progn
      (CCT_Str_Echo paseStr)
      (setq errFlag T)
      (while errFlag
      (setq conFlag(TTC_Paste paseStr))
           );end while
         ); end progn
        ); end if
      ); end while
    ); end progn
      ); end if
   (vla-EndUndoMark actDoc)
   (princ "\nQuit TTC")
  (princ)
  ); end c:ttc

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Была рядовая программа, созданная для редактирования текстов по образцу. С включением в нее возможности использовать таблицы в качестве как источника текста, так и его приемника, программа стала уникальной. Таблицы это то, что умеет делать автокад-2005 и выше. Я начал осваивать таблицы некоторое время назад. Затем мой чертеж продолжил другой. Несмотря на то, что 2005 у него дома уже больше года, а 2006 на работе пол-года, он понятия не имел о таблице, и взорвал ее. А затем размножил обрывки и продолжал работать. Когда узнал, я был вне себя. Теперь можно легко починить. Но, пожалуй, заставлю его сделать это вручную. Просьба не комментировать последний авзац, чтобы не засорять ветку. Здесь должны быть только отзывы, да найденные неправильности. А я все это описал на правах заказчика. Спасибо, {Smirnoff}

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Исправил и ещё одну недоработку. Копирование в Таблицы неработал в UCS. Теперь работает.

(defun c:ttc (/ actDoc vlaObj sObj sText curObj oldForm
          oType oldMode conFlag errFlag *error*)
  (vl-load-com)
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-acad-object)))
      (vla-StartUndoMark actDoc)
  (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
                       hitRes Row Column)
    (setq errFlag nil)
    (if
     (setq nslLst(nentsel "\nPaste text >"))
      (progn
    (cond
      (
       (and
         (= 4(length nslLst))
         (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst)))))))
       (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
         'vla-put-TextOverride(list vlaObj pasteStr)))
           (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
       ); end condition #1
      (
       (and
         (= 4(length nslLst))
         (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object
            (cdr(assoc -1(entget(car(last nslLst))))))
         hitPt(vlax-3D-Point(trans(cadr nslLst)1 0))
         hitRes(vla-HitTest vlaObj hitPt
              (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
               ); end setq
       (if(= :vlax-true hitRes)
         (progn
           (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-SetText(list vlaObj Row Column pasteStr)))
         (progn
           (princ "\n Can't paste. Object may be on locked layer. ")
           (setq errFlag T)
           ); end progn
         ); end if
           ); end progn
         ); end if
       ); end condition # 2
      (
       (and
         (= 4(length nslLst))
         (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
         ); end and
       (princ "\nCan't paste to block's DText or MText. ")
       (setq errFlag T)
       ); end condition #3
      (
       (and
         (= 2(length nslLst))
             (member(cdr(assoc 0(entget(car nslLst))))
             '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
         ); end and
       (setq vlaObj
          (vlax-ename->vla-object(car nslLst)))
          (if
         (vl-catch-all-error-p
           (vl-catch-all-apply
             'vla-put-TextString(list vlaObj pasteStr)))
        (progn
           (princ "\nError. Can't pase text. ")
          (setq errFlag T)
          ); end progn
         ); end if
       ); end condition #4
      (T
       (princ "\nCan't paste. Invalid object. ")
       (setq errFlag T)
       ); end condition #5
      ); end cond
             T
        ); end progn
            nil
           ); end if
    ); end of TTC_Paste
    (defun TTC_MText_Clear(Mtext / Text Str)
    (setq Text "")
    (while(/= Mtext "")
      (cond
    ((wcmatch
       (strcase
           (setq Str
              (substr Mtext 1 2)))
                         "\\[\\{}`~]")
     (setq Mtext(substr Mtext 3)
           Text(strcat Text Str)
     ); end setq
    ); end condition #1
    ((wcmatch(substr Mtext 1 1) "[{}]")
      (setq Mtext
         (substr Mtext 2))
    ); end condition #2
    (
     (and
     (wcmatch
       (strcase
         (substr Mtext 1 2)) "\\P")
     (/=(substr Mtext 3 1) " ")
      ); end and
         (setq Mtext (substr Mtext 3)
               Text (strcat Text " ")
         ); end setq
     ); end condition #3
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[LOP]")
      (setq Mtext(substr Mtext 3))
    ); end condition #4
    ((wcmatch
       (strcase
         (substr Mtext 1 2)) "\\[ACFHQTW]")
      (setq Mtext
         (substr Mtext
             (+ 2
                (vl-string-search ";" Mtext))))
    ); end condition #5
    ((wcmatch
       (strcase (substr Mtext 1 2)) "\\S")
      (setq Str(substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
            Text(strcat Text (vl-string-translate "#^\\" " " Str))
            Mtext(substr Mtext (+ 4 (strlen Str)))
     ); end setq
     (print Str)
    ); end condition #6
    (T
     (setq Text(strcat Text(substr Mtext 1 1))
           Mtext (substr Mtext 2)
     )
    ); end condition #7
      ); end cond
    ); end while
  Text
); end of TTC_MText_Clear
  (defun TTC_Copy (/ sObj sText tType actDoc)
   (if
    (and
     (setq sObj(car(nentsel "\nCopy text... ")))
     (member(setq tType(cdr(assoc 0(entget sObj))))
        '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
     ); end and
    (progn
      (setq actDoc(vla-get-ActiveDocument
            (vlax-get-Acad-object))
        sText(vla-get-TextString
           (vlax-ename->vla-object sObj))
        ); end setq
      (if(= tType "MTEXT")
    (setq sText(TTC_MText_Clear sText))
    ); end if
      ); end progn
    ); end if
    sText
    ); end of TTC_Copy
  (defun CCT_Str_Echo(paseStr / comStr)
    (if(< 20(strlen paseStr))
        (setq comStr
           (strcat
             (substr paseStr 1 17)"..."))
        (setq comStr paseStr)
        ); end if
      (princ
        (strcat "\nText = \"" comStr "\""))
    (princ)
    ); end of CCT_Str_Echo
    (defun *error*(msg)
    (vla-EndUndoMark
      (vla-get-ActiveDocument
            (vlax-get-acad-object)))
    (princ "\nQuit TTC")
    (princ)
    ); end of *error*
    (if(not ttc:Mode)(setq ttc:Mode "Multiple"))
    (initget "Multiple Pair-wise")
    (setq oldMode ttc:Mode
      ttc:Mode
       (getkword
         (strcat "\nSpecify mode [Multiple/Pair-wise] <"ttc:Mode">: "))
      conFlag T
      paseStr ""
       ); end setq
    (if(null ttc:Mode)(setq ttc:Mode oldMode))
    (if(= ttc:Mode "Multiple")
      (progn
    (if(and(setq paseStr(TTC_Copy))conFlag)
      (progn
      (CCT_Str_Echo paseStr)
      (while(setq conFlag(TTC_Paste paseStr))T
        ); end while
      ); end progn
      ); end if
    ); end progn
      (progn
    (while
      (and conFlag paseStr)
      (setq paseStr(TTC_Copy))
      (if(and paseStr conFlag)
        (progn
      (CCT_Str_Echo paseStr)
      (setq errFlag T)
      (while errFlag
      (setq conFlag(TTC_Paste paseStr))
           );end while
         ); end progn
        ); end if
      ); end while
    ); end progn
      ); end if
   (vla-EndUndoMark actDoc)
   (princ "\nQuit TTC")
  (princ)
  ); end c:ttc

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> {Smirnoff}
Новый вопрос -- новая тема: Как из dwg- или dxf-файла извлечь информацию о линиях?.
/Администратор./

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> {Smirnoff}
Спасибо, пользуюсь и наслаждаюсь,
как у Матроскина в Простоквашино,
теперь у нас в дваааа раза больше таблиц бууудет ;).

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Не получается копировать текст из/в таблицы! От чего это может зависить? Acad 2006-2007. Причем даже "Selection Preview Effect" не показывает, что таблица будет выделена. Как правильно вставить текст в таблицу??

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Жаль что если промахнешься прога вылетает

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> {Smirnoff}
Спасибо за лисп. А реально сделать, чтоб копируемый текст, можно вставить в другом файле или на худой конец в Layout. Очень надо при составлении ведомости рабочих чертежей.

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

{Smirnoff}
А можно доработать программу так, чтоб просто выбрать исходный блок для копирования всех атрибутов и блок куда эти атрибуты копировать? Чтоб не нажимать на каждый атрибут. И приссоединюсь к просьбе a-alex в плане возможности копирования из листа в лист, или из листа в модель. Т.е. чтоб диалог копирования не прерывался при переходе из листа в лист.
ЗЫ. Если можно конечно

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> Dextron3

> a-alex
Вариант с возможностью переключения Layout (лист-лист или лист-модель)

(defun c:ttc (/ actDoc vlaObj sObj sText curObj oldForm
        oType oldMode conFlag errFlag *error*)
  (vl-load-com)
;;; Text To Text copy
;;; Original posted {Smirnoff}
;;; https://www.caduser.ru/forum/topic21894.html
;;; Modifyed V. Azarko (VVA)
;;; https://www.caduser.ru/forum/topic21894.html
     (setq actDoc(vla-get-ActiveDocument
        (vlax-get-acad-object)))
      (vla-StartUndoMark actDoc)
  (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
                   hitRes Row Column lst ss)
    (setq errFlag nil)
  (setvar "ERRNO" 0)(initget "Switch")
    (while (progn
         (setq Lst(nentsel "\nPaste text or first point of corner or [Switch layout] <Enter-exit> >>"))
         (cond ((= Lst "Switch")
            (TTC_ls)
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
;;;           ((and (null Lst)
;;;             (= (getvar "errno") 7)
;;;             )
;;;            (princ "* Missing * ")
;;;            (setvar "ERRNO" 0)
;;;            (initget "Switch")
;;;            T
;;;            )
           (t nil)
           )
         )
      );_while
  (if (and (null Lst)
       (= (getvar "errno") 7)
       )
    (progn
    (setq hitPt (getcorner  (setq vlaObj (cadr(GRREAD nil 1))) "\nOther point: "))
    (setq ss (ssget "_C" vlaObj hitPt '((0 . "*TEXT"))))
    (setq Lst (mapcar '(lambda(x)(cons x '((0 0 0))))
            (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        )
      )
    )
    (setq Lst (list Lst))
    )
(foreach nsllst Lst
    (if nsllst ;(setq nslLst(nentsel "\nPaste text >"))
      (progn
  (cond
    (
     (and
       (= 4(length nslLst))
       (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object
        (cdr(assoc -1(entget(car(last nslLst)))))))
     (if
       (vl-catch-all-error-p
         (vl-catch-all-apply
     'vla-put-TextOverride(list vlaObj pasteStr)))
         (progn
         (princ "\n Can't paste. Object may be on locked layer. ")
         (setq errFlag T)
         ); end progn
       ); end if
     ); end condition #1
    (
     (and
       (= 4(length nslLst))
       (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object
        (cdr(assoc -1(entget(car(last nslLst))))))
     hitPt(vlax-3D-Point(trans(cadr nslLst)1 0))
     hitRes(vla-HitTest vlaObj hitPt
        (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
           ); end setq
     (if(= :vlax-true hitRes)
     (progn
         (if
     (vl-catch-all-error-p
       (vl-catch-all-apply
         'vla-SetText(list vlaObj Row Column pasteStr)))
     (progn
       (princ "\n Can't paste. Object may be on locked layer. ")
       (setq errFlag T)
       ); end progn
     ); end if
         ); end progn
       ); end if
     ); end condition # 2
    (
     (and
       (= 4(length nslLst))
       (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (princ "\nCan't paste to block's DText or MText. Select Attribute ")
     (setq errFlag T)
     ); end condition #3
    (
     (and
       (= 2(length nslLst))
         (member(cdr(assoc 0(entget(car nslLst))))
           '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object(car nslLst)))
        (if
     (vl-catch-all-error-p
       (vl-catch-all-apply
         'vla-put-TextString(list vlaObj pasteStr)))
    (progn
       (princ "\nError. Can't pase text. ")
      (setq errFlag T)
      ); end progn
     ); end if
     ); end condition #4
    (T
     (princ "\nCan't paste. Invalid object. ")
     (setq errFlag T)
     ); end condition #5
    ); end cond
             T
      ); end progn
            nil
           ); end if
  )
    ); end of TTC_Paste
    (defun TTC_MText_Clear(Mtext / Text Str)
    (setq Text "")
    (while(/= Mtext "")
      (cond
  ((wcmatch
     (strcase
       (setq Str
        (substr Mtext 1 2)))
                     "\\[\\{}`~]")
   (setq Mtext(substr Mtext 3)
         Text(strcat Text Str)
   ); end setq
  ); end condition #1
  ((wcmatch(substr Mtext 1 1) "[{}]")
    (setq Mtext
     (substr Mtext 2))
  ); end condition #2
  (
   (and
   (wcmatch
     (strcase
       (substr Mtext 1 2)) "\\P")
   (/=(substr Mtext 3 1) " ")
    ); end and
         (setq Mtext (substr Mtext 3)
               Text (strcat Text " ")
         ); end setq
   ); end condition #3
  ((wcmatch
     (strcase
       (substr Mtext 1 2)) "\\[LOP]")
    (setq Mtext(substr Mtext 3))
  ); end condition #4
  ((wcmatch
     (strcase
       (substr Mtext 1 2)) "\\[ACFHQTW]")
    (setq Mtext
     (substr Mtext
       (+ 2
          (vl-string-search ";" Mtext))))
  ); end condition #5
  ((wcmatch
     (strcase (substr Mtext 1 2)) "\\S")
    (setq Str(substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
          Text(strcat Text (vl-string-translate "#^\\" " " Str))
          Mtext(substr Mtext (+ 4 (strlen Str)))
   ); end setq
   (print Str)
  ); end condition #6
  (T
   (setq Text(strcat Text(substr Mtext 1 1))
         Mtext (substr Mtext 2)
   )
  ); end condition #7
      ); end cond
    ); end while
  Text
); end of TTC_MText_Clear
(defun ttc-layouts-list (doc)
  (or doc (setq doc (vla-get-activedocument (vlax-get-acad-object))))
  (vl-sort
    ((lambda (/ res)
       (vlax-for item (vla-get-layouts doc)
         (setq res (cons item res))
         ) ;_ end of vlax-for
       ) ;_ end of lambda
     )
    '(lambda (a b)
       (< (vla-get-taborder a) (vla-get-taborder b))
       ) ;_ end of lambda
    ) ;_ end of vl-sort
  ) ;_ end of defun
;;; RUS ************************************************************************
;;; * Библиотека DWGruLispLib Copyright ©2008  DWGru Programmers Group
;;; *
;;; * _TTC-GET-USER-DCL (Кандидат)
;;; *
;;; * Запрос значения у пользователя через диалоговое окно
;;; *
;;; *
;;; * 26/01/2008 Версия 0002. Редакция Владимир Азарко (VVA)
;;;              - Выход по двойному клику, если запрещен множественный выбор (multi-nil)
;;;              - Обработка нескольких колонок
;;; * 21/01/2008 Версия 0001. Редакция Владимир Азарко (VVA)
;;; ************************************************************************
;;; EN ************************************************************************
;;; * Library DWGruLispLib Copyright © 2008 DWGru Programmers Group
;;; *
;;; * _TTC-GET-USER-DCL (Candidate)
;;; *
;;; * Inquiry of value at the user through a dialogue window
;;; *
;;; *
;;; * 26/01/2008 Version 0002. Edition Vladimir Azarko (VVA)
;;; - the Output on double a clique if the plural choice (multi-nil) is forbidden
;;; - Processing of several columns
;;; * 21/01/2008 Version 0001. Edition Vladimir Azarko (VVA)
(defun _TTC-GET-USER-DCL (ZAGL        INFO-LIST   MULTI
                            /           FL          RET
                            DCL_ID      MAXROW      MAX_COUNT_COL
                            COUNT_COL   I           LISTBOX_HEIGHT
                            LST         _LOC_FINISH _LOC_CLEAR
                            NCOL
                           )
;|
* ENGLISH
* Inquiry of value at the user through a dialogue window
* Dialogue is formed to "strike"
* the Quantity of lines on page without скроллинга is set by variable MAXROW.
* It is necessary to remember, that number MAXROW increases on 3.
* the Maximum quantity of columns is set by variable MAX_COUNT_COL
* It is published
     http://dwg.ru/f/showthread.php?p=203746#post203746
* Parameters of a call:
    zagl - heading of a window [String]
    info-list - the list of line values [List of String]
    multi - t - the plural choice is resolved, nil-is not present
* Returns:
 The list of the chosen lines or nil - a cancelling
* the Example
 (_TTC-GET-USER-DCL " Specify a variant " ' ("First " Second " " Third ") nil); _-> ("First")
 (_TTC-GET-USER-DCL " Specify a variant " ' ("First " Second " " Third ") t); _-> ("First " Second ")
 (_TTC-GET-USER-DCL " Specify a variant "
   (progn (setq i 0 lst nil) (repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1 + i)))) lst))) (reverse lst)) nil)
 (_TTC-GET-USER-DCL " Specify a variant, using CTRL and SHIFT for a choice "
   (progn (setq i 0 lst nil) (repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1 + i)))) lst))) (reverse lst)) t)
|;
                        
                        
;|
* RUS                        
* Запрос значения у пользователя через диалоговое окно
* Диалог формируется "налету"
* Количество строк на страницу без скроллинга задается переменной MAXROW.
* Необходимо помнить, что число MAXROW увеличивается на 3.
* Максимальное количество колонок задается переменной MAX_COUNT_COL
* Опубликована
     http://dwg.ru/f/showthread.php?p=203746#post203746
* Параметры вызова:
    zagl - заголовок окна [String]
    info-list - список строковых значений [List of String]
    multi - t - разрешен множественный выбор, nil- нет
* Возвращает:
 Список выбранных строк или nil - отмена
* Пример
 (_TTC-GET-USER-DCL "Укажите вариант" '("Первый" "Второй" "Третий") nil) ;_->("Первый")
 (_TTC-GET-USER-DCL "Укажите вариант" '("Первый" "Второй" "Третий") t) ;_->("Первый" "Второй")
 (_TTC-GET-USER-DCL "Укажите вариант"
   (progn (setq i 0 lst nil)(repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1+ i)))) lst)))(reverse lst)) nil)
 (_TTC-GET-USER-DCL "Укажите вариант, используя CTRL и SHIFT для выбора"
   (progn (setq i 0 lst nil)(repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1+ i)))) lst)))(reverse lst)) t)
|;
 ;_ ===== КОНСТАНТЫ ============
  (setq MAXROW 40) ;_макc. кол-во строк без скроллинга (К нему дальше добавится еще 3 строчки)
                   ;_  max lines without scrolling (To it 3 more lines further will be added)
  (setq MAX_COUNT_COL 5) ;_максимальное количество колонок
                         ;_ ; _ a maximum quantity of columns
;;;==================== Локальные фунцкции START==================================
;;;==================== Local functions START==================================
  (defun _LOC_FINISH ()
    (setq I   0
          RET NIL
    ) ;_ end ofsetq
    (repeat COUNT_COL
      (setq I (1+ I))
      (setq RET (cons (cons I (get_tile (strcat "info" (itoa I)))) RET))
    ) ;_ end ofrepeat
    (setq RET (reverse RET))
    (done_dialog 1)
  ) ;_ end ofdefun
  (defun _LOC_CLEAR (NOMER)
    (setq I 0)
    (repeat COUNT_COL
      (setq I (1+ I))
      (if (/= I NOMER)
        (progn
          (start_list (strcat "info" (itoa I)))
          (mapcar 'add_list (nth (1- I) LST))
          (end_list)
        ) ;_ end ofprogn
      ) ;_ end ofif
    ) ;_ end ofrepeat
  ) ;_ end ofdefun
;;;==================== Локальные фунцкции END ==================================
;;;==================== Local functions END ==================================
;;;==================== MAIN PART ===============================================
  (if (null ZAGL)
    (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
      (setq ZAGL "Выбор")
      (setq ZAGL "Select")
    ) ;_ end ofif
  ) ;_ end if
  (if (zerop (rem (length INFO-LIST) MAXROW)) ;_Целое количество столбцов
    (setq COUNT_COL (/ (length INFO-LIST) MAXROW)) ;_Его и оставляем
    (setq COUNT_COL (1+ (fix (/ (length INFO-LIST) MAXROW 1.0)))) ;_Берем ближайшее целое
  ) ;_ end ofif
  (if (> COUNT_COL MAX_COUNT_COL)
    (setq COUNT_COL MAX_COUNT_COL)
  ) ;_Ограничиваем max количеством
  (setq LISTBOX_HEIGHT (+ 3 MAXROW)) ;_  добавляем 3 строчки для красоты и для исключения пограничного скроллинга
                                     ;_ We add 3 lines for appearance and for exception boundary scroll
  (if (and (= COUNT_COL 1) (<= (length INFO-LIST) MAXROW))
    (setq LISTBOX_HEIGHT (+ 3 (length INFO-LIST)))
  ) ;_ end ofif
  (setq I 0)
  (setq FL (vl-filename-mktemp "dwgru" NIL ".dcl"))
  (setq RET (open FL "w")
        LST NIL
  ) ;_ end ofsetq
  (mapcar '(lambda (X) (write-line X RET))
          (append (list "dwgru_get_user : dialog { "
                        (strcat "label=\"" ZAGL "\";")
                        ": boxed_row {"
                        (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                          "label = \"Значение\";"
                          "label = \"Value\";"
                        ) ;_ end ofif
                  ) ;_ end oflist
                  (repeat COUNT_COL
                    (setq LST
                           (append
                             LST
                             (list
                               " :list_box {"
                               "alignment=top ;"
                               (if MULTI
                                 "multiple_select = true ;"
                                 "multiple_select = false ;"
                               ) ;_ end ofif
                               "width=31 ;"
                               (strcat "height= " (itoa LISTBOX_HEIGHT) " ;")
                               "is_tab_stop = false ;"
                               (strcat "key = \"info" (itoa (setq I (1+ I))) "\";}")
                             ) ;_ end oflist
                           ) ;_ end ofappend
                    ) ;_ end ofsetq
                  ) ;_ end ofrepeat
                  (list
                    "}"
                    ":row{"
                    "ok_cancel_err;}}"
                  ) ;_ end oflist
          ) ;_ end of list
  ) ;_ end of mapcar
  (setq RET (close RET))
  (if (and (null (minusp (setq DCL_ID (load_dialog FL))))
           (new_dialog "dwgru_get_user" DCL_ID)
      ) ;_ end and
    (progn
      (setq LST INFO-LIST)
      ((lambda (/ RET1 BUF ITM)
         (repeat (1- COUNT_COL)
           (setq I '-1)
           (while (and (setq ITM (car LST))
                       (< (setq I (1+ I)) MAXROW)
                  ) ;_ end ofand
             (setq BUF (cons ITM BUF)
                   LST (cdr LST)
             ) ;_ end ofsetq
           ) ;_ end ofwhile
           (setq RET1 (cons (reverse BUF) RET1)
                 BUF  NIL
           ) ;_ end ofsetq
         ) ;_ end ofrepeat
         (setq RET RET1)
       ) ;_ end oflambda
      )
      (if LST
        (setq RET (cons LST RET))
      ) ;_ end ofif
      (setq LST (reverse RET))
      (setq I 0)
      (mapcar '(lambda (THIS_LIST)
                 (if (<= (setq I (1+ I)) COUNT_COL)
                   (progn
                     (start_list (strcat "info" (itoa I)))
                     (mapcar 'add_list THIS_LIST)
                     (end_list)
                   ) ;_ end ofprogn
                 ) ;_ end ofif
               ) ;_ end oflambda
              LST
      ) ;_ end ofmapcar
      (set_tile "info1" "0")
      (setq I 0
            NCOL 1
      ) ;_ end ofsetq
      (repeat COUNT_COL
        (action_tile
          (strcat "info" (itoa (setq I (1+ I))))
          (strcat "(progn (setq Ncol "
                  (itoa I)
                  ")(if (not multi)(_loc_clear Ncol))"
                  "(if (and (not multi)(= $reason 4))(_loc_finish)))"
          ) ;_ end ofstrcat
        ) ;_ end ofaction_tile
      ) ;_ end ofrepeat
      (action_tile "cancel" "(done_dialog 0)")
      (action_tile "accept" "(_loc_finish)")
      (if MULTI
        (set_tile "error"
                  (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                    "Используйте CTRL и SHIFT для выбора"
                    "Use CTRL and SHIFT for a choicet"
                  ) ;_ end ofif
        ) ;_ end ofset_tile
        (set_tile "error"
                  (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                    "Можно выбирать двойным щелчком"
                    "It is possible to choose double click"
                  ) ;_ end ofif
        ) ;_ end ofset_tile
      ) ;_ end ofif
      (if (zerop (start_dialog))
        (setq RET NIL)
        (progn
          (setq
            RET (apply
                  'append
                  (mapcar
                    '(lambda (ITM)
                       (setq THIS_LIST (nth (1- (car ITM)) LST))
                       (mapcar
                         (function (lambda (NUM) (nth NUM THIS_LIST)))
                         (read (strcat "(" (cdr ITM) ")"))
                       ) ;_ end ofmapcar
                     ) ;_ end oflambda
                    RET
                  ) ;_ end ofmapcar
                ) ;_ end ofapply
          ) ;_ end ofsetq
        ) ;_ end ofprogn
      ) ;_ end if
      (unload_dialog DCL_ID)
    ) ;_ end of progn
  ) ;_ end of if
  (vl-file-delete FL)
  RET
) ;_ end of defun
(defun TTC_ls ( / ret)
  (and
    (setq
      ret
       (car (_TTC-GET-USER-DCL
              "Select layout"
              (mapcar 'vla-get-name (ttc-layouts-list nil))
              nil
              ) ;_ end of _TTC-GET-USER-DCL
            ) ;_ end of car
      ) ;_ end of setq
    (setvar "CTAB" ret)
    ) ;_ end of and
  (princ)
  ) ;_ end of defun
  (defun TTC_Copy (/ sObj sText tType actDoc)
(setvar "ERRNO" 0)(initget "Switch")
   (if
    (and
    (or
    (while (progn
         (setq sObj(nentsel "\nCopy text [Switch layout]... "))
         (cond ((= Lst "Switch")
            (TTC_ls)
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
           ((and (null Lst)
             (= (getvar "errno") 7)
             )
            (princ "* Missing * ")
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
           (t nil)
           )
         )
      ) T)
;;;      (or
;;;      (while (= (setq sObj(nentsel "\nCopy text [Switch layout]... ")) "Switch")
;;;    (TTC_ls)
;;;    (initget "Switch")
;;;    )
;;;         t)
     (setq sObj(car sObj))
     (member(setq tType(cdr(assoc 0(entget sObj))))
      '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))
     ); end and
    (progn
      (setq actDoc(vla-get-ActiveDocument
        (vlax-get-Acad-object))
      sText(vla-get-TextString
       (vlax-ename->vla-object sObj))
      ); end setq
      (if(= tType "MTEXT")
  (setq sText(TTC_MText_Clear sText))
  ); end if
      ); end progn
    ); end if
    sText
    ); end of TTC_Copy
  (defun CCT_Str_Echo(paseStr / comStr)
    (if(< 20(strlen paseStr))
      (setq comStr
       (strcat
         (substr paseStr 1 17)"..."))
      (setq comStr paseStr)
      ); end if
    (princ
      (strcat "\nText = \"" comStr "\""))
    (princ)
    ); end of CCT_Str_Echo
    (defun *error*(msg)
    (vla-EndUndoMark
      (vla-get-ActiveDocument
        (vlax-get-acad-object)))
    (princ "\nQuit TTC")
    (princ)
    ); end of *error*
    (if(not ttc:Mode)(setq ttc:Mode "Multiple"))
    (initget "Multiple Pair-wise")
    (setq oldMode ttc:Mode
    ttc:Mode
     (getkword
       (strcat "\nSpecify mode [Multiple/Pair-wise] <" ttc:Mode ">: "))
    conFlag T
    paseStr ""
     ); end setq
    (if(null ttc:Mode)(setq ttc:Mode oldMode))
    (if(= ttc:Mode "Multiple")
      (progn
  (if(and(setq paseStr(TTC_Copy))conFlag)
    (progn
    (CCT_Str_Echo paseStr)
    (while(setq conFlag(TTC_Paste paseStr))T
      ); end while
    ); end progn
    ); end if
  ); end progn
      (progn
  (while
    (and conFlag paseStr)
    (setq paseStr(TTC_Copy))
    (if(and paseStr conFlag)
      (progn
    (CCT_Str_Echo paseStr)
    (setq errFlag T)
    (while errFlag
    (setq conFlag(TTC_Paste paseStr))
         );end while
       ); end progn
      ); end if
    ); end while
  ); end progn
      ); end if
   (vla-EndUndoMark actDoc)
   (princ "\nQuit TTC")
  (princ)
  )

> Serg01
Это уже в принципе другая программа

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

спасибо работает, ждем обновления, при правке экономит много времени, тут даже можно размеры править!!!

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Программа прекрасная! Ещё бы добавить возможность копирования содержимого из мультивыносок...

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Текст в таблицах не копируется при шрифтах ttf, с shx все чудесно!
Огромная просьба добавить мультивыноски!!

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

> Fill
Шрифт в таблицах задается в стиле и никакого влияния на лисп не оказывает. Мультилидер добавлен

(defun c:ttc (/ actDoc vlaObj sObj sText curObj oldForm
        oType oldMode conFlag errFlag *error*)
  (vl-load-com)
;;; Text To Text copy
;;; Original posted Aleksandr Smirnov {Smirnoff} now known as ASMI
;;; Aleksandr Smirnov (ASMI)
;;; https://www.caduser.ru/forum/topic21894.html
;;; Modifyed V. Azarko (VVA)
;;; https://www.caduser.ru/forum/topic21894.html
;;; 22.10.2008 Add MULTILEADER
     (setq actDoc(vla-get-ActiveDocument
        (vlax-get-acad-object)))
      (vla-StartUndoMark actDoc)
  (defun TTC_Paste(pasteStr / nslLst vlaObj hitPt
                   hitRes Row Column lst ss)
    (setq errFlag nil)
  (setvar "ERRNO" 0)(initget "Switch")
    (while (progn
         (setq Lst(nentsel "\nPaste text or first point of corner or [Switch layout] <Enter-exit> >>"))
         (cond ((= Lst "Switch")
            (TTC_ls)
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
;;;           ((and (null Lst)
;;;             (= (getvar "errno") 7)
;;;             )
;;;            (princ "* Missing * ")
;;;            (setvar "ERRNO" 0)
;;;            (initget "Switch")
;;;            T
;;;            )
           (t nil)
           )
         )
      );_while
  (if (and (null Lst)
       (= (getvar "errno") 7)
       (setq hitPt (getcorner  (setq vlaObj (cadr(GRREAD nil 1))) "\nOther point: "))
       (setq ss (ssget "_C" vlaObj hitPt '((0 . "*TEXT"))))
       )
    (progn
    (setq Lst (mapcar '(lambda(x)(cons x '((0 0 0))))
            (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        )
      )
    )
    (setq Lst (list Lst))
    )
(foreach nsllst Lst
    (if nsllst ;(setq nslLst(nentsel "\nPaste text >"))
      (progn
  (cond
    (
     (and
       (= 4(length nslLst))
       (= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object
        (cdr(assoc -1(entget(car(last nslLst)))))))
     (if
       (vl-catch-all-error-p
         (vl-catch-all-apply
     'vla-put-TextOverride(list vlaObj pasteStr)))
         (progn
         (princ "\n Can't paste. Object may be on locked layer. ")
         (setq errFlag T)
         ); end progn
       ); end if
     ); end condition #1
    (
     (and
       (= 4(length nslLst))
       (= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object
        (cdr(assoc -1(entget(car(last nslLst))))))
     hitPt(vlax-3D-Point(trans(cadr nslLst)1 0))
     hitRes(vla-HitTest vlaObj hitPt
        (vlax-3D-Point '(0.0 0.0 1.0)) 'Row 'Column)
           ); end setq
     (if(= :vlax-true hitRes)
     (progn
         (if
     (vl-catch-all-error-p
       (vl-catch-all-apply
         'vla-SetText(list vlaObj Row Column pasteStr)))
     (progn
       (princ "\n Can't paste. Object may be on locked layer. ")
       (setq errFlag T)
       ); end progn
     ); end if
         ); end progn
       ); end if
     ); end condition # 2
    (
     (and
       (= 4(length nslLst))
       (= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))
       ); end and
     (princ "\nCan't paste to block's DText or MText. Select Attribute ")
     (setq errFlag T)
     ); end condition #3
    (
     (and
       (= 2(length nslLst))
         (member(cdr(assoc 0(entget(car nslLst))))
           '("TEXT" "MTEXT" "ATTRIB" "ATTDEF" "MULTILEADER"))
       ); end and
     (setq vlaObj
      (vlax-ename->vla-object(car nslLst)))
        (if
     (vl-catch-all-error-p
       (vl-catch-all-apply
         'vla-put-TextString(list vlaObj pasteStr)))
    (progn
       (princ "\nError. Can't pase text. ")
      (setq errFlag T)
      ); end progn
     ); end if
     ); end condition #4
    (T
     (princ "\nCan't paste. Invalid object. ")
     (setq errFlag T)
     ); end condition #5
    ); end cond
             T
      ); end progn
            nil
           ); end if
  )
    ); end of TTC_Paste
    (defun TTC_MText_Clear(Mtext / Text Str)
    (setq Text "")
    (while(/= Mtext "")
      (cond
  ((wcmatch
     (strcase
       (setq Str
        (substr Mtext 1 2)))
                     "\\[\\{}`~]")
   (setq Mtext(substr Mtext 3)
         Text(strcat Text Str)
   ); end setq
  ); end condition #1
  ((wcmatch(substr Mtext 1 1) "[{}]")
    (setq Mtext
     (substr Mtext 2))
  ); end condition #2
  (
   (and
   (wcmatch
     (strcase
       (substr Mtext 1 2)) "\\P")
   (/=(substr Mtext 3 1) " ")
    ); end and
         (setq Mtext (substr Mtext 3)
               Text (strcat Text " ")
         ); end setq
   ); end condition #3
  ((wcmatch
     (strcase
       (substr Mtext 1 2)) "\\[LOP]")
    (setq Mtext(substr Mtext 3))
  ); end condition #4
  ((wcmatch
     (strcase
       (substr Mtext 1 2)) "\\[ACFHQTW]")
    (setq Mtext
     (substr Mtext
       (+ 2
          (vl-string-search ";" Mtext))))
  ); end condition #5
  ((wcmatch
     (strcase (substr Mtext 1 2)) "\\S")
    (setq Str(substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
          Text(strcat Text (vl-string-translate "#^\\" " " Str))
          Mtext(substr Mtext (+ 4 (strlen Str)))
   ); end setq
   (print Str)
  ); end condition #6
  (T
   (setq Text(strcat Text(substr Mtext 1 1))
         Mtext (substr Mtext 2)
   )
  ); end condition #7
      ); end cond
    ); end while
  Text
); end of TTC_MText_Clear
(defun ttc-layouts-list (doc)
  (or doc (setq doc (vla-get-activedocument (vlax-get-acad-object))))
  (vl-sort
    ((lambda (/ res)
       (vlax-for item (vla-get-layouts doc)
         (setq res (cons item res))
         ) ;_ end of vlax-for
       ) ;_ end of lambda
     )
    '(lambda (a b)
       (< (vla-get-taborder a) (vla-get-taborder b))
       ) ;_ end of lambda
    ) ;_ end of vl-sort
  ) ;_ end of defun
;;; RUS ************************************************************************
;;; * Библиотека DWGruLispLib Copyright ©2008  DWGru Programmers Group
;;; *
;;; * _TTC-GET-USER-DCL (Кандидат)
;;; *
;;; * Запрос значения у пользователя через диалоговое окно
;;; *
;;; *
;;; * 26/01/2008 Версия 0002. Редакция Владимир Азарко (VVA)
;;;              - Выход по двойному клику, если запрещен множественный выбор (multi-nil)
;;;              - Обработка нескольких колонок
;;; * 21/01/2008 Версия 0001. Редакция Владимир Азарко (VVA)
;;; ************************************************************************
;;; EN ************************************************************************
;;; * Library DWGruLispLib Copyright © 2008 DWGru Programmers Group
;;; *
;;; * _TTC-GET-USER-DCL (Candidate)
;;; *
;;; * Inquiry of value at the user through a dialogue window
;;; *
;;; *
;;; * 26/01/2008 Version 0002. Edition Vladimir Azarko (VVA)
;;; - the Output on double a clique if the plural choice (multi-nil) is forbidden
;;; - Processing of several columns
;;; * 21/01/2008 Version 0001. Edition Vladimir Azarko (VVA)
(defun _TTC-GET-USER-DCL (ZAGL        INFO-LIST   MULTI
                            /           FL          RET
                            DCL_ID      MAXROW      MAX_COUNT_COL
                            COUNT_COL   I           LISTBOX_HEIGHT
                            LST         _LOC_FINISH _LOC_CLEAR
                            NCOL
                           )
;|
* ENGLISH
* Inquiry of value at the user through a dialogue window
* Dialogue is formed to "strike"
* the Quantity of lines on page without скроллинга is set by variable MAXROW.
* It is necessary to remember, that number MAXROW increases on 3.
* the Maximum quantity of columns is set by variable MAX_COUNT_COL
* It is published
     http://dwg.ru/f/showthread.php?p=203746#post203746
* Parameters of a call:
    zagl - heading of a window [String]
    info-list - the list of line values [List of String]
    multi - t - the plural choice is resolved, nil-is not present
* Returns:
 The list of the chosen lines or nil - a cancelling
* the Example
 (_TTC-GET-USER-DCL " Specify a variant " ' ("First " Second " " Third ") nil); _-> ("First")
 (_TTC-GET-USER-DCL " Specify a variant " ' ("First " Second " " Third ") t); _-> ("First " Second ")
 (_TTC-GET-USER-DCL " Specify a variant "
   (progn (setq i 0 lst nil) (repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1 + i)))) lst))) (reverse lst)) nil)
 (_TTC-GET-USER-DCL " Specify a variant, using CTRL and SHIFT for a choice "
   (progn (setq i 0 lst nil) (repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1 + i)))) lst))) (reverse lst)) t)
|;
                        
                        
;|
* RUS                        
* Запрос значения у пользователя через диалоговое окно
* Диалог формируется "налету"
* Количество строк на страницу без скроллинга задается переменной MAXROW.
* Необходимо помнить, что число MAXROW увеличивается на 3.
* Максимальное количество колонок задается переменной MAX_COUNT_COL
* Опубликована
     http://dwg.ru/f/showthread.php?p=203746#post203746
* Параметры вызова:
    zagl - заголовок окна [String]
    info-list - список строковых значений [List of String]
    multi - t - разрешен множественный выбор, nil- нет
* Возвращает:
 Список выбранных строк или nil - отмена
* Пример
 (_TTC-GET-USER-DCL "Укажите вариант" '("Первый" "Второй" "Третий") nil) ;_->("Первый")
 (_TTC-GET-USER-DCL "Укажите вариант" '("Первый" "Второй" "Третий") t) ;_->("Первый" "Второй")
 (_TTC-GET-USER-DCL "Укажите вариант"
   (progn (setq i 0 lst nil)(repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1+ i)))) lst)))(reverse lst)) nil)
 (_TTC-GET-USER-DCL "Укажите вариант, используя CTRL и SHIFT для выбора"
   (progn (setq i 0 lst nil)(repeat 205 (setq lst (cons (strcat "Значение-" (itoa (setq i (1+ i)))) lst)))(reverse lst)) t)
|;
 ;_ ===== КОНСТАНТЫ ============
  (setq MAXROW 40) ;_макc. кол-во строк без скроллинга (К нему дальше добавится еще 3 строчки)
                   ;_  max lines without scrolling (To it 3 more lines further will be added)
  (setq MAX_COUNT_COL 5) ;_максимальное количество колонок
                         ;_ ; _ a maximum quantity of columns
;;;==================== Локальные фунцкции START==================================
;;;==================== Local functions START==================================
  (defun _LOC_FINISH ()
    (setq I   0
          RET NIL
    ) ;_ end ofsetq
    (repeat COUNT_COL
      (setq I (1+ I))
      (setq RET (cons (cons I (get_tile (strcat "info" (itoa I)))) RET))
    ) ;_ end ofrepeat
    (setq RET (reverse RET))
    (done_dialog 1)
  ) ;_ end ofdefun
  (defun _LOC_CLEAR (NOMER)
    (setq I 0)
    (repeat COUNT_COL
      (setq I (1+ I))
      (if (/= I NOMER)
        (progn
          (start_list (strcat "info" (itoa I)))
          (mapcar 'add_list (nth (1- I) LST))
          (end_list)
        ) ;_ end ofprogn
      ) ;_ end ofif
    ) ;_ end ofrepeat
  ) ;_ end ofdefun
;;;==================== Локальные фунцкции END ==================================
;;;==================== Local functions END ==================================
;;;==================== MAIN PART ===============================================
  (if (null ZAGL)
    (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
      (setq ZAGL "Выбор")
      (setq ZAGL "Select")
    ) ;_ end ofif
  ) ;_ end if
  (if (zerop (rem (length INFO-LIST) MAXROW)) ;_Целое количество столбцов
    (setq COUNT_COL (/ (length INFO-LIST) MAXROW)) ;_Его и оставляем
    (setq COUNT_COL (1+ (fix (/ (length INFO-LIST) MAXROW 1.0)))) ;_Берем ближайшее целое
  ) ;_ end ofif
  (if (> COUNT_COL MAX_COUNT_COL)
    (setq COUNT_COL MAX_COUNT_COL)
  ) ;_Ограничиваем max количеством
  (setq LISTBOX_HEIGHT (+ 3 MAXROW)) ;_  добавляем 3 строчки для красоты и для исключения пограничного скроллинга
                                     ;_ We add 3 lines for appearance and for exception boundary scroll
  (if (and (= COUNT_COL 1) (<= (length INFO-LIST) MAXROW))
    (setq LISTBOX_HEIGHT (+ 3 (length INFO-LIST)))
  ) ;_ end ofif
  (setq I 0)
  (setq FL (vl-filename-mktemp "dwgru" NIL ".dcl"))
  (setq RET (open FL "w")
        LST NIL
  ) ;_ end ofsetq
  (mapcar '(lambda (X) (write-line X RET))
          (append (list "dwgru_get_user : dialog { "
                        (strcat "label=\"" ZAGL "\";")
                        ": boxed_row {"
                        (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                          "label = \"Значение\";"
                          "label = \"Value\";"
                        ) ;_ end ofif
                  ) ;_ end oflist
                  (repeat COUNT_COL
                    (setq LST
                           (append
                             LST
                             (list
                               " :list_box {"
                               "alignment=top ;"
                               (if MULTI
                                 "multiple_select = true ;"
                                 "multiple_select = false ;"
                               ) ;_ end ofif
                               "width=31 ;"
                               (strcat "height= " (itoa LISTBOX_HEIGHT) " ;")
                               "is_tab_stop = false ;"
                               (strcat "key = \"info" (itoa (setq I (1+ I))) "\";}")
                             ) ;_ end oflist
                           ) ;_ end ofappend
                    ) ;_ end ofsetq
                  ) ;_ end ofrepeat
                  (list
                    "}"
                    ":row{"
                    "ok_cancel_err;}}"
                  ) ;_ end oflist
          ) ;_ end of list
  ) ;_ end of mapcar
  (setq RET (close RET))
  (if (and (null (minusp (setq DCL_ID (load_dialog FL))))
           (new_dialog "dwgru_get_user" DCL_ID)
      ) ;_ end and
    (progn
      (setq LST INFO-LIST)
      ((lambda (/ RET1 BUF ITM)
         (repeat (1- COUNT_COL)
           (setq I '-1)
           (while (and (setq ITM (car LST))
                       (< (setq I (1+ I)) MAXROW)
                  ) ;_ end ofand
             (setq BUF (cons ITM BUF)
                   LST (cdr LST)
             ) ;_ end ofsetq
           ) ;_ end ofwhile
           (setq RET1 (cons (reverse BUF) RET1)
                 BUF  NIL
           ) ;_ end ofsetq
         ) ;_ end ofrepeat
         (setq RET RET1)
       ) ;_ end oflambda
      )
      (if LST
        (setq RET (cons LST RET))
      ) ;_ end ofif
      (setq LST (reverse RET))
      (setq I 0)
      (mapcar '(lambda (THIS_LIST)
                 (if (<= (setq I (1+ I)) COUNT_COL)
                   (progn
                     (start_list (strcat "info" (itoa I)))
                     (mapcar 'add_list THIS_LIST)
                     (end_list)
                   ) ;_ end ofprogn
                 ) ;_ end ofif
               ) ;_ end oflambda
              LST
      ) ;_ end ofmapcar
      (set_tile "info1" "0")
      (setq I 0
            NCOL 1
      ) ;_ end ofsetq
      (repeat COUNT_COL
        (action_tile
          (strcat "info" (itoa (setq I (1+ I))))
          (strcat "(progn (setq Ncol "
                  (itoa I)
                  ")(if (not multi)(_loc_clear Ncol))"
                  "(if (and (not multi)(= $reason 4))(_loc_finish)))"
          ) ;_ end ofstrcat
        ) ;_ end ofaction_tile
      ) ;_ end ofrepeat
      (action_tile "cancel" "(done_dialog 0)")
      (action_tile "accept" "(_loc_finish)")
      (if MULTI
        (set_tile "error"
                  (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                    "Используйте CTRL и SHIFT для выбора"
                    "Use CTRL and SHIFT for a choicet"
                  ) ;_ end ofif
        ) ;_ end ofset_tile
        (set_tile "error"
                  (if (= (getvar "DWGCODEPAGE") "ANSI_1251")
                    "Можно выбирать двойным щелчком"
                    "It is possible to choose double click"
                  ) ;_ end ofif
        ) ;_ end ofset_tile
      ) ;_ end ofif
      (if (zerop (start_dialog))
        (setq RET NIL)
        (progn
          (setq
            RET (apply
                  'append
                  (mapcar
                    '(lambda (ITM)
                       (setq THIS_LIST (nth (1- (car ITM)) LST))
                       (mapcar
                         (function (lambda (NUM) (nth NUM THIS_LIST)))
                         (read (strcat "(" (cdr ITM) ")"))
                       ) ;_ end ofmapcar
                     ) ;_ end oflambda
                    RET
                  ) ;_ end ofmapcar
                ) ;_ end ofapply
          ) ;_ end ofsetq
        ) ;_ end ofprogn
      ) ;_ end if
      (unload_dialog DCL_ID)
    ) ;_ end of progn
  ) ;_ end of if
  (vl-file-delete FL)
  RET
) ;_ end of defun
(defun TTC_ls ( / ret)
  (and
    (setq
      ret
       (car (_TTC-GET-USER-DCL
              "Select layout"
              (mapcar 'vla-get-name (ttc-layouts-list nil))
              nil
              ) ;_ end of _TTC-GET-USER-DCL
            ) ;_ end of car
      ) ;_ end of setq
    (setvar "CTAB" ret)
    ) ;_ end of and
  (princ)
  ) ;_ end of defun
  (defun TTC_Copy (/ sObj sText tType actDoc)
(setvar "ERRNO" 0)(initget "Switch")
   (if
    (and
    (or
    (while (progn
         (setq sObj(nentsel "\nCopy text [Switch layout]... "))
         (cond ((= Lst "Switch")
            (TTC_ls)
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
           ((and (null Lst)
             (= (getvar "errno") 7)
             )
            (princ "* Missing * ")
            (setvar "ERRNO" 0)
            (initget "Switch")
            T
            )
           (t nil)
           )
         )
      ) T)
;;;      (or
;;;      (while (= (setq sObj(nentsel "\nCopy text [Switch layout]... ")) "Switch")
;;;    (TTC_ls)
;;;    (initget "Switch")
;;;    )
;;;         t)
     (setq sObj(car sObj))
     (member(setq tType(cdr(assoc 0(entget sObj))))
      '("TEXT" "MTEXT" "ATTRIB" "ATTDEF" "MULTILEADER"))
     ); end and
    (progn
      (setq actDoc(vla-get-ActiveDocument(vlax-get-Acad-object))
        sText(vla-get-TextString(vlax-ename->vla-object sObj))
      ); end setq
      ;;; (if(= tType "MTEXT")(setq sText(TTC_MText_Clear sText))); end if
      (setq sText(TTC_MText_Clear sText))
      ); end progn
    ); end if
    sText
    ); end of TTC_Copy
  (defun CCT_Str_Echo(paseStr / comStr)
    (if(< 20(strlen paseStr))
      (setq comStr
       (strcat
         (substr paseStr 1 17)"..."))
      (setq comStr paseStr)
      ); end if
    (princ
      (strcat "\nText = \"" comStr "\""))
    (princ)
    ); end of CCT_Str_Echo
    (defun *error*(msg)
    (vla-EndUndoMark
      (vla-get-ActiveDocument
        (vlax-get-acad-object)))
    (princ "\nQuit TTC")
    (princ)
    ); end of *error*
    (if(not ttc:Mode)(setq ttc:Mode "Multiple"))
    (initget "Multiple Pair-wise")
    (setq oldMode ttc:Mode
    ttc:Mode
     (getkword
       (strcat "\nSpecify mode [Multiple/Pair-wise] <" ttc:Mode ">: "))
    conFlag T
    paseStr ""
     ); end setq
    (if(null ttc:Mode)(setq ttc:Mode oldMode))
    (if(= ttc:Mode "Multiple")
      (progn
  (if(and(setq paseStr(TTC_Copy))conFlag)
    (progn
    (CCT_Str_Echo paseStr)
    (while(setq conFlag(TTC_Paste paseStr))T
      ); end while
    ); end progn
    ); end if
  ); end progn
      (progn
  (while
    (and conFlag paseStr)
    (setq paseStr(TTC_Copy))
    (if(and paseStr conFlag)
      (progn
    (CCT_Str_Echo paseStr)
    (setq errFlag T)
    (while errFlag
    (setq conFlag(TTC_Paste paseStr))
         );end while
       ); end progn
      ); end if
    ); end while
  ); end progn
      ); end if
   (vla-EndUndoMark actDoc)
   (princ "\nQuit TTC")
  (princ)
  )

Re: LISP. Копирование текста из/в DText, MText, Таблиц, Размеров, Атрибутов, определения Атрибутов

Спасибо. Уже интереснее. ))