Changing Dimension Prefix (Dynamo/Python)


#1

Hi people,

i’ve been searching for a way of, some how, change a dimension prefix or sufix. There’s a topic that talk a bit about it in http://dynamobim.org/forums/topic/get-dimensions-value-replace-with-text/ and there’s another one that talk about override dimension values too http://dynamobim.org/forums/topic/override-dimension-values/ . Both used python code to edit a single dimension value only.

My question is if there’s a way to change all dimensions prefixs, something like collecting all elements by family type and change the prefix to all that instances.

Cheers!


Determine if dimension is arc length
#2

Here’s a good post from Jeremy: http://thebuildingcoder.typepad.com/blog/2014/09/revit-2015-r2-ur4-and-dimension-prefix-suffix.html


#3

Thank you for your awnser Konrad! I forgot to mention, that I’m totally ignorant in coding. As I understand in the link you posted, he wanted to collect dimensions suffix/prefix, not to change it for a defined text. Am I wrong?

I’m sending in attachmet the codes created by Jeremy (from the first link i’ve mentioned) that’s running but nothing seems to happenGet-dimension-Value1 (1).dyn (2.0 KB)
. The other one, created by Ben Osborn (in the second link i’ve mentioned) that is working fine but just for one single dimension.dim-texts-change.dyn (2.4 KB)

Is it possible to work to all elements of a dimension type?


#4

Hi Joaquim,

Are you looking to override Dimension Text Values?


#5

Hi Kulkul,

Yes, something like prefix or sufix. Your script seems very close of what i’m searching. How did you did it?


#6

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

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

for i in UnwrapElement(IN[0]) : i.Prefix = IN[1]

TransactionManager.Instance.TransactionTaskDone()

OUT = IN[0]

Note: This doesn’t work if any of the dimensions have multiple segments.


#7

@Joaquim_Danado currently away from my PC. Will get back tomorrow.


#8

Thank you Kulkul. Your help will be welcome!


#9

Thank you for your reply Vikram!
I’m trying to find a way to change dimensions, even with multiple segments


#10

@Joaquim_Danado This should do the needful

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

    doc = DocumentManager.Instance.CurrentDBDocument
    TransactionManager.Instance.EnsureInTransaction(doc)

    for i in UnwrapElement(IN[0]):
    	if i.Value>=0: i.Prefix=IN[1]
    	else:
    		for j in i.Segments: j.Prefix = IN[1]

    TransactionManager.Instance.TransactionTaskDone()

    OUT =IN[0]

Add Dimension Prefix for all similar type in the Project
#11

Hi Vikram, thank you for your help!
It works pretty well. I tried it not for selected elements but catching all elements and it works fine.

Thank you a lot :slight_smile:


#12

We also discussed this in this post Override Dimension Values


#13

Hi Vikram i tried running your code block but it gives me syntax errors.

thanks,
S


#14

Hi @Kulkul !

I’m a new with Dynamo and your script in that gif is exactly what I have been looking for, how do I do it? :slight_smile: