Hide and unhide point cloud

I need to create the button and need to add in the shortcut keys.

then button is to hide and unhide the Linked point cloud from the current view.

Any help appreciated.

Hi Vijay,

The pyRevit guides on notion will have all the information you need to create the extension and buttons: https://www.notion.so/Create-Your-First-Command-2509b43e28bd498fba937f5c1be7f485
This explains the anatomy of an extension folder; subfolders (buttons), bundles (UI sorting and command info stored in a yaml file) and scripts in detail.

Once the button is visible on your toolbar you will be able assign it as you would any other keyboard shortcut in Revit (shortcut KS).

I got it…I need code, here it’s mine . It’s working in dynamo but not in pyrevit
from pyrevit import script

  # Load the Python Standard  Libraries

    import clr
    clr.AddReference("RevitServices")
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager

    clr.AddReference("RevitAPI")
    import Autodesk
    from Autodesk.Revit.DB import *

    clr.AddReference("RevitNodes")
    import Revit
    clr.ImportExtensions(Revit.GeometryConversion)
    clr.ImportExtensions(Revit.Elements)

    clr.AddReference('ProtoGeometry')
    from Autodesk.DesignScript.Geometry import *


    # Current doc/app/ui
    doc = DocumentManager.Instance.CurrentDBDocument

    #Filtered element collector (all point clouds)
    pc = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PointClouds).ToElements()


    for i in pc:
        cat = i.Category
    if cat is not None:
        t = Transaction(doc,'hide cloud')
        t.Start()
        doc.ActiveView.HideCategoryTemporary(cat.Id)
        t.Commit()

image

Error

you are using library of dynamo revit , please use lib of pyrevit with document.

from pyrevit import script
#Import pyRevit form library
import clr
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI') 
from Autodesk.Revit.DB import * 
from Autodesk.Revit.DB import Category
from Autodesk.Revit.UI import * 
app = __revit__.Application
uidoc = __revit__.ActiveUIDocument
doc = uidoc.Document
logger = script.get_logger()
logger.set_quiet_mode()
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PointClouds).ToElements()
cat = None
for i in collector:
    cat = i.Category
if cat is not None:
    t = Transaction(doc,'hide cloud')
    t.Start()
    doc.ActiveView.HideCategoryTemporary(cat.Id)
    t.Commit()
1 Like

thank you @Chuongpqvn

I want to hide from the permanently with a key the unhide vice versa.

i mean want hide point cloud link from view with key and the unhide with the same key.

as in above image