pyRevit extension to toggle point cloud visibility

pyRevit extension to toggle point cloud visibility

Anonymous
Not applicable
1,311 Views
5 Replies
Message 1 of 6

pyRevit extension to toggle point cloud visibility

Anonymous
Not applicable

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... 

TypeError: bool is not callable

 

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()

 

 

0 Likes
Accepted solutions (1)
1,312 Views
5 Replies
Replies (5)
Message 2 of 6

franciscopossetto
Advocate
Advocate
Accepted 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.

Github:
https://github.com/franpossetto
Message 3 of 6

jeremy_tammik
Alumni
Alumni

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.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 4 of 6

franciscopossetto
Advocate
Advocate

Thank you @jeremy_tammik! I appreciate it.
I'll send Nina your regards!

Github:
https://github.com/franpossetto
Message 5 of 6

Anonymous
Not applicable

Vey helpful, thankyou @franciscopossetto 

Message 6 of 6

juraj.kiaba
Observer
Observer

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()