Change the color mode of a point could

Change the color mode of a point could

Anonymous
Not applicable
1,410 Views
6 Replies
Message 1 of 7

Change the color mode of a point could

Anonymous
Not applicable

Hello,

 

I'm creating a small plugin that allow me to change the color mode of a point cloud, so i found the Pointcloudcolorsetting Class, but i Don't know how to apply it to my PointCloudInstance.

 

            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document doc = uiDoc.Document;
            FilteredElementCollector collector1 = new FilteredElementCollector(doc);
            ICollection<Element> collection = collector1.OfClass(typeof(PointCloudInstance)).ToElements();
            PointCloudOverrides over = new PointCloudOverrides();
            PointCloudOverrideSettings setting = new PointCloudOverrideSettings();
            setting.ColorMode = PointCloudColorMode.Normals;
            Transaction trans = new Transaction(doc, "color mode");
            trans.Start();
            foreach (PointCloudInstance elem in collection)
            {
                over.SetPointCloudScanOverrideSettings(elem.Id, setting);  
            }
            trans.Commit();
            return Result.Succeeded;
 
I wrote this, but it is not wotrking.

 

if someone can help me.

0 Likes
1,411 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Please search this forum for `PointCloudColorSettings`.

 

One hit is this thread on hiding scans in PointCloudInstance:

 

https://forums.autodesk.com/t5/revit-api-forum/hidding-scans-in-pointcloudinstance/m-p/7342794

 

It includes some hints that might help you solve this:

 

  PointCloudOverrideSettings ptc_overridesettings_invisible 
    = new PointCloudOverrideSettings();

  ptc_overrides.SetPointCloudScanOverrideSettings( pti.Id, 
    ptc_overridesettings_invisible, scanname,doc );

 

I searched the online help for `SetPointCloudScanOverrideSettings`, and, from there, I found the `PointCloudOverrideSettings` class and its method `SetModeOverride` method taking an argument `PointCloudColorSettings` `colorSettings`:

 

https://www.revitapidocs.com/2020/d44adc12-6607-719a-98fd-fd8efbc85771.htm

 

I hope this helps solve your question. Please confirm.

 

Also, please always search for answers yourself before raising new questions.

 

You will be much faster and more effective in the long run if you don't have to wait for others to do the searching for you.

 

Thank you, and good luck!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hello,

Thanks you fo your help.

 

I'm sorry for asking "simple" questions but I ask Because I've already search and I Don't find a complete sample and I Don't know how to do. Even with your help I wrote this :

 

            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document doc = uiDoc.Document;
            FilteredElementCollector collector1 = new FilteredElementCollector(doc);
            ICollection<Element> collection = collector1.OfClass(typeof(PointCloudInstance)).ToElements();
            PointCloudOverrides over = new PointCloudOverrides();
            PointCloudOverrideSettings setting = new PointCloudOverrideSettings();
            PointCloudColorSettings colorSetting = new PointCloudColorSettings(new Color(0, 255, 0), new Color(255, 0, 0));
            ChooesColorMode formColor = new ChooesColorMode();
            formColor.ShowDialog();
               
            switch (formColor.index)
            {
                case 0:
                    setting.ColorMode = PointCloudColorMode.NoOverride;
                    setting.SetModeOverride(PointCloudColorMode.NoOverride, colorSetting);
                    break;
                case 1:
                    setting.ColorMode = PointCloudColorMode.FixedColor;
                    setting.SetModeOverride(PointCloudColorMode.FixedColor, colorSetting);
                    break;
                case 2:
                    setting.ColorMode = PointCloudColorMode.Elevation;
                    setting.SetModeOverride(PointCloudColorMode.Elevation, colorSetting);
                    break;
                case 3:
                    setting.ColorMode = PointCloudColorMode.Intensity;
                    setting.SetModeOverride(PointCloudColorMode.Intensity, colorSetting);
                    break;
                case 4:
                    setting.ColorMode = PointCloudColorMode.Normals;
                    setting.SetModeOverride(PointCloudColorMode.Normals, colorSetting);
                    break;
            }
            Transaction trans = new Transaction(doc, "color mode");
            trans.Start();
            foreach (PointCloudInstance elem in collection)
            {
                IList<string> scanNames = elem.GetScans();
                foreach (string scanName in scanNames)
                    over.SetPointCloudScanOverrideSettings(elem.Id, setting, scanName, doc);
            }
            trans.Commit();
 
