Author Topic: Pulling Text from an Xref  (Read 2625 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Pulling Text from an Xref
« on: September 20, 2006, 04:54:32 PM »
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.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Pulling Text from an Xref
« Reply #1 on: September 20, 2006, 05:08:12 PM »
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

  • Needs a day job
  • Posts: 5251
Re: Pulling Text from an Xref
« Reply #2 on: September 20, 2006, 05:14:15 PM »
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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling Text from an Xref
« Reply #3 on: September 20, 2006, 05:43:38 PM »
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: [Select]
  (setq selectedtext (nentsel "n\Select text in xref: "))

Does it just select the text and set it ??

Too Cool, thanks.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling Text from an Xref
« Reply #4 on: September 20, 2006, 05:52:38 PM »
'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: [Select]
(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)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling Text from an Xref
« Reply #5 on: September 20, 2006, 06:04:20 PM »
Tim,
This is exactly what I'm trying to do.  I had no idea.  Thank you very much.

I was a bit lost with what had the info from the selected text.  Now I realize I need to break it down as you have shown.  You have some things in there I don't recognize, but I can go look up the definitions now and learn some more.

Thanks again, you guys are great !!!
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling Text from an Xref
« Reply #6 on: September 20, 2006, 06:05:56 PM »
You're welcome.  You might want to add some error checking.  Right now you can change a nested text object, which don't think you want to do because then it will change it all instances of the block.  Just an FYI.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling Text from an Xref
« Reply #7 on: September 20, 2006, 06:22:30 PM »
Awww crap !!!
I had to go and open my big mouth and brag about you guys and now I'm going to pay for it.

They (the ones I bragged to) threw out another idea.

Say you have 5 typical details lined up in your drawing.  They are all xrefed in and the description of the typical detail is on Defpoints on the bottom left side of each xrefed detail.  The Title bar of the details are on the sheet the details were xrefed into.
They asked if they could select all 5 details at once in a window selection and have the title from each xref transfer to the title bar on the page.

Cool hunh !?!   :lol:

Thanks Tim for the FYI, I'll go put some error checking and other stuff in.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling Text from an Xref
« Reply #8 on: September 20, 2006, 06:42:15 PM »
You're welcome.

As to your new problem, I think you could.  It will take a little more code.  You will search each block definition, find a text object on the defpoints layer, and transfer that to the new text/attribute object.  I will let you code this one yourself.  I will only help.   :wink:  Time to fly!  :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Pulling Text from an Xref
« Reply #9 on: September 20, 2006, 06:47:02 PM »
Yes, Hangman, that could be done.....although I'd wonder if the Title bar on the current sheet had sufficient space for all 5 titles......

Now is when the drawings in question would be really handy to answer any questions.