MText kopieren und ersetzen

MText kopieren und ersetzen

raumin
Contributor Contributor
3.738Aufrufe
22Antworten
Nachricht 1 von 23

MText kopieren und ersetzen

raumin
Contributor
Contributor

guten tag

ich möchte einen bestimmteren mtext kopieren und durch einen vordefiniert text aus einer auswalliste ersetzen in grösse und position bei meinem script gehts leider nur mit neu erstellen, lieber hätte ich aber kopieren da dann der layer übernommen wird. der layer ist immer anders

 

------------------------------------------------------

 

(defun c:uv_rwdemont ( / )

(command "-layer" "_t" "--------_ansc_syst" "" "" )
(command "-layer" "_ma" "--------_ansc_syst" "farbe" "gelb" "" "" )
(command "-layer" "se" "--------_ansc_syst" "" )
(command "osmode" "64" )
(command "ortho" "aus" )
(command "_ucs" "O" pause "" )
;(command "_mtext" pause "st" "All CAD" "h" "30" "a" "mz" pause "RW DEMONT." "")
(command "_text" "st" "All CAD" "I" "MZ" pause "30" "0" "RW DEMONT." )
(command "osmode" "0" )
(command "-layer" "se" "0" "" )
(command "schieben" "l" "" "0,0,0" "100<90" )
(command "schieben" "l" "" pause pause )
(command "osmode" "223" )
(command "_ucs" "W" "" "" )
(command "_txt2mtxt" "l" "" )
(command "ortho" "ein" )


)

 

 

0 „Gefällt mir“-Angaben
3.739Aufrufe
22Antworten
Antworten (22)
Nachricht 2 von 23

ВeekeeCZ
Consultant
Consultant

@raumin wrote:

Hello, I would like to copy a specific mtext and replace it with a predefined text from a selection list in size and position. Unfortunately, my script only works with new creation, but I would have preferred to copy it because the layer is then taken over. the layer is always different

 

 


Post a dwg with an example of such MTEXT (= does the contents include format chars).

Also, how many items would such a list have? How the list should look like? 

 

--

"Poste eine dwg mit einem Beispiel für einen solchen MTEXT (= enthält der Inhalt "format chars").

Wie viele Einträge würde eine solche Liste haben? Wie sollte die Liste aussehen?"

@ВeekeeCZ comment translated above

0 „Gefällt mir“-Angaben
Nachricht 3 von 23

raumin
Contributor
Contributor

guten tag

es muss keine liste sein, es kann auch direkt im lisp hinterlegt sein und somit steure ich dann das icon.

wenn eine Liste möglich wäre so ungefähr 20-30 Einträge wählbar aus eine Dialogbox.

 

guten tag

danke für ihre rückmeldung.

Text sollte den gleichen Layer wie A2 in der dwg haben. der layer a2 ist aber immer in jeder zeichnung anders. die formatierung sollte so sein wie im script.

 

text sollte diese formatierung haben:

(command "_text" "st" "All CAD" "I" "MZ" pause "30" "0" "RW DEMONT." )

 

 

 

 

 

 

0 „Gefällt mir“-Angaben
Nachricht 4 von 23

ВeekeeCZ
Consultant
Consultant

Ok, the TEXT line is yours, untested by me. Double <enter> to add the last one.

 

(vl-load-com)

(defun c:AddNoteOf20 ( / :DclList lst )

  (setq lst '("Ohrwurm"
	      "Weichei"
	      "Backpfeifengesicht"
	      "Erklärungsnot"
	      "Purzelbaum"
	      "Zungenbrecher"
	      "Schattenparker"
	      "Kuddelmuddel"
	      "Speisekarte"
	      "Eselsbrücke"
	      "Kummerspeck"
	      "Innerer Schweinehund"
	      "Fremdschämen"
	      "Torschlusspanik"
	      "Treppenwitz"
	      "Lebensmüde"
	      "Dreikäsehoch"
	      "Sitzfleisch"
	      ))


  (defun :DclList (title lst multi / ch flg tmp file id lst)
  (if (and (setq tmp (vl-filename-mktemp nil nil ".dcl"))
	   (setq file (open tmp "w"))
	   (write-line (strcat "Dcllist : dialog { label = \"" title
			       "\";spacer;: row {: list_box {key = \"l\"; alignment = centered; width = "
			       (itoa (+ 10 (car (vl-sort (mapcar 'strlen (mapcar 'vl-princ-to-string lst)) '>))))
			       "; height = " (itoa (+ 3 (length lst)))
			       ";" (if multi " multiple_select = true;" " allow_accept = true;")
			       "}}spacer;ok_cancel;}")
	     file)
	   (not (close file)))
    (progn
      (setq id (load_dialog tmp))
      (new_dialog "Dcllist" id)
      (start_list "l")
      (mapcar 'add_list (mapcar '(lambda (x) (vl-princ-to-string x)) lst)) (end_list)
      (action_tile "l" "(setq ch $value)")
      (setq flg (start_dialog))
      (unload_dialog id)
      (vl-file-delete tmp)
      (if (and ch (= 1 flg))
	(mapcar '(lambda (x) (nth x lst)) (read (strcat "(" ch ")")))))))


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

   (if (setq *an-note* (cond ((car (:DclList "Select a note: " lst nil)))
			     (*an-note*)))
     (if (setq e (car (entsel "\nSpecify note to copy <create new>: ")))
       (progn
	 (command "_.copy" e "" "_non" '(0 0 0) "_non" '(0 0 0))
	 (setq e (entlast))
	 (setpropertyvalue e (if (= "MTEXT" (cdr (assoc 0 (entget e)))) "Contents" "TextString") *an-note*)
	 (command "_.move" e "" pause))
       (command "_text" "st" "All CAD" "I" "MZ" pause "30" "0" *an-note*)))
  (princ)
  )

 

Nachricht 5 von 23

raumin
Contributor
Contributor

danke ihnen. leider wir das script nicht geladen. was mache ich falsch?

0 „Gefällt mir“-Angaben
Nachricht 6 von 23

ВeekeeCZ
Consultant
Consultant

Seems like it's not even loaded.

 

Use updated code.

Make sure you use the lisp right, see THIS 

 

Edit. Now I see that your lsp file is one right parent short.

0 „Gefällt mir“-Angaben
Nachricht 7 von 23

raumin
Contributor
Contributor

es kommt diese meldung.

 

Befehl: AppLoad uv_demo.LSP erfolgreich geladen.
Befehl: Falsch formatierte Liste in Eingabe

0 „Gefällt mir“-Angaben
Nachricht 8 von 23

ВeekeeCZ
Consultant
Consultant

I can imagine. But I have nothing more to add than what is noted in the last msg.

0 „Gefällt mir“-Angaben
Nachricht 9 von 23

raumin
Contributor
Contributor

Perfekt, jetzt funktionierts. Vielen Dank

0 „Gefällt mir“-Angaben
Nachricht 10 von 23

CADaSchtroumpf
Advisor
Advisor

@ВeekeeCZ 

Good job, but for me this return an ADS error 

(setpropertyvalue e (if (= "MText" (getpropertyvalue e "LocalizedName")) "Contents" "TextString") *an-note*)

must be

(setpropertyvalue e (if (= "Textmult" (getpropertyvalue e "LocalizedName")) "Contents" "TextString") *an-note*)

for working correctly

Nachricht 11 von 23

ВeekeeCZ
Consultant
Consultant

@CADaSchtroumpf 

 

Thank you. Unfortunately, some of the property names differ from the release/language version. Well, the name implies it a bit, but who would have thought that the word Mtext could be localized.

The code update.

0 „Gefällt mir“-Angaben
Nachricht 12 von 23

raumin
Contributor
Contributor

sorry ich nochmals

jetzt wird die Formatierung vom kopierten Text verwendet aber nicht diese Einstellung von der dieser linie.

 

 

(command "_text" "st" "All CAD" "I" "MZ" pause "30" "0" *an-note*)))

0 „Gefällt mir“-Angaben
Nachricht 13 von 23

ВeekeeCZ
Consultant
Consultant

I see. The site removed the user info. 😞

 

Use updated code. When picking a text to copy, hit enter to create. It worked, but <create> info was missing.

0 „Gefällt mir“-Angaben
Nachricht 14 von 23

raumin
Contributor
Contributor

hallo

leider ist der text immer noch 70mm statt 30mm.

0 „Gefällt mir“-Angaben
Nachricht 15 von 23

ВeekeeCZ
Consultant
Consultant

I see. I've probably overestimated my ability to understand German. I will ask the moderator to move this to the German section where they will hopefully understand you better. I should have done it right away. My bad.

Good luck.

0 „Gefällt mir“-Angaben
Nachricht 16 von 23

raumin
Contributor
Contributor

Danke für Ihre Bemühungen.

 

0 „Gefällt mir“-Angaben
Nachricht 17 von 23

calderg1000
Mentor
Mentor

Regards @raumin 

Previous permission by for the variation of the code of @ВeekeeCZ 
Try this little change

(progn
	 (command "_.copy" e "" "_non" '(0 0 0) "_non" '(0 0 0))
;;;	 (setq e (entlast))
         (setq e (entget (entlast))
               e (entmod (subst (cons 40 30) (assoc 40 e) e))
               e (entlast)
         )
	 (setpropertyvalue e (if (= "MTEXT" (cdr (assoc 0 (entget e)))) "Contents" "TextString") *an-note*)
	 (command "_.move" e "" pause))

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 „Gefällt mir“-Angaben
Nachricht 18 von 23

raumin
Contributor
Contributor

guten tag

hat leider nicht funktioniert. im Anhang den ganzen code. was jetzt noch nicht funktioniert ist die schriftgrösse von 30mm und osmode 223. was müsste noch angepasst werden? ich wäre froh wenn mir jemand helfen könnte. besten dank.

0 „Gefällt mir“-Angaben
Nachricht 19 von 23

calderg1000
Mentor
Mentor

Dear @raumin 

Here I show you in a video how the routine works, and I am attaching the modified file...., maybe it is what you need...?


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 „Gefällt mir“-Angaben
Nachricht 20 von 23

raumin
Contributor
Contributor

guten tag

jetzt funktionierts. wie und wo kann ich osmode 223 am schluss einbauen? jetzt bleibt osmode 0 drin.

 

 

 

0 „Gefällt mir“-Angaben