But I have the follwing error and I Don't understand : 
 
"Argument Out of Range Exception : The override settings are not valid."
 
But I Don't understand Because it indicates me that the error happend in the methode "SetPointCLoudScanOverrideSettings" with the argument "newSetting".
 
If you can help me with this error.
0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

So, apparently, you wish to change the settings for all scans at the same time.

 

Why don't you use the override that does just that, instead of using the override that modifies settings for a single scan only, and then calling it repeatedly for all scans?

 

Look at the two overrides provided:

 

https://www.revitapidocs.com/2020/7a5735d1-acd8-9011-eadb-966319cd24a6.htm

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 7

Anonymous
Not applicable

Your are right ! I didn't saw that method.

 

But the error Don't come from this, it's comming from the setting object and I Don't understand why.

0 Likes
Message 6 of 7

Anonymous
Not applicable

I changed the method in order to Apply the override to the hole point cloud, but anything happend. The color mode Don't change but i Don't understand why.

 

here is my code (the ChooseColorMode object is just a Windows from that i use to ask the user which mode he want Apply)  : 

 

            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document doc = uiDoc.Document;
            FilteredElementCollector collector1 = new FilteredElementCollector(doc);
            ICollection<Element> collection = collector1.OfClass(typeof(PointCloudInstance)).ToElements();
            PointCloudOverrides over = new PointCloudOverrides();
            PointCloudOverrideSettings setting = new PointCloudOverrideSettings();
            PointCloudColorSettings colorSetting = new PointCloudColorSettings(new Color(0, 255, 0), new Color(255, 0, 0));
            ChooesColorMode formColor = new ChooesColorMode();
            formColor.ShowDialog();
               
            switch (formColor.index)
            {
                case 0:
                    setting.ColorMode = PointCloudColorMode.NoOverride;
                    setting.SetModeOverride(PointCloudColorMode.NoOverride, colorSetting);
                    break;
                case 1:
                    setting.ColorMode = PointCloudColorMode.FixedColor;
                    setting.SetModeOverride(PointCloudColorMode.FixedColor, colorSetting);
                    break;
                case 2:
                    setting.ColorMode = PointCloudColorMode.Elevation;
                    setting.SetModeOverride(PointCloudColorMode.Elevation, colorSetting);
                    break;
                case 3:
                    setting.ColorMode = PointCloudColorMode.Intensity;
                    setting.SetModeOverride(PointCloudColorMode.Intensity, colorSetting);
                    break;
                case 4:
                    setting.ColorMode = PointCloudColorMode.Normals;
                    setting.SetModeOverride(PointCloudColorMode.Normals, colorSetting);
                    TaskDialog.Show("revit", "nomarles");
                    break;
            }
            Transaction trans = new Transaction(doc, "color mode");
            trans.Start();
            foreach (PointCloudInstance elem in collection)
            {
                over.SetPointCloudScanOverrideSettings(elem.Id, setting);
            }
            trans.Commit();
            return Result.Succeeded;
 
If someone has an idea about why it's not working
0 Likes
Message 7 of 7

dcdvn2022
Community Visitor
Community Visitor

My solution:
View pView = uidoc.ActiveView;

PointCloudOverrides over = pView.GetPointCloudOverrides();

over.SetPointCloudScanOverrideSettings(eId1, setting1);

...then it worked.

0 Likes