Jump to content

Recommended Posts

Posted

Latest code:

 

;; Txt2Att  ( Lee Mac )
;; Converts Single-line Text to Attribute Definition

(defun c:txt2att ( / StringSubst RemovePairs ss ent eLst str dx73 )
 (vl-load-com)
 ;; Lee Mac  ~  27.04.10

 (defun StringSubst ( new pat str )
   (while (vl-string-search pat str)
     (setq str (vl-string-subst new pat str))
   )
   str
 )

 (defun RemovePairs ( lst pairs )
   (vl-remove-if
     (function
       (lambda ( pair )
         (vl-position (car pair) pairs)
       )
     )
     lst
   )
 )

 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   
   ( (lambda ( i )
       
       (while (setq ent (ssname ss (setq i (1+ i))))
         (setq eLst (entget ent)
               str  (StringSubst "_" " " (cdr (assoc 1 eLst)))
               dx73 (cdr (assoc 73 eLst)))

         (setq eLst (RemovePairs eLst '( 0 100 1 73 )))

         (if (entmake (append '( (0 . "ATTDEF") ) eLst (list (cons 70    0)
                                                             (cons 74 dx73)
                                                             (cons 1   str)
                                                             (cons 2   str)
                                                             (cons 3   str))))
           (entdel ent)
         )
       )
     )
     -1
   )
 )

 (princ))

  • Like 1
Posted

Its astounding to see how far I've come from that first post of mine... :oops:

 

Nice to hear you're still using the code :)

Posted

Long time back im using this code

by the way, whats the deference between CODE, LISP and ROUTINE

Posted

Not much difference really, the code is what is typed, the LISP is the file itself perhaps, and the routine may refer to the program algorithm

  • 1 year later...
Posted

Lee,

 

Is there any chance I can convince you to go back to this useful utility and adapt it for converting multiline text to multiline attribute? I guess it would need to handle multiple single-line texts and MText as well. Or, at least, it should handle MText since Express Tools has a Text2MText tool that can be used, if necessary.

 

I appreciate you even considering it. Thanks!

 

 

-Patch

  • 1 year later...
Posted

Hi sir,

I am searching a lisp for converting text (inside block) to attribute definition. like your program txt2att. Can you help me. Thanks in advance

 

Manigandan

  • 1 year later...
Posted

Lee, is there any way to modify a line of that code to get to it insert a default "PROMPT" of Drawing Number: .... with the semicolon at the end? Would be awesome if I can change it easily to whatever default I want....even if it means modifying the code.

Posted
Lee, is there any way to modify a line of that code to get to it insert a default "PROMPT" of Drawing Number: .... with the semicolon at the end? Would be awesome if I can change it easily to whatever default I want....even if it means modifying the code.
I think the 3 value is the one you want to change, i.e., substitute your prompt string in place of str in that case. Also, I think the colon is automatically provided by AutoCAD.
  • 1 year later...
Posted

Hi everybody.

 

I need the result of that entmake as an SSGET selection

 

Is there an obvious way of doing that?

 

----

 

(setq result (entmake (list (cons 0 "ATTDEF") ....

 

then I have a function that requires the result of an SSGET

I want to feed result to that function

 

I know Lee Mac has such conversion functions, like (LM:ss->vla ss)

Is there something like a (LM:entmake->ss result) ?

Posted
I need the result of that entmake as an SSGET selection

 

Is there an obvious way of doing that?

 

Use entmakex in place of entmake and add the entity name returned by this function to a selection set using ssadd.

Posted

Works like a charm.

 

Thanks.

  • 10 months later...
Posted

Lee, It's wonderful lisp,

For example we can converts 100 text to 100 tags

But can we convert 100 tags to 100 blocks?

Txt2Tag2Block

Blocks name should be same.

Posted

Could you explain that question a little more thoroughly?

 

 

What exactly are you starting with? ATTDEF entities loose in the dwg, or is it still text entities ?

 

 

And now you want each of these values in a ATTDEF inside a block.

And presumably you want the block to be inserted, so that the attribute stays in the same position as the text used to be?

 

 

The block definition already exists, it has 1 (or more) attribute , ...

 

 

Right?

Posted

Absolutely right,

I want to convert text to attribute blocks value, not to tag (attribute definition)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...