Changing Dimension Prefix (Dynamo/Python)

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!

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

1 Like

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?

Hi Joaquim,

Are you looking to override Dimension Text Values?

1 Like

Hi Kulkul,

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

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.

1 Like

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

Thank you Kulkul. Your help will be welcome!

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

1 Like

@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]
5 Likes

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:

1 Like

We also discussed this in this post Override Dimension Values

1 Like

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

thanks,
S

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:

Hi @Vikram_Subbaiah I have an error and I don’t understand. Can you help me?

Add List.Create after SelectModelElement node. Next time please start new thread.

Thank you so much @Kulkul it worked. One last question when I use the Select Model Elements I can’t select any instance. Do you know why?

Crossing window selection. Right?

Yes!

what i do wrong?