Distance between to dimension lines? change

Hello @all,
i was thinking about if its possible to change the distance of a set of dimension lines.
I have to translate a bunch of drawings from a certain kind of detail to another and there are a lot of dimension lines not readable when i change the scale.

so for example here…

please note, that there are lots of random placed dimensions (horizontal and vertical) - not all of them are `grouped´as in the picture…

kind regards
kev :slight_smile:

i’m not sure i understand what you’re trying to accomplish. It sort of sounds like you just need to change the type of your Dimensions? You may not even need dynamo to do this.

If you want to use dynamo to change the type of your dimensions, the pseudocode would look something like this

// collect all dimension types
// filter the ones you want to target
// select the type you want to change to
// set the type parameter of the target instances

Hey,

I think you are looking to move the dimension, which you can do like this?

Hope that helps,

Mark

import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#The inputs to this node will be stored as a list in the IN variable.
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
obj = UnwrapElement(IN[0])

try:
    # Check if obj is iterable
    len(obj)
    dims = obj
except TypeError:  # If obj is not iterable (i.e., not a list)
    dims = [obj]

TransactionManager.Instance.EnsureInTransaction(doc)

[ElementTransformUtils.MoveElement(doc, dim.Id, XYZ(IN[1], IN[2], IN[3])) for dim in dims]

TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = dim


for example here…
i have a drawing in 1:50 - i need to reduce the level of detail in the dimension in general - so for the dimensions outside of the building i need to increase the distance between the lines so i can read the bigger numbers and inside of the building i need to find a way to reduce the dimensions to just a few necessary.

does someone has a smart opinion on this? :slight_smile:

I guess you’re not going to be able to get a perfect solution, so it’s about making a rule and moving those dimensions which meet it…

You could count how many witness lines a dimension has? If it has 2 it is the outer one? you could do 2 rays perpendicular to the dimension line and if it intersects, move in the opposite direction by double the distance?

It’s a lot of coding, so you would need a lot of drawings to justify…

Hope that helps,

Mark

An example using vectors operations


import clr
import sys
import System
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

  
def dim_to_BoundLine(dim):
    curvDim = dim.Curve
    direction = curvDim.Direction
    start = dim.Origin.Subtract(direction.Multiply( dim.Value/2))			
    end = dim.Origin.Subtract(direction.Multiply(-1 * dim.Value/2 ))		
    #
    return DB.Line.CreateBound(start, end)
    
    
def get_distance_beetween(dimA, dimB):
    lineA = dim_to_BoundLine(dimA)
    lineB = dim_to_BoundLine(dimB)
    pta = lineA.GetEndPoint(0)
    ptb = lineB.GetEndPoint(0)
    normalA = lineA.Direction.CrossProduct(XYZ.BasisZ)
    vector_lines = ptb.Subtract(pta)
    distance = vector_lines.DotProduct(normalA.Normalize())
    return f"{abs(distance) * 304.8:0.1f} mm"

#Preparing input from dynamo to revit
dimA = UnwrapElement(IN[0])
dimB = UnwrapElement(IN[1])


OUT = get_distance_beetween(dimA, dimB)

thats pretty cool :slight_smile: to retrieve the distance between the dimensions…
but is it possible to set the distance to a certain value?

Hi,

yes, need to move the dimension with a vector see the @Mark.Ackerley 's example

yes i can see that @Mark.Ackerley example is working for all selected elements at once.
so i can move all dimensions together by a specific value. but this is not what i want in this case - i need to set the distance between each dimension to a specific value.
and unfortunately i cant give the python input a list :confused:

Hi @kevin.scholtyssekM76

your request is not simple, but here’s an example of the steps to follow

  • group parallel and nearby dimensions using the code given above
  • for each group, sort the dimensions by value
  • for each group,
    • for each line in group
      • calculate the distance from the first dimension in the group,
      • calculate the difference from its current position,
      • calculate the placement vector,
      • move the dimension with this vector (example)
1 Like

When it comes to the interior strings, it may be more complicated than it’s worth. You could move horizontal strings so they clear other horizontal strings, but end up with those interfering or overlapping vertical strings. At that point you’re pretty much back to manually moving the dimensions and/or dim text. You may can get something nice for simple projects, but doubt very seriously that you can account for all conditions, especially with your example clips.

Just my one cent worth of input.


first of all thanks to anybody for giving me this input :slight_smile:

so i grouped the dimensions after vertical and horizontal, then after the distance. So i have groups of moveable elements - regarding to @c.poupin
so for now i took the centerpoint of each dimension line and calculated the distance between one point to all other points of the grouped dimensions. then make a vector, scale it and move the elements - and somehow it works yey :slight_smile:
sadly i cannot set the distance between the lines to a certain value but maybe its not necessary for this task :slight_smile: