Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi guys
I have this routine ConstructField.lsp from here (http://forums.autodesk.com/t5/Visual-LISP-AutoLISP
This routine do its the job very well, but now I would like to have some improvement.The routine makes a Field between an Attribute and a Mtext. In resume, It takes the « Value » of an Attribute and puts it in a Mtext. So, if I change the Attrribute, the Mtext will follow. Also, I can choose if the Mtext will be placed in the same layout or in another layout. However, I would like to have 2 particular changes:
- Instead of select a point and click to create a new Mtext, it is possible to click on a existing Text, Mtext or Attribute to simply replace it?
- Instead to make a Field only from an Attribute to a Mtext, I would like that the source could be also a Text or a Mtext and the destination could be another Text, Mtext or Attribute. I mean, no matter what kind of source I take, and no matter what kind of destination I put it. The routine will acept all of them (Text, Mtext & Attribute).
Exemple: If my source is an Attribute, I will be able to select a Text, Mtext or another Attribute to destination. If my source is a Text,I will be able to select a Mtext, Attibute or another Text to destination and so on…
If my second issue is to hard, I will be glad only with the first one.
By the way, I saw this routine CopyTextV1-3.lsp at Lee-Mac (http://www.lee-mac.com/copytext.html). The CTx command is pretty similar to what I need, but :
- Don’t need to have the leader option.
- Instead to just copy the text bettween the source and the destination, I would like to have this with Fields to keep it linked.
- With the possibility to choose the layout tab to put the destination.
Thanks for any help,
Solved! Go to Solution.
Re: Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
msarqui wrote:Hi guys
I have this routine ConstructField.lsp from here (http://forums.autodesk.com/t5/Visual-LISP-AutoLISP
-and-General/Extract-Field-Expression/td-p/3364401 ...). It was made by gjrcmb (He does not put his name into) .......
Exemple: If my source is an Attribute, I will be able to select a Text, Mtext or another Attribute to destination. If my source is a Text,I will be able to select a Mtext, Attibute or another Text to destination and so on…
Thanks for any help,
Quick mod
(defun c:ConstructField (/ enam elst objid fldexp enm2)
(vl-load-com)
(while (null (setq enam (car (nentsel "\nSelect TEXT/MTEXT/ATTRIBUTE: "))))
(princ "Nothing Selected")
)
(cond ((and
(setq elst (entget enam))
(setq elst (member (cdr (assoc 0 elst)) '("ATTRIB" "TEXT" "MTEXT")))
(setq objid (vla-get-ObjectId (vlax-ename->vla-object enam)))
(setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).TextString>%"))
(setvar "cmdecho" 0)
(setq glay (Strcase (getstring "\nSpecify Layout Tab to Place MText Object On: ")))
(progn (If (and (not (= glay ""))
(member glay (mapcar 'strcase (cons "MODEL" (layoutlist)))))
(setvar 'Ctab glay)) T)
(setq enm2 (car (nentsel "\nSelect String: ")))
(setq enam (member (cdr (assoc 0 (entget enm2))) '("ATTRIB" "TEXT" "MTEXT")))
(not (vla-put-textstring (vlax-ename->vla-object enm2) fldexp))
(setvar "cmdecho" 1)
(vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
)
)
)
(vl-some
'(lambda (j) (if (null (eval (car j))) (princ (cadr j))
))
'((elst "\nSelected Entity is Not valid for Field value.")
(enm2 "\nNothing Selected")
(enam "\nSelected Entity is Not valid for Field value."))
)
(princ)
)
As for this one:
msarqui wrote:By the way, I saw this routine CopyTextV1-3.lsp at Lee-Mac (http://www.lee-mac.com/copytext.html). The CTx Thanks for any help,
You can leave a message on his weblink msarqui and ask for the additional options
HTH
Re: Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello pbejse
I put the routine from Lee-Mac as an example only.
Analyzing your routine, I had one last idea that seems (to me) impossible with lisp, but still I want to share with you: instead of choosing the layout tab by typing its name on the command line, it would be possible to just click on the layout tab to choose it ?
But do not worry if this is not possible or if is to hard, since the routine you did is exactly what I asked.
I'm starting to run out of compliments for you because once again the routine you made is really good. I am very grateful for your work.
Re: Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
msarqui wrote:Hello pbejse
......Iam verygratefulfor your work.
You are welcome msarqui.
msarqui wrote:
Analyzing your routine, I had one last idea that seems (to me) impossible with lisp, but still I want to share with you: instead of choosing the layout tab by typing its name on the command line, it would be possible to just click on the layout tab to choose it ?
But do not worry if this is not possible or if is to hard, since the routine you did is exactly what I asked.
Not sure if you can do that with newer versions of Autocad.
Look here: --> Navigate Layout Tab
We can modify the code using the routine from that thread.
[Attached file: ConstructField2.lsp]
HTH
Cheers
Re: Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Perfect!!!!!!!!
The ListBoxDia "thing" is perfect for easily switching layouts.
Thanks and best regards!
Re: Link between Text, Mtext and Attribute with Field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
msarqui wrote:...
Thanks and best regards!
Anytime msarqui.
I'm happy to help.
Cheers
