How to reset dimension text position using C# AutoCAD

How to reset dimension text position using C# AutoCAD

kite15
Advocate Advocate
2,727 Views
4 Replies
Message 1 of 5

How to reset dimension text position using C# AutoCAD

kite15
Advocate
Advocate

Hi,

 

Can you please, guide how to perform the activity by using code of dimension quick pop-up function [attached snap] to make AutoCAD dimension text reset text position etc...

 

Thanks.

0 Likes
2,728 Views
4 Replies
Replies (4)
Message 2 of 5

ActivistInvestor
Mentor
Mentor

How about setting the Dimension's UsingDefaultTextPosition property to true?

 


@kite15 wrote:

Hi,

 

Can you please, guide how to perform the activity by using code of dimension quick pop-up function [attached snap] to make AutoCAD dimension text reset text position etc...

 

Thanks.


 

 

 

0 Likes
Message 3 of 5

kite15
Advocate
Advocate

Actually, the options which have shown in snap its available by picking hot grips of dimensions text. I am trying to automate the dimension text as required by user with multiple dimension selection. 

 

Since, by executing a code related command the user can reset the text position, and or center vertically and or above dim line

 

Already, tried with the usingDefaultTextPosition not successes [attached]. Smiley Sad

 

Thanks

0 Likes
Message 4 of 5

ActivistInvestor
Mentor
Mentor

In the future, I will not respond to posts that contain attached images of code.

 

Paste the code into the message using the Insert Code button.

 

You are creating a new Dimension and you are setting the TextPosition property of the new dimension.

 

Setting the TextPosition property is effectively setting the dimension text position to a non-default position.

 

To make the dimension text have the default position, do not set the TextPosition property.

 

 

 

0 Likes
Message 5 of 5

kite15
Advocate
Advocate

Sorry for that !

 

Here is the code: and attached the requirement !!

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    SelectionSet sel = SelRes.Value;
                    if (SelRes.Value.Count != 0)
                    {
                        BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                        BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                        foreach (ObjectId id in sel.GetObjectIds())
                        {
                            DBObject dbo = tr.GetObject(id, OpenMode.ForWrite, true) as DBObject;
                            RotatedDimension rtd = dbo as RotatedDimension;
                            rtd.UsingDefaultTextPosition = true;
                        }
                        tr.Commit();
                    }
                }