Hello,
I have very little knowledge in complex Autolist routines and really need help after countless hours searching for a routine to do the following:
I would like to be able to provide a Prefix and/or Suffix via dialog then pick any line of text or multiple lines of text and have it concentrate. For example: Prefix: First Floor Suffix: M100. I pick the room text on an arch floor plan "Mechanical room" and the second line "100" The result will be "First Floor Mechanical room 100 M100".
But lets take it a final step further; once condensed, I want it added to a perticular tag attribute in a block I inserted.
Example of how I would use it. I insert a symbol for an addressable smoke detector that has several tags; one of them being Location. I would use this routine to gather the information provided by the Arch floor plan and join it with the block attribute for exporting later for use in the Fire Alarm Panel Programming.
attached is a sample block with the attributes.
You can try ALTEXT.vlx in attachment.
I can imagine 3 steps to complet the task.
1. Use a lisp formula in ALTEXT to pick up the room name and assign it to the attrubite.
2. Add prefix to previous selection.
3. Add suffix to previous selection.
Or you can combine step 2 & 3 into the lisp file in Step 1.
Try attached lisp, let us know what you need to change
@LSFiretrol wrote:
...... But lets take it a final step further; once condensed, I want it added to a perticular tag attribute in a block I inserted.
....
So its an existing attribute block already inserted?
(Defun c:Send2att ( / _Valid text blk ) ;;; pBe 07April2013 ;;; (vl-load-com) (setq _Valid (lambda (x / y) (if (not (or (numberp (eval (setq y (lisped x)))) (eq "" y))) y ))) (And (setq pref (_valid (cond (pref) ("First Floor")))) (setq suf (_valid (cond (suf) ("M100"))))) (While (and pref (princ "\n<<<Select Text/Mtext>>> [Enter to Exit]") (setq text (ssget "_:S:E:L" '((0 . "TEXT,MTEXT")))) (not (redraw (ssname text 0) 4)) (not (redraw (ssname text 0) 3)) (setq text (vlax-ename->vla-object (ssname text 0))) (princ "\n<<<Select Attribue Block>>>") (setq blk (ssget "_:S:E:L" '((0 . "INSERT") (2 . "NAC&SPK_CIRCUIT") (66 . 1)) ) ) ) (progn (vla-put-textstring text (setq str (strcat pref " " (vla-get-textstring text) " " suf)) ) (foreach at (vlax-invoke (vlax-ename->vla-object (ssname blk 0)) 'getattributes) (if (eq (strcase (vla-get-tagstring at)) "LOCATION") (vla-put-textstring at (vl-string-subst "" "\\P" str)) ) ) ) ) (princ) )
HTH
BTW: Welcome to Autodesk Visual-LISP-AutoLISP-and-General forum 🙂
Cheers
Hello,
Thanks for the response. I truly appreciate it. The lisp worked as far as adding the string to the attribute but it also changed the mtext using the prefix and suffix. so as an example, it added "First Floor Office M100" to the attribute (Location) tag AND changed the text on the floor plan.
The other item would be what part of the Lisp do I change for different blocks? In other words, I use five different Blocks all having the Tag location but the block names are different. Since I'm not very good at code yet, Im asking if its as simple as changing the "Block Name" in the code or is there more to it. Attached are two examples of different blocks requiring location.
Lastly, How do I learn to do what you are capable of doing? Trial and error doesnt work so well for me.
Regards,
Lou
@LSFiretrol wrote:Hello,
Thanks for the response. I truly appreciate it. The lisp worked as far as adding the string to the attribute but it also changed the mtext using the prefix and suffix
Guess you dont want that then. [probably mis-read your post]
The other item would be what part of the Lisp do I change for different blocks?
Yes.you can include all the block names (separated by a comma "," ) that have the LOCATION tag.
(setq blk (ssget "_:S:E:L" '((0 . "INSERT") (2 . "NAC&SPK_CIRCUIT,SLC_Module,SLC_Device") (66 . 1)) ) )
Modified code:
(Defun c:Send2att ( / _Valid text blk ) ;;; pBe 08April2013 ;;; (vl-load-com) (setq _Valid (lambda (x / y) (if (not (or (numberp (eval (setq y (lisped x)))) (eq "" y))) y ))) (And (setq pref (_valid (cond (pref) ("First Floor")))) (setq suf (_valid (cond (suf) ("M100"))))) (While (and pref (princ "\n<<<Select Text/Mtext>>> [Enter to Exit]") (setq text (ssget "_:S:E:L" '((0 . "TEXT,MTEXT")))) (not (redraw (ssname text 0) 3)) (princ "\n<<<Select Attribue Block>>>") (setq blk (ssget "_:S:E:L" '((0 . "INSERT") (2 . "NAC&SPK_CIRCUIT,SLC_Module,SLC_Device") (66 . 1)) ) ) ) (progn (foreach at (vlax-invoke (vlax-ename->vla-object (ssname blk 0)) 'getattributes ) (if (eq (strcase (vla-get-tagstring at)) "LOCATION") (vla-put-textstring at (vl-string-subst " " "\\P" (strcat pref " " (vla-get-textstring (vlax-ename->vla-object (ssname text 0))) " " suf ) ) ) ) )(redraw (ssname text 0) 4) ) ) (princ) )
@LSFiretrol wrote:.....
Lastly, How do I learn to do what you are capable of doing? Trial and error doesnt work so well for me.
Regards,
Lou
Practice.. practice...practice.....
HTH
Thanks you so much for this. I tried to revise it to do one more thing with no success. In otherwords, I tried practice but not working yet. As your probably know, many times there are several lines of text for a room description, for example:
Mechanical
Room
101
I am Trying to get this routine to grab all three lines prior to asking to pick the attribute. Is that possible?
Thanks
Lou
@LSFiretrol wrote:
I am Trying to get this routine to grab all three lines prior to asking to pick the attribute. Is that possible?
Lou
Are we dealing only with TEXT entities?