.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble getting textstring from attribute definition

62 REPLIES 62
Reply
Message 1 of 63
myspambox111
1090 Views, 62 Replies

Trouble getting textstring from attribute definition

I have been creating block attributes with some good success. Example:







While btrEnum.MoveNext

Dim ent As Entity = btrEnum.Current.GetObject(OpenMode.ForWrite)

If TypeOf ent Is AttributeDefinition Then

Dim attdef As AttributeDefinition = ent

Dim attref As New AttributeReference

attref.SetAttributeFromBlock(attdef, myBRef.BlockTransform)

attref.TextString = myReader.ReadLine

attColl.AppendAttribute(attref)

trans.AddNewlyCreatedDBObject(attref, True)

End If



End While

Now, when I try to read those attribute's textstrings back later for different reasons, I receive only the "default" attribute textstring instead of the one I inserted earlier in the program. Example:



While btrEnum.MoveNext

Dim ent As Entity = btrEnum.Current.GetObject(OpenMode.ForWrite)

If TypeOf ent Is AttributeDefinition Then

Dim attdef As AttributeDefinition = ent

Dim attref As New AttributeReference

attref.SetAttributeFromBlock(attdef, myBRef.BlockTransform)

If attdef.Tag.ToUpper = myTag.ToUpper Then

value = attdef.TextString

End If

End If

End While

Why doesn't this return the textstring value recorded earlier?



Is there an easier way to do this?
62 REPLIES 62
Message 41 of 63

Whell, your probabley write, sew I think ill just teech a clas insted. Sea yew ther!



jvj
Message 42 of 63
NathTay
in reply to: myspambox111


Well put. If we needed any more proof of your hypocrisy we have it.

Message 43 of 63
myspambox111
in reply to: myspambox111

I just wanted to say thanks to you Mikko for actually answering my question.



I don't understand the answer though.

-------------------------------------------------------------------------------------------------



Private Sub GetAttributes(ByVal NameOfBlock As String)

Dim findThis() As TypedValue = {New TypedValue(0, "INSERT"), New TypedValue(2, NameOfBlock)}

Dim sf = New SelectionFilter(findThis)

Dim psr As PromptSelectionResult = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.SelectAll(sf)

If psr.Status = PromptStatus.OK Then

Using t As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()

For Each h As ObjectId In From q As ObjectId In psr.Value.GetObjectIds()

Dim br = CType(t.GetObject(h, OpenMode.ForRead), BlockReference)

For Each k As ObjectId In br.AttributeCollection

Dim ar As AttributeReference = CType(t.GetObject(k, OpenMode.ForRead), AttributeReference)

MsgBox(ar.TextString)

Next k

Next

t.Commit()

End Using

End If

End Sub

-------------------------------------------------------------------------------------------------

I have no clue about:

Dim findThis() As TypedValue = {New TypedValue(0, "INSERT"), New TypedValue(2, NameOfBlock)}

Dim sf = New SelectionFilter(findThis)

Dim psr As PromptSelectionResult = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.SelectAll(sf)

Is this the only way to get my block's attributes? Obviously the attributes exist when I insert them in the drawing. Can I not get them directly without searching and having a filter and a result collection? Why does this collection hold the value but not the way I did it?



Without any pissing contests, can anyone answer me this in a little more detail?

(Mikko's code is also attached as a text file for those who need it)



Thanks!

Brandon
Message 44 of 63
Anonymous
in reply to: myspambox111



BTW, the book in question is still
selling copies. Where's your book?

 

Sales are not the best
measureing stick to use... Shouldn't the person writing a book be expert on the
subject beyond

reproach? You would think they would be here
defending their writting and helping us out thus promoting the
books

sales further. Wonder why people aren't emailing this guy and asking him
questions - that's right because they say he

does not respond - hmmm. Tony is constantly here helping us out where
is your author again? So is anyone here

upset the dude wrote a book - of course not! The fact that he
convinced so many that they can attack this api with what

little he knows is creating people reposting his code without knowing what
they are doing and messing up this group!

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
BTW,
the book in question is still selling copies. Where's your
book?



Nuff said.



jvj
Message 45 of 63
sgsawdy
in reply to: myspambox111

Not to get into the merits of Jerry's book nor to defend it, but, every time I have written to Jerry, he has responded and has tried to help.

Scott
Message 46 of 63
Anonymous
in reply to: myspambox111


When I read Tony Tanzillo's stupid belittling
responses I laugh because he's nothing but an old saw horse (working out of his
basement) ready for pasture.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
That
is a jumble of irrelevant nonsense which only goes to show your true reason
for the question which is a deep hatred of Tony for belittling
you.



The quality of information you are spreading has absolutey
no connection to how nice you are. You aren't actually in a position to take
the moral high ground either with your debates with Tony it hasn't exactly
been one sided nastiness.



Please not not write a book as your
incompetence has been shown time and time again.
Message 47 of 63
NathTay
in reply to: myspambox111

You should find the answer in Jerry's book.



Basically you have not taken my advice and still have no idea about the purpose of block definitions and references.



You need to understand the basics of AutoCAD before you start programming it.
Message 48 of 63
myspambox111
in reply to: myspambox111

I have understood it enough to write a half dozen programs and macros. I also understand that the way these concepts are explained and the approach taken has differed from one source to the next. The best reference I have had has been the arx inspector tool which I can no longer use as I've upgraded to autocad x64 and it doesn't seem to be compatible. This shows the inner working of the definitions and references but I haven't been able to use it in over a month to refresh my memory.

If anyone has the inspector tool for x64 or has a link to the download I'd appreciate it.
Message 49 of 63
NathTay
in reply to: myspambox111


The reason you have your knickers in a twist on this occasion is because you do not have an understanding of working in AutoCAD. You may have gotten away with no knowledge up to this point but the gripes you are making about how block definitions and references work is purely down to the fact you are ignorant. If you had a working knowledge of AutoCAD you would realise why things are how they are.

Message 50 of 63
myspambox111
in reply to: myspambox111

Another senseless post by you.

Postcount+1?
Message 51 of 63
NathTay
in reply to: myspambox111

It seems senseless to you because of your ignorance. I am giving you very good advice. Learn the basics of using AutoCAD and it will help you understand programming it easier.



You claim how smart you are because you have written programs for AutoCAD without a basic understanding of AutoCAD. You also claim if someone gives you an example you can understand it. The code you have posted here and your rants prove that wrong.



You need to get over your ego and accept the advice that you are coming here for.
Message 52 of 63
myspambox111
in reply to: myspambox111

I read it immediately and I understand what it says but to implement understanding in an api like autocad is easier said than done.

You assume because I fail to understand a single functionality of an object that I'm altogether without knowlege of Autocad. Calling me ignorant 4 times in a row based on this assumption and that I did not take your advice is foolish to say the least. I prefer an example to better understand something, not just reading a chapter of a book over and over again.

If your idea of advice is making broadbrush assumptions, ignoring what the OP asked and stated in multiple posts, and following it up with insults, you can save your advice for someone else. I've experienced the boot camp method of teaching first hand, I don't need that crap in a programming forum.
Message 53 of 63
NathTay
in reply to: myspambox111

I have made no assumptions. You clearly proved yourself ignorant. You then showed complete arrogance by ignoring well meaning advice.



It is foolish expecting someone to write your code for you and then nitpicking it without understanding it.



Again you need to brush your ego to one side and look at things objectively.
Message 54 of 63

MyspamBox111,



Don't let immature goaders like NathTay get your goat. I've seen 14 yr old mentality like this before. He's just out there to cause trouble. Of the many posts he's placed very few have been recieved openly, so if his post is not useful to you, just ignore him. Personnally I agree with your point of view on comming here to seek a quick bit of advice, and have seen that the 'real' advice is hard to find. So as I learn things I'll be glad to help out.



Later,



jvj
Message 55 of 63
NathTay
in reply to: myspambox111

Do you disagree that the issues that he has come with here are because he does not have a basic understanding of how blocks work in AutoCAD?
Message 56 of 63
williams
in reply to: myspambox111

Is this a forum for asking and answering questions or a 3rd grade arguing match? It's hard to believe that someone with apparently soooo much knowledge (Tony) would actually degrade and get on people's cases for asking questions, no matter how simple. THAT'S what this forum is for! If you want to set up another web site that basically crams down people's throats how unbelievably awesome you are then go ahead but leave this one alone. Alot of people ask me the simplest questions about AutoCAD and I'm proud to answer every one of them with a smile on my face because I know that they know, I'm the "go to guy". Instead of being a "go to guy", the resident "guru" here seems to push more people away than actually answering questions. A valid answer to a seemingly simple question should never be "Go get this book, look at this web site, or how 'bout learning a little something before you ask stupid questions". It should be answered in a few simple replys by NICE people and then the "Thank yous" can commence. BTW, I'm still yet to know the answer to the simple question posted here. The bottom line here was to kiss someone's b^tt and apoligize for doing nothing wrong. Quite frankly I thought all the "Where's your book" replys were spot on. If all these people are giving such bad advice it's probably because of forums like this where the simple answers are dodged with code snipets that do nothing but show off and say "hey look at what I can do with all these error handlers and safeguards!". Your quick answer to this might be... I'm not here to write code for you.. but that's just it... you are! If you can take the time to put up 200 replys arguing about how you're the best and everyone else sucks then at least take 5 minutes and give us the code first.

... or next time just say "I'm the greatest and I don't have time for your stupid question" and then let someone else do the helping.
Message 57 of 63
Anonymous
in reply to: myspambox111

You can provide free .tutoring on .NET programming, to people who come here
looking for that, if you're able and willing to do that.

If you don't want to do that, then stop bashing others because they are not
stupid enough to be suckered into providing free tutoring, as if you or
someone else were paying us for it.

This is not a free, online classroom for training on basic programming
topics. This is not the 'C# newsgroup' or a newsgroup for learning the very
basics of programming in any language, or the generic aspects of using the
.NET framework.

If someone wants to learn the basics of C# or .NET, they should go to the
relevant Microsoft newsgroups and use the online resources that Microsoft
provides for beginners, and they can get all the help they want.

No, I'm not in the free tutoring business, and if you don't like that, I
don't have to tell you where you can go.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6268551@discussion.autodesk.com...
Is this a forum for asking and answering questions or a 3rd grade arguing
match? It's hard to believe that someone with apparently soooo much
knowledge (Tony) would actually degrade and get on people's cases for asking
questions, no matter how simple. THAT'S what this forum is for! If you want
to set up another web site that basically crams down people's throats how
unbelievably awesome you are then go ahead but leave this one alone. Alot of
people ask me the simplest questions about AutoCAD and I'm proud to answer
every one of them with a smile on my face because I know that they know, I'm
the "go to guy". Instead of being a "go to guy", the resident "guru" here
seems to push more people away than actually answering questions. A valid
answer to a seemingly simple question should never be "Go get this book,
look at this web site, or how 'bout learning a little something before you
ask stupid questions". It should be answered in a few simple replys by NICE
people and then the "Thank yous" can commence. BTW, I'm still yet to know
the answer to the simple question posted here. The bottom line here was to
kiss someone's b^tt and apoligize for doing nothing wrong. Quite frankly I
thought all the "Where's your book" replys were spot on. If all these people
are giving such bad advice it's probably because of forums like this where
the simple answers are dodged with code snipets that do nothing but show off
and say "hey look at what I can do with all these error handlers and
safeguards!". Your quick answer to this might be... I'm not here to write
code for you.. but that's just it... you are! If you can take the time to
put up 200 replys arguing about how you're the best and everyone else sucks
then at least take 5 minutes and give us the code first.

... or next time just say "I'm the greatest and I don't have time for your
stupid question" and then let someone else do the helping.
Message 58 of 63
SRWCadder
in reply to: myspambox111

You certainly have the power and the option to choose what posts to reply to and your first post here was to simply suck us all in with your opinion on how bad someone elses code skills are from a book. If you don't want to help with even a simple question because it's a waste of time, why have you spent so much time hammering on the "not so smart"? Building applications in .net for AutoCAD requires more knowledge of how to tap into AutoCAD than the .net language. That's all we're asking for. If we (the stupid) happen to follow up with a simple question of how and why, don't shut us down and go off on some rant about how we should learn the language before posting questions or giving answers. With ALL the bad code out there, we take it for gospel because don't know any better if it actually happens to work, then we pass it along to others who ask the same question down the road. That's all that has happened here.

I can't wait for the next kid to ask me how to read and write so, like you, I can also tell him to "go to h#ll" and go find some books.
Nice... real nice.
Message 59 of 63
Anonymous
in reply to: myspambox111

I got where I am by being hammered on. Hammering on someone is may way of
challenging them to better themselves, and yes, it can be humiliating, but
not nearly as humiliating as it is motivating.

Does that make sense to you, or are you one of those who believes that
politeness is, above all other things, going to get you somewhere?

Politeness is a trait that every swindler and scam/con artist I've had the
pleasure of meeting has in common. In fact, one can say that it is the
primary tool of their trade.

If you take a look at the abysmal state of the country you live in, and ask
yourself why students in this country are abysmal failures in the areas that
matter (math and science), it has a lot to do with the same 'mentality of
politeness' that motivated you to comment here.

Take a hike.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6268973@discussion.autodesk.com...
You certainly have the power and the option to choose what posts to reply to
and your first post here was to simply suck us all in with your opinion on
how bad someone elses code skills are from a book. If you don't want to help
with even a simple question because it's a waste of time, why have you spent
so much time hammering on the "not so smart"? Building applications in .net
for AutoCAD requires more knowledge of how to tap into AutoCAD than the .net
language. That's all we're asking for. If we (the stupid) happen to follow
up with a simple question of how and why, don't shut us down and go off on
some rant about how we should learn the language before posting questions or
giving answers. With ALL the bad code out there, we take it for gospel
because don't know any better if it actually happens to work, then we pass
it along to others who ask the same question down the road. That's all that
has happened here.

I can't wait for the next kid to ask me how to read and write so, like you,
I can also tell him to "go to h#ll" and go find some books.
Nice... real nice.
Message 60 of 63
HEnnulat
in reply to: myspambox111

Tony,

What surprised me was your well reasoned (and calm) reply after all the slams you and others made. I had to smile 🙂

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost