Replace Text to filename problem...

Replace Text to filename problem...

danglar
Advocate Advocate
1,410 Views
6 Replies
Message 1 of 7

Replace Text to filename problem...

danglar
Advocate
Advocate

This Aleksandr Smirnov (ASMI) program can copy the filename of drawing to Text, MText, Tables, Dimensions and Attributes

In Multiple modes with option to insert file name of drawing as regular text (added by me).

Program working properly but a little “dirty”. I mean we have here at least 2 unnecessary steps. First – insert filename as text into the drawing as regular text entity.. After what we can copy this text and paste it in multiple mode (replace Text, MText, Tables, Dimensions and Attributes to filename of drawing)

and Second unnecessary step – delete inserted text with filename (see attached lisp)

Is it possible to eliminate these two unnecessary steps in order to select Text, MText, Tables, Dimensions and Attributes and replace it immediately to file name?

Any help will be very appreciated

0 Likes
Accepted solutions (1)
1,411 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hi,

 

i think this lisp similar you need:

 

(defun c:test ()
(if (setq txt_1 (car (nentsel "\n Select text,mtex,dim,attribute 1: ")))
(progn
(setq vla_1 (vlax-ename->vla-object txt_1))
(while (setq txt_2 (car (nentsel "\n Select text,mtex,dim,attribute 2: ")))
(setq vla_2 (vlax-ename->vla-object txt_2))
(vla-put-textstring vla_2 (vla-get-textstring vla_1))
)
)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acAllViewports)
)

 

0 Likes
Message 3 of 7

danglar
Advocate
Advocate

Thanks for replay

 

Unfortunately it’s not exactly what I need

I need to Replace Text to filename in a same way your program work

Can you modify your program?

0 Likes
Message 4 of 7

danglar
Advocate
Advocate

.. another "dirty" modification.

same problem, but from another point of view

(defun c:tt ()
(setq aa (strcat (vl-filename-base (getvar 'DwgName)) ".dwg"))
(command "-style" "temp" "arial.ttf" "" "" "" "" "")
(command "_.TEXT" "s" "temp" (getpoint) 2 0 aa)

(if (setq txt_1 (car (nentsel "\n Select text,mtex,dim,attribute 1: ")))
(progn
(setq vla_1 (vlax-ename->vla-object txt_1))
(while (setq txt_2 (car (nentsel "\n Select text,mtex,dim,attribute 2: ")))
(setq vla_2 (vlax-ename->vla-object txt_2))
(vla-put-textstring vla_2 (vla-get-textstring vla_1))
)
)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acAllViewports)
(command "erase" "l" "")
)

0 Likes
Message 5 of 7

Anonymous
Not applicable
Accepted solution

Hi, maybe this code:

 

(defun c:tt ()
(setq aa (strcat (vl-filename-base (getvar 'DwgName)) ".dwg"))
(while (setq txt (car (nentsel "\n Select text,mtex,dim,attribute: ")))
(setq vla_obj (vlax-ename->vla-object txt))
(vla-put-textstring vla_obj aa)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acAllViewports)
)

Message 6 of 7

danglar
Advocate
Advocate

Wow! It's Perfect!

This is exactly what I need.

Thank you

 

0 Likes
Message 7 of 7

Anonymous
Not applicable

You are welcome.!

 

^_^

0 Likes