Hi guys!
I'm trying to reposition the base point of a Dynamic block after it is added to the database.
The block consists of 5 Attributes and 1 Mtext.
The expected behaviour is that Attributes and Mtext stay at the current position, and only the base point and custom grips are repositioned.
What I get is: Attributes stay but Mtext moves along with the base point and custom grips.
Any ideas why this is happeneing and how to resolve it?
I've attached the dwg file.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
How do I "synchronize" the attributes? What came to my mind is a workaround: change that Mtext to Attribute - that should hopefully make it stay in place.
If TransformBy displaces attributes - that is not what I want. I want all the blocks' content to stay in place, and only reposition its base point (I don't care if custom grips are repositioned or not).
Edit: Forgot to attach the block. It's now attached to my first post.
> Please show the code that you have written and that "don't work" for you.
In my opinion, It is not that the code isn't working, but I just want to know why is Mtext moving and Attribute is not moving.
> And perhaps explain how you'd "reposition its base point" without coding.
Actually, what I'm trying to do is to automate the process of manually repositioning the block reference as well as its attributes. Manual process involved repositioning the block using base point grip and a few custom grips. The manual steps were as follows:
1) Reposition the base point to location 1.
2) Reposition the attributes using custom grips to location 2.
Current automatic steps (with coding):
1) Reposition the base point to location 1 using `blkRef.Position = newPosition;`.
2) Reposition the attributes to location 2 by changing the values of dynamic block properties (e.g. `prop.Value = newValue;`).
The code works as expected albeit the Mtext is moved to location 1. This behaviour is explained by Mtext not being an attribute. So I was wandering if there is a way to keep Mtext from moving to location 1?
@OrmArTHe a écrit :
The code works as expected albeit the Mtext is moved to location 1. This behaviour is explained by Mtext not being an attribute. So I was wandering if there is a way to keep Mtext from moving to location 1?
No way. This is how AutoCAD blocks work. You cannot change an entity in a block reference (except attribute references), you have to change it in the block definition and doing so will affect all inserted references.
> You cannot change an entity in a block reference (except attribute references), you have to change it in the block definition and doing so will affect all inserted references.
What changes should I make in block definition so that Mtext doesn't move to location 1?
@OrmArTHe a écrit :
> You cannot change an entity in a block reference (except attribute references), you have to change it in the block definition and doing so will affect all inserted references.
What changes should I make to block definition so that Mtext doesn't move to location 1?
Sorry if I was not clear. What you're asking is not possible, any tranformation to a block reference will affect all the displayed entities (with an exception for attributes)
.
You should learn how AutoCAD blocks work (read this topic).
A block definition (BlockTableRecord) is a collection of entities. A block reference (BlockReference) does not contains entities, it is only a reference to the block definition with linear transformations (displacement, rotation and scaling) which affect all the displayed entities.
Only the attributes work a little differently. The block definition may contain attribute definitions (AttributeDefinition) and, as shown in another of your posts, when creating a new BlockReference by code, we have to explicitly create an attribute reference in the block reference AttributeCollection for each AttributeDefinition in the block definition. This is why, unlike other entities, attribute references may be slightly different from their attribute definition (position, text string).
In your case, you should replace the MText (/) with a Constant attribute definition and add it to the selection set of the action of Position1 parameter so that it can be displaced with other attributes.
Thank you for the detailed response.
> In your case, you should replace the MText (/) with a Constant attribute definition and add it to the selection set of the action of Position1 parameter so that it can be displaced with other attributes.
I did this and still, the issue persists... Block attached.
Can't find what you're looking for? Ask the community or share your knowledge.