View Title Location (Python)

Hello Dynamo Friends :slight_smile:

I´m looking for the API-Method to get and set the view title location. Google and RevitAPIdocs didn´t help me :confused:

Rhythm has this nodes:

image

But I want to do it in python.

Happy about any help :slight_smile:
Kind Regards!

Does this help?

1 Like

Hello Jan,
Can you tell me what the “label” is ? Is the label the title? Then the labeloffset is what i want?
Sorry I don´t know this english term.

I think you can use the def what John use in this code.

1 Like

Thank you Jan!

Setting the Viewtitle works, somehow:

As you can see in Dynamo background the outline and as a result the viewtitle is WAY off.

Will have to find out why and i have to find out how to GET the title location.

outlist=[]

# If Input is an item wrap it in a list:
if isinstance(IN[0],list):
	viewports = UnwrapElement(IN[0])
else:
	viewports = [UnwrapElement(IN[0])]
	
TransactionManager.Instance.EnsureInTransaction(doc)

for viewport in viewports:
	outline = viewport.GetBoxOutline()
	maxpoint = outline.MaximumPoint
	viewport.LabelOffset = maxpoint
	
TransactionManager.Instance.TransactionTaskDone()

OUT = viewports

Got it! New location is maxpoint-minpoint :slight_smile:

outlist=[]

# If Input is an item wrap it in a list:
if isinstance(IN[0],list):
	viewports = UnwrapElement(IN[0])
else:
	viewports = [UnwrapElement(IN[0])]
	
TransactionManager.Instance.EnsureInTransaction(doc)

for viewport in viewports:
	outline = viewport.GetBoxOutline()
	minpoint = outline.MinimumPoint
	maxpoint = outline.MaximumPoint
	viewport.LabelOffset = maxpoint-minpoint
	
TransactionManager.Instance.TransactionTaskDone()

OUT = viewports
1 Like

And here is the code for getting the viewtitle location:

outlist=[]

# If Input is an item wrap it in a list:
if isinstance(IN[0],list):
	viewports = UnwrapElement(IN[0])
else:
	viewports = [UnwrapElement(IN[0])]

for viewport in viewports:
	location =  viewport.LabelOffset
	outlist.append(location)

OUT = outlist

And this is for setting title to top left:

outlist=[]

# If Input is an item wrap it in a list:
if isinstance(IN[0],list):
	viewports = UnwrapElement(IN[0])
else:
	viewports = [UnwrapElement(IN[0])]
	
TransactionManager.Instance.EnsureInTransaction(doc)

for viewport in viewports:
	outline = viewport.GetBoxOutline()
	minpoint = outline.MinimumPoint
	maxpoint = outline.MaximumPoint
	topright = maxpoint-minpoint
	viewport.LabelOffset = XYZ(0,topright.Y,0)
	
TransactionManager.Instance.TransactionTaskDone()

OUT = viewports
1 Like