Set link to halftone in view template Dynamo

Hello,

Is there any idea on how to set Revit link to halftone in view templates using dynamo.

Thanks!

I don’t know if this is possible to do in view templates using Dynamo, but you can override each of the link instances to halftone in the active view. See below:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FilteredElementCollector, OverrideGraphicSettings, RevitLinkInstance
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
view = doc.ActiveView
links = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
overrides = OverrideGraphicSettings()
overrides.SetHalftone(True)

TransactionManager.Instance.EnsureInTransaction(doc)
for link in links:
	id = link.Id
	view.SetElementOverrides(id, overrides)

TransactionManager.Instance.TransactionTaskDone()

As far as I am aware, it isn’t possible to access the data in the RevitLinks tab of the Visibility/Graphics Overrides of a given view through the API (or Dynamo, for that matter). For now your only option is most likely what I have shown above.

2 Likes

Thanks!

This actually works on active view only… is there any way to make it work on the entire views in the project? I guess we need to exclude drafting views and legends.

Thanks for your help!

I’m not sure of the exact view types you’re trying to override, but here’s an example overriding all 3D views in the document:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FilteredElementCollector, OverrideGraphicSettings, RevitLinkInstance, View3D
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
links = FilteredElementCollector(doc).OfClass(RevitLinkInstance)
views = FilteredElementCollector(doc).OfClass(View3D)

overrides = OverrideGraphicSettings()
overrides.SetHalftone(True)

TransactionManager.Instance.EnsureInTransaction(doc)
for view in views:
	for link in links:
		id = link.Id
		view.SetElementOverrides(id, overrides)

TransactionManager.Instance.TransactionTaskDone()

Clockwork has a Document.Views node which you may be able to use to get and filter the proper views.

I want to override plan views in the projects.

dont want 3d, section, drafting, legend… etc.

Thanks,

I’ve made a workflow but it didn’t work to me.

I would appreciate any kind of help
Thanks

Two things:

  1. You are telling the node to override all Views to halftone (not a category of modeled elements, e.g. Link Instances)
  2. Elements do not exist in view templates themselves, as the view template has to be applied to a view for it to have any effect.

So, if you instead put a list of actual views (not view templates) into the “view” input and change the category to Link Instances (I don’t remember the exact category name off hand) then you will be able override their appearance to halftone. This won’t have an effect on any of your view templates, but it will achieve the same effect.

It did work to my after several trials and error… for some reason I still have the error but I dont care!! thank you for your help.

3 Likes