Changing TextNoteType - Python/Dynamo

Changing TextNoteType - Python/Dynamo

adri3362
Participant Participant
392 Views
1 Reply
Message 1 of 2

Changing TextNoteType - Python/Dynamo

adri3362
Participant
Participant

Hey guys!

 

I have started learning using Revit API in my scripts and I have hard time understanding how to use it in Python scripts. Could someone explain me how I can change this TextNoteType, please? It is 3.5 mm and I want to change it to the 2.0mm type. I have tried so many different ways, I found some solutions in C# but I don't know the C# syntax. 

adri3362_0-1699305445892.png

 

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitServices")
clr.AddReference('RevitAPI')

import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 
import System
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument

list = IN[0]

txt = UnwrapElement(list[0])
output = []

TransactionManager.Instance.EnsureInTransaction(doc)

x = (txt.TextNoteType)
output.append(x)

TransactionManager.Instance.TransactionTaskDone()






OUT = output

 

0 Likes
393 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni

Welcome to the Revit API! I hope you know some basic Revit principles manually through the UI; if not, the API can be rather baffling.

  

Don't worry about C# versus Python... the underlying IL is the same, and there are even tools that can translate from one language to another (e.g., C# and Python) by compiling to IL and then decompiling the result back to the other source language.

  

You can either define different text note types for the different sizes (standard approach, recommended), or modify the existing text note type to be the way you want it. However, that will affect all instances using it.  Both approaches are easy. You can use the TextNoteType property; it has a setter as well as a getter function:

  

  

Here is an example that modifies the existing type instead of changing the type to a different type:

  

  

It can give you some ideas, though.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes