Boortsneggor Posted December 27, 2011 Posted December 27, 2011 Hi there, I´m developing a little interface for AUTCOCAD at the moment. I use Visual Studio 2010 and ObjectARX 2012 with C#. The interface should be able to edit specific blockReferences and their attributes. I´ve got two special kinds of blocks which I want to edit. Now I´ve implemented a command to move the position of one kind of the block references`attributes. For one of my two blocks this command works very well. For the other ones I cannot set a new position of the attribute references. And I don´t know why! I´ve compared several properties of the attributes but they are the same for both kind of blocks. The "lockposition" for example is "false" for both. Which property of the attribute references, block references or block should I set to change the position of the attribute references. Curiously to change the height or width of the text attributes makes no problems for both kind of blocks. So what could it be?? Or is there a simple way to set all properties of one block also to another one?? Thanks for help!!! greets robert Quote
fixo Posted December 27, 2011 Posted December 27, 2011 See these methods, just an idea sorry attRef.AdjustAlignment(db) blockref.RecordGraphicsModified(True) Quote
Boortsneggor Posted January 1, 2012 Author Posted January 1, 2012 Hello fixo, first of all, happy new year! Thanks for your answer. Unfortunately after setting the properties you mentioned the positions still remain the same. Do you have another ideas which can be the reason for this?? greets robert Quote
fixo Posted January 1, 2012 Posted January 1, 2012 Thanks Robert, Happy New Year too Unfortunatelly I can't 2010 release on my machine Just an idea, sorry, perhaps in the block table record this attribute properties: Lock position was set to true? Best wishes, Oleg Quote
Boortsneggor Posted January 4, 2012 Author Posted January 4, 2012 Hallo Oleg, I came through with small steps. I've find out, that it works, when I sync the BlockReferences with the origin block. Now I`ve the problem, that the visible Attributes also get all the Textproperties like Textheight, width and so on... of the origin Block. But the Textproperties of the visible Attributes of every BlockReference need to remain the same independent from the origin Block. Do you have an idea to realize that?? greets robert Quote
fixo Posted January 4, 2012 Posted January 4, 2012 Hi Robert, I could not generate the same issue on my machine I've used this simple code written years ago: public void ApplyAttributes(Database db, Transaction tr, BlockReference bref) { BlockTableRecord btrec = tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord; if (btrec.HasAttributeDefinitions) { Autodesk.AutoCAD.DatabaseServices.AttributeCollection atcoll = bref.AttributeCollection; foreach (ObjectId subid in btrec) { Entity ent = (Entity)subid.GetObject(OpenMode.ForRead); AttributeDefinition attDef = ent as AttributeDefinition; if (attDef != null) { AttributeReference attRef = new AttributeReference(); attRef.SetDatabaseDefaults();// optional or wrong maybe attRef.SetAttributeFromBlock(attDef, bref.BlockTransform); attRef.Position = attDef.Position.TransformBy(bref.BlockTransform); attRef.Tag = attDef.Tag; // you may want to swap other properties // between AttributeDefinition and AttributeReference here attRef.AdjustAlignment(db); atcoll.AppendAttribute(attRef); tr.AddNewlyCreatedDBObject(attRef, true); } } } } Try it too, perhaps it will be working for you, who knows? Or stay arriving of the heavy artillery Quote
Boortsneggor Posted January 5, 2012 Author Posted January 5, 2012 Hi Oleg, could you please explain your code a little bit. When I integrate the method I `ve got the little problem, that all blockReferences has their Attributes twice times. So I have to delete the old ones but store the values to set them to the new ones. But as I say on parts I don´t know exactly what your method did. Thanks for help! greets robert Quote
Boortsneggor Posted January 6, 2012 Author Posted January 6, 2012 Hi Oleg, it´s me again and I´ve solved the problem. The difference between the blocks were the alignment of the text attributes. If they have the default-LEFT-alingment you can simply use the "Position" property to move them. If they have other alignment in my case right, you have to set the "AlingmentPoint" property of the attribute references. So now my method works fine for all blocks and I´m very happy! Again thanks for your help and have a good time! greets robert Quote
fixo Posted January 6, 2012 Posted January 6, 2012 (edited) Hi Oleg, it´s me again and I´ve solved the problem. The difference between the blocks were the alignment of the text attributes. If they have the default-LEFT-alingment you can simply use the "Position" property to move them. If they have other alignment in my case right, you have to set the "AlingmentPoint" property of the attribute references. So now my method works fine for all blocks and I´m very happy! Again thanks for your help and have a good time! greets robert Hi Robert, Glad you've solved it by yorself Sorry for the belating, and yes, it's right way to set all properties for attribute references by its parent attribute definition one by one I was lazy to write them all separately Cheers, mate Oleg Edited January 6, 2012 by fixo spell check Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.