Automatic replacement of overlapping dimension text

Hi,
Im placing multiple dimensions automaticcaly and want to move texts that are overlapping. The node Dimension.SetTextLocation is no longer active in Dynamo 2.1. It seems still to be possible with the API code below. Before trying to reinvent the wheel I would like to ask the community if someone already has translated the below code in C# to Python. If not then Ill try myself.
Thanks.
Wouter Hilhorst

// Get the current text XYZ position
XYZ currentTextPosition = dimToModify.TextPosition;
// Calculate a new XYZ position by transforming the current text position
XYZ newTextPosition = Transform.CreateTranslation(new XYZ(0.0, 1.0, 0.0)).OfPoint(currentTextPosition);
// Set the new text position
dimToModify.TextPosition = newTextPosition;

1 Like

Solved the problem myself. :slightly_smiling_face:Attached is the script.
It works on Multi segmented dimension lines.
The repositioning of texts could be improved though
Also any other improvements are welcome!
thanks to everyone that helped!
Automatisch verplaatsen tekst maatlijn.dyn (11.4 KB)

3 Likes

Can you share how your .dyn should work?
Is it simply clicking the Dimension and then run it? If that is the case it doesn’t work (at least not for me).

You have to feed it with the dimension element. It works

Not for me :disappointed: (Revit 2021).

I took a look at it in revit 2021, it was some time ago that I wrote the script (2019).

The reason it doesnt work is probably because of the variable Var_Overl` in the script.

I set this variable on 0,7. If you copy the list Afstanden in OUT and run the script then you will see the distances between the texts (OUT = Afstanden).

If this distance is higher then the variable Var_Overl is doesn`t do anything.

So you can play around with the variable Var_Overl and make it higher than the lowest value in Afstanden. Then you will see that it does work.

The script is not perfect and needs to be developed further.

The challenge now is to develop the script further so it automatically adjusts the variable Var_Overl depending on the scale of the drawing.

Also the direction that the text goes needs to be made dependent on the scale.

Do you have an upgraded download for this script? I tried making those adjustments but it still isn’t working for me. I am using Revit 2023.

I basically need the script that this video shows of automatically cleaning up the dimension text.

Welcome to the forum. In the future, don’t piggy back off a post that has already been resolved. Please start a new post and reference the resolved post in your question. Piggy backing off a resolved post, will sometimes not yield the attention from others.

Try this
Fix Overlapping Dimension Text.dyn (39.3 KB)

EDIT: Be aware that this will only work when you have two dimension text that overlap each other as shown in the video. If you have more than two, it will not work correctly.

Sorry, ïts an old post, written in python 2.7. This is not suported anymore.
Good luck!

Verzonden vanaf Outlook voor Android

1 Like