Any idea how can I create the Buttom for the below image.
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
// how can I change the colour mode?
i tried this but not working
Gui Talarico has you covered
this is what you are after
pt_cloud_settings = DB.PointClouds.PointCloudOverrideSettings()
pt_cloud_settings.ColorMode = DB.PointCloudColorMode.Normals
When you look for code samples, besides looking into pyrevit code + others extensions I suggest you look through this website instead ApiDocs.co and once you located a method for example, click on the top right symbol
yeah, the way the transaction is handled…
try this _ pyrevit modules style _
from pyrevit import revit, DB
uidoc = revit.uidoc
doc = revit.doc
view = uidoc.ActiveView
pt_overrides = view.GetPointCloudOverrides()
pts = DB.FilteredElementCollector(doc).OfClass(DB.PointCloudInstance).WhereElementIsNotElementType().ToElements()
pt_cloud_settings = DB.PointClouds.PointCloudOverrideSettings()
pt_cloud_settings.ColorMode = DB.PointCloudColorMode.Normals
with revit.Transaction('Point Cloud Color Mode change'):
for pt in pts:
pt_overrides.SetPointCloudOverrideSettings(pt.Id, pt_cloud_settings)
ERROR [pyrevit.revit.db.transaction] Error in Transaction Context. Rolling back changes. | <type 'exceptions.AttributeError'>:'PointCloudOverrides' object has no attribute 'SetPointCloudOverrideSettings'
IronPython Traceback:
Traceback (most recent call last):
File "C:\Program Files\pyRevit-Master\extensions\pc.extension\Multivista.tab\Points Display.panel\Normals.pushbutton\Normals_script.py", line 15, in <module>
AttributeError: 'PointCloudOverrides' object has no attribute 'SetPointCloudOverrideSettings'
Script Executor Traceback:
System.MissingMemberException: 'PointCloudOverrides' object has no attribute 'SetPointCloudOverrideSettings'
at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)
not tried, rough guess
SetPointCloudOverrideSettings → SetPointCloudScanOverrideSettings
from pyrevit import revit, DB
uidoc = revit.uidoc
doc = revit.doc
view = uidoc.ActiveView
pt_overrides = view.GetPointCloudOverrides()
pts = DB.FilteredElementCollector(doc).OfClass(DB.PointCloudInstance).WhereElementIsNotElementType().ToElements()
pt_cloud_settings = DB.PointClouds.PointCloudOverrideSettings()
pt_cloud_settings.ColorMode = DB.PointCloudColorMode.Normals
with revit.Transaction('Point Cloud Color Mode change'):
for pt in pts:
pt_overrides.SetPointCloudScanOverrideSettings(pt.Id, pt_cloud_settings)
1 Like
Works perfectly…
all the below works good and well.
|NoOverride|Show the actual colors|
|FixedColor|Show a single color|
|Elevation|Color by elevation|
|Intensity|Color by intensity (reflectivity)|
|Normals|Color by normal vectors|
This code is working well, but if I want to change Normals to NoOverride and then NoOverride to Normals and repeat it again so how could i do?
Thanks guys which is quite helpful @Jean-Marc @_Vijay