Author Topic: Need help about increase attribute number in the block!  (Read 2365 times)

0 Members and 1 Guest are viewing this topic.

Sieu khung khiep

  • Mosquito
  • Posts: 15
Need help about increase attribute number in the block!
« on: November 22, 2019, 12:27:03 AM »
Hello, I am reading from this post: https://www.keanw.com/2008/05/an-automatic-nu.html ,and
currently I don't know the purpose of this piece of code now(it is at the bottom of the post): I understand that it will handle the constant properties but it seems that after removing this code the project still works,here is code:
Code - C#: [Select]
  1. [code] foreach (AttributeDefinition ad2 in other){
  2.         AttributeReference ar2 =new AttributeReference();
  3.         ar2.SetAttributeFromBlock(ad2, br.BlockTransform);
  4.         ar2.Position =ad2.Position.TransformBy(br.BlockTransform);
  5.         ar2.Tag = ad2.Tag;
  6.         ar2.TextString = ad2.TextString;
  7.         ar2.AdjustAlignment(db);
  8.         br.AttributeCollection.AppendAttribute(ar2);
  9.         tr.AddNewlyCreatedDBObject(ar2, true);
  10.       }
[/code]
I think it was solved by the above command:
Code - C#: [Select]
  1. [code]ar.SetAttributeFromBlock (ad, br.BlockTransform);
[/code]
Not sure, could someone explain help me?
Thanks very much.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Need help about increase attribute number in the block!
« Reply #1 on: November 22, 2019, 09:44:33 AM »
It looks like that part was creating attribute references for "other" attributes if the block contained any other attributes besides the "NUMBER" attribute.

I have not tested but you should see a difference by testing with drawing attached since I added two attributes("OTHER" & "OTHER2") to bubble block definition.
You should see two extra attributes using snippet below, but after removing snippet below it should just add the number attribute.



Sieu khung khiep

  • Mosquito
  • Posts: 15
Re: Need help about increase attribute number in the block!
« Reply #2 on: November 23, 2019, 02:58:13 AM »
Hi Jeff H
Thanks for the reply. I have reviewed the code carefully, and from your comments I have figured out how it works. It also helps me answer a question I'm preparing to post;) Great!
Have a nice weekend! :-D

Sieu khung khiep

  • Mosquito
  • Posts: 15
Re: Need help about increase attribute number in the block!
« Reply #3 on: November 23, 2019, 04:55:09 AM »
Hi Jeff H, I have another question and I posted here. https://www.theswamp.org/index.php?topic=55593.0
I think you can help me, thanks a lot.