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

Attribute to text

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
450 Views, 14 Replies

Attribute to text

I'm looking for a routine that will copy an attribute into a text entity. We
have a block that has three attributes; PNTNO, PNTDESC and PNTELEV. I'm
wanting to get the PNTDESC out of each and make it into text while leaving
the original attribute intact. Basically what will be accomplished is each
of my symbols will have its description as a label. Our engineers do not use
our survey points with attributes in their drawing which is on a separate
layer than the symbol itself.

I have Dotsoft's Toolpac and only see ways to explode the attribute to text.
That would leave a lot of cleanup because I don't need the other two
attributes as text.

Thanks
Jason
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

Something like this?

(defun c:CopyAtt2Text (/ ActDoc CurSp Sel Obj NewObj)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq CurSp
(if (equal (getvar "cvport") 1)
(vla-get-PaperSpace ActDoc)
(vla-get-ModelSpace ActDoc)
)
)
(setq Sel (nentsel "\n Select attribute to copy to text: "))
(setq Obj (vlax-ename->vla-object (car Sel)))
(setq NewObj (vlax-invoke CurSp 'AddText "Hello" '(0.0 0.0 0.0) 0.1))
(mapcar
'(lambda (x) (vlax-put NewObj x (vlax-get Obj x)))
'("Alignment" "Backward" "Color" "Height" "InsertionPoint" "Layer"
"Linetype" "LinetypeScale" "Lineweight" "Normal" "Rotation" "ScaleFactor"
"StyleName" "TextAlignmentPoint" "TextString")
)
(princ)
)

--

Tim
"A blind man lets nothing block his vision."


"JB" wrote in message
news:5586713@discussion.autodesk.com...
I'm looking for a routine that will copy an attribute into a text entity. We
have a block that has three attributes; PNTNO, PNTDESC and PNTELEV. I'm
wanting to get the PNTDESC out of each and make it into text while leaving
the original attribute intact. Basically what will be accomplished is each
of my symbols will have its description as a label. Our engineers do not use
our survey points with attributes in their drawing which is on a separate
layer than the symbol itself.

I have Dotsoft's Toolpac and only see ways to explode the attribute to text.
That would leave a lot of cleanup because I don't need the other two
attributes as text.

Thanks
Jason
Message 3 of 15
Anonymous
in reply to: Anonymous

Yes, that is sort of what I'm looking for. I want to be able to select the entire drawing rather than picking each attribute at a time. Again, I just want to get the one attribute not all three.

I did find in Toolpac a routine that will copy attributes to text, but it is getting all three.
Message 4 of 15
Anonymous
in reply to: Anonymous

Can you do this yourself, change the code I gave you? Do you want help in
the process?

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5586847@discussion.autodesk.com...
Yes, that is sort of what I'm looking for. I want to be able to select the
entire drawing rather than picking each attribute at a time. Again, I just
want to get the one attribute not all three.

I did find in Toolpac a routine that will copy attributes to text, but it is
getting all three.
Message 5 of 15
Anonymous
in reply to: Anonymous

I do not write code. I posted on here figuring that someone has seen a routine, written one or would like the challenge. I used to write programs 20 years ago in Basic and Pascal, but I never learned LISP. I've always wanted to learn, but never found time to do so. If I had a good source book to learn from a may pursue it one day.

If you don't want to help, that's cool. I completely understand. I used to do things like this for people just because I enjoyed doing it and liked the challenge.
Message 6 of 15
Anonymous
in reply to: Anonymous

The problem is it's not a challenge, and people seem to post here who want
stuff and are not willing to try and lisp, they just have their hands out.
I have helped many because I have been helped by many, but it gets old when
people are not willing to try. Most of the people who help here have full
time jobs as well as try to help those who ask questions.

Now with that said, to do what you want to do, one would need to know the
name of the block and the tag name of the attribute you want to copy.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5586926@discussion.autodesk.com...
I do not write code. I posted on here figuring that someone has seen a
routine, written one or would like the challenge. I used to write programs
20 years ago in Basic and Pascal, but I never learned LISP. I've always
wanted to learn, but never found time to do so. If I had a good source book
to learn from a may pursue it one day.

If you don't want to help, that's cool. I completely understand. I used to
do things like this for people just because I enjoyed doing it and liked the
challenge.
Message 7 of 15
Anonymous
in reply to: Anonymous

Block name = SRVPNO1
Attribute Tag = DESC2

What's a good source to learn the basics? Thanks for your help. I'll be glad to pay you for it through Paypal if you'd like, if your services isn't too much.
Message 8 of 15
Anonymous
in reply to: Anonymous

Hey Tim,

That mapcar thing is a nice idea. 🙂

Joe
Message 9 of 15
Anonymous
in reply to: Anonymous

Thanks Joe. It was the easiest way to do it.

--

Tim
"A blind man lets nothing block his vision."


"Joe Burke" wrote in message
news:5587013@discussion.autodesk.com...
Hey Tim,

That mapcar thing is a nice idea. 🙂

Joe
Message 10 of 15
Anonymous
in reply to: Anonymous

What I do here isn't worth much money to me. I like to help people who want
to learn, that is why I help here. As long as people don't just assume if
they post a question, someone is going to give them a whole routine that
works without them doing anything.

I had someone to teach me the basics at the first real job I had when I got
out of school. I think aftralisp.net is a good place to start. I would
just jump in, and look at the help files, and then post if I can't find the
answer I'm looking for. Which is what I do now because I don't know
everything.

(defun c:Atts2Text (/ CopyAtt ActDoc CurSp ss Ent)

(defun CopyAtt (Spc Obj / NewObj)

(setq NewObj (vlax-invoke Spc 'AddText "Hello" '(0.0 0.0 0.0) 0.1))
(mapcar
'(lambda (x) (vlax-put NewObj x (vlax-get Obj x)))
'("Alignment" "Backward" "Color" "Height" "InsertionPoint" "Layer"
"Linetype" "LinetypeScale" "Lineweight" "Normal" "Rotation" "ScaleFactor"
"StyleName" "TextAlignmentPoint" "TextString")
)
)
;--------------------------------------------------------------
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq CurSp
(if (equal (getvar "cvport") 1)
(vla-get-PaperSpace ActDoc)
(vla-get-ModelSpace ActDoc)
)
)
(if (setq ss (ssget '((0 . "INSERT") (2 . "SRVPNO1"))))
(while (setq Ent (ssname ss 0))
(foreach Att (vlax-invoke (vlax-ename->vla-object Ent) 'GetAttributes)
(if (= (vla-get-TagName Att) "DESC2")
(CopyAtt CurSp Att)
)
)
(ssdel Ent ss)
)
)
(princ)
)

This should do what you want. Untested.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5587032@discussion.autodesk.com...
Block name = SRVPNO1
Attribute Tag = DESC2

What's a good source to learn the basics? Thanks for your help. I'll be glad
to pay you for it through Paypal if you'd like, if your services isn't too
much.
Message 11 of 15
Anonymous
in reply to: Anonymous

Thanks for your assistance. I'll check the website out. There's no doubt I'll get the programming bug once I learn the basics. It's just finding the time to learn it.

Thanks again.
Message 12 of 15
Anonymous
in reply to: Anonymous

Is your website reference spelled correctly? I tried it and could not find it.
Message 13 of 15
Anonymous
in reply to: Anonymous

Here is a valid link. Just tired it.

http://www.afralisp.net/

Tim
wrote in message news:5587393@discussion.autodesk.com...
Is your website reference spelled correctly? I tried it and could not find
it.
Message 14 of 15
Anonymous
in reply to: Anonymous

You must have done this intentionally to see if I could figure it out.
(if (= (vla-get-TagName Att) "DESC2")
should have been
(if (= (vla-get-TagString Att) "DESC2")
correct?

The funny thing is that I used a post of yours from a year ago to figure it out.
http://forums.augi.com/printthread.php?t=40022

Thanks again.
Message 15 of 15
Anonymous
in reply to: Anonymous

I didn't do that one purpose, just slip out while think 'tag name' and
trying to type TagString. Glad you got it working Jason.

Tim


wrote in message news:5589320@discussion.autodesk.com...
You must have done this intentionally to see if I could figure it out.
(if (= (vla-get-TagName Att) "DESC2")
should have been
(if (= (vla-get-TagString Att) "DESC2")
correct?

The funny thing is that I used a post of yours from a year ago to figure it
out.
http://forums.augi.com/printthread.php?t=40022

Thanks again.

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

Post to forums  

Autodesk Design & Make Report

”Boost