Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selected Text to Tagged Attribute including Prefix/Suffix

12 REPLIES 12
Reply
Message 1 of 13
LSFiretrol
1563 Views, 12 Replies

Selected Text to Tagged Attribute including Prefix/Suffix

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.

12 REPLIES 12
Message 2 of 13
3wood
in reply to: LSFiretrol

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.

Message 3 of 13
Hallex
in reply to: LSFiretrol

Try attached lisp, let us know what you need to change

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 13
pbejse
in reply to: LSFiretrol


@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? 

 

Message 5 of 13
pbejse
in reply to: pbejse

(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

 

Message 6 of 13
LSFiretrol
in reply to: LSFiretrol

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

Message 7 of 13
pbejse
in reply to: LSFiretrol


@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] Smiley LOL


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..... Smiley Happy

HTH

Message 8 of 13
LSFiretrol
in reply to: LSFiretrol

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

Message 9 of 13
pbejse
in reply to: LSFiretrol


@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? 

Message 10 of 13
LSFiretrol
in reply to: pbejse

Yes. All three lines are text.

Sent from my iPhone
Message 11 of 13
pbejse
in reply to: LSFiretrol

HYG [attached file]

 

HTH

 

Sent from my Dell Laptop 

Message 12 of 13
LSFiretrol
in reply to: pbejse

I'm sorry but no attached file?

Lou A Scarantino, ET
Fire Alarm Operations Manager
Firetrol Protection Systems
11111 Landmark 35 Drive
San Antonio, TX 78233
(210) 270-8400 Office
(210) 270-8401 Fax
(210) 315-3400 Cell
www.firetrol.net
24 Hour Emergency Service

[cid:image001.gif@01CDECE6.407009D0]
[cid:image002.jpg@01CDECE6.407009D0]
[cid:image003.jpg@01CDECE6.407009D0] [cid:image004.jpg@01CDECE6.407009D0]
GSA # GS-06F-0063S TXMAS # 6-03FAC020
Message 13 of 13
pbejse
in reply to: LSFiretrol


@LSFiretrol wrote:
I'm sorry but no attached file?


Yes there is.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost