I'm trying to write a basic extension to toggle point cloud visibility in the active vew as shown below. But I receive this eror...
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit import DB
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
view = doc.ActiveView
t = DB.Transaction(doc)
t.Start('Set Pt Cloud Color Mode')
view.ArePointCloudsHidden(False, True)
t.Commit()
Solved! Go to Solution.
Solved by franciscopossetto. Go to Solution.
Hey,
It seems like you are trying to use the property ArePointCloudsHidden as a method. If you want to switch the visibility of the point cloud, you could use the method HideCategoryTemporary.
https://www.revitapidocs.com/2022/26684015-0635-cb13-d5a9-f6a6f9b0780a.htm
I have developed this tool before, it is on C# but you can see the code.
https://github.com/franpossetto/Nina/blob/master/Nina/Lib/PointCloud.cs
or download it.
https://github.com/franpossetto/Nina/releases
I hope it helps,
Kind regards.
Thank you for the precise answer and the pointer to your nice and useful collection of tools!
P.S. Best regards to Nina as well.
Thank you @jeremy_tammik! I appreciate it.
I'll send Nina your regards!
My solution for hiding and showing point clouds in active view (in pyRevit script file):
from Autodesk.Revit.DB import *
doc = __revit__.ActiveUIDocument.Document
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PointClouds).WhereElementIsNotElementType()
elements = collector.ToElements()
pointclouds = collector.ToElementIds()
visible = False
for element in elements:
if not element.IsHidden(doc.ActiveView):
visible = True
break
if visible:
t = Transaction(doc,"Hide pointclouds")
t.Start()
doc.ActiveView.HideElements(pointclouds)
t.Commit()
else:
t = Transaction(doc,"Unhide pointclouds")
t.Start()
doc.ActiveView.UnhideElements(pointclouds)
t.Commit()
Can't find what you're looking for? Ask the community or share your knowledge.