Code Red > AutoLISP (Vanilla / Visual)

Pulling Text from an Xref

(1/2) > >>

Hangman:
So, ...  I jus got outa da meet'n (felt like a beat'n) and was giv'n a task ta do.

I'm hoping you guys can help me cause I don't know if this will even work.

Here's the task:
The user needs to pull some dtext from an xrefed drawing and add that text line to an attributed block.

Here's the questions:
...  where to start ???
Part 1,
Pulling the text from the xref, would the user have to do a ref-edit to select the text line or can the text line be pulled from the xref simply by picking the xref ??  If the latter applies, how is the text in the xref determined ??  In other words, how would the program know which text line has to be pulled ??  The text line will be random, so searching for specific words will not be an option.
I've seen discussions involving changing text in a block, but is it possible to copy the text from a block ?? And would this be similar as an xref is recognized as a block in a drawing ??

Part 2,
Placing that copied text from the xref into an attributed block and taking on the properties of the block, whatever was specified in the block.
The dtext line in the xref would be in Architxt.shx or a simplex.ttf font and the attribute block would be specified as an Arial.ttf font, different font style, different color, height, etc.
I don't even know where to start the questions here.  Can it be done ??  How can it be done ??  Will you show me please ??

I'm sure I'm missing some clarifications and not catching all the possible scenarios, so please don't assume anything, just throw the questions out to try and narrow this down to exactly what is needed.

And please throw some input in here, if this scenario I'm describing here will not work, would you have an idea or two of another way to accomplish the task ??

Thank you for your help.

Jeff_M:
To select nested text: (nentsel)

I'm not clear on how you are placing it in a block.....is the text to be a new text object in the block, or more of a fill in an attribute's value with the text value?

Sample dwg's?

T.Willey:
Sound like you want to select a piece of text (like Jeff said 'nentsel' is the ticket), then you want to fill in an attribute with the text information.  If you are replacing and existing text string (attribute has a value) then you can use 'nentsel' again to select the attribute, or you can just select the block, and then step through it using 'entnext' of the block entity, and test each attribute entity to make sure you are editing the right attribute.

Hangman:
The attribute is existing.  There is existing text that needs to be replaced by the text being selected from the xref.
It is a single line existing text so I won't have to test each string in the attribute block.

I don't believe I've ever used the (nentsel), is it as simple as I'm thinking it is ??

--- Code: ---  (setq selectedtext (nentsel "n\Select text in xref: "))

--- End code ---

Does it just select the text and set it ??

Too Cool, thanks.

T.Willey:
'nentsel' is just like 'entsel' except it lets you select nested objects, and returns a little more information, see help if you want the full break down.  The easiest way to do what you want is this

--- Code: ---(defun c:ReplaceText (/ Sel EntData Txt)

(and
 (setq Sel (nentsel "\n Select text to copy: "))
 (setq EntData (entget (car Sel)))
 (setq Txt (cdr (assoc 1 EntData)))
 (setq Sel (nentsel "\n Select attribute to replace: "))
 (setq EntData (entget (car Sel)))
 (entmod (subst (cons 1 Txt) (assoc 1 EntData) EntData))
 (entupd (car Sel))
)
(princ)
)

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version