Author Topic: Pointcloud Stylization  (Read 2205 times)

0 Members and 1 Guest are viewing this topic.

Noie1234

  • Mosquito
  • Posts: 4
Pointcloud Stylization
« on: December 01, 2023, 12:18:18 AM »
Hi All

I am trying to write a lisp to set the stylization and ColorScheme of a point cloud without having to open a dialogue box. 

Currently I can change the stylization to what I want but the ColorScheme errors with:

; error: lisp value has no coercion to VARIANT with this type:  "Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#"

Also I cannot figure out how to set the range for each style. (eg min max heights to colour by elevation)

Code: [Select]
(defun c:PCel ()
(setq obj (vlax-ename->vla-object (car (entsel "\nSelect Point Cloud :\n"))))
              (vla-put-Stylization obj 4)
              (vla-put-ColorScheme obj "Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#")
 )

A vlax-dump-object gives:

Command: DUMP
Select Point Cloud :
; IAcadPointCloudEx2: AutoCAD Point Cloud Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff74a81b910>
;   ColorScheme = "Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#"
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000013557926cd8>
;   EntityTransparency = "6"
;   Geolocate = 0
;   Handle (RO) = "285"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000001357ac1c758>
;   InsertionPoint = (0.0 0.0 0.0)
;   Layer = "PCgnd"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Locked = 0
;   Material = "ByLayer"
;   Name = "240531WaterworksGND"
;   ObjectID (RO) = 42
;   ObjectName (RO) = "AcDbPointCloudEx"
;   OwnerID (RO) = 43
;   Path (RO) = ".\\Recap\\240531WaterworksGND.rcp"
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   scale = 1.0
;   Segmentation (RO) = "No"
;   ShowCropped = -1
;   Stylization = 4
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000001357ac1b0d0>
;   Unit (RO) = "Meters"
;   UnitFactor (RO) = 1.0
;   Visible = -1

But nothing seems to change in that list when I change the min max elevations by the dialogue box.

Any direction of where to go from here would be appreciated.

Thanks
Matt

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #1 on: December 01, 2023, 05:00:31 AM »
Hi Matt,
welcome to the swamp!

I looked at the docs, and well they donít say much. Hoping someone familiar with point cloud shows up..
By any chance, do you have a sample drawing to investigate on?

PKENEWELL

  • Bull Frog
  • Posts: 308
Re: Pointcloud Stylization
« Reply #2 on: December 01, 2023, 12:17:06 PM »
; error: lisp value has no coercion to VARIANT with this type:  "Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#"

Hi Matt,

Just as seen siad. I lack knowledge of the point cloud API. However. The error indicates that the property needs a VARIANT as the argument. Could it be as easy as this?
Code - Auto/Visual Lisp: [Select]
  1. (vla-put-ColorScheme obj (vlax-make-variant "Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#" vlax-vbString))
  2.  

P.S. Looking more into the documentation. I believe the Color Scheme information is stored separately from the Point Cloud itself. Similar to a Dimension Style or Visual Style. I don't know if that has an exposed API or if it is just stored in a dictionary in the drawing, or in the registry if it is not drawing based. It will take some more research to figure out.

P.P.S. It appears Point Cloud Styles and Color Schemes ARE stored in a Dictionary. While it may not solve your problem, see this link for insight:
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/point-cloud-elevation-color-scheme-problem/td-p/8878975
« Last Edit: December 01, 2023, 01:01:53 PM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Noie1234

  • Mosquito
  • Posts: 4
Re: Pointcloud Stylization
« Reply #3 on: December 02, 2023, 09:36:06 PM »
Hi Guys

Thanks for the replies. 

I've tried to attach a dwg which has the rcs attached already. Note this rcs does not have any valid scan colours or classifications on it.

No luck with the make variant code unfortunatly, it returns ; error: lisp value has no coercion to VARIANT with this type:  #<variant 8 Spectrum#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#>.

Looks like I've got some learning to do on working with dictionaries. I'll report back if I make some progress

Cheers

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #4 on: December 02, 2023, 10:49:11 PM »
it wants an int  :-o

Code - C++: [Select]
  1.  [ClassInterfaceAttribute(0)]
  2.     [ComSourceInterfaces("AutoCAD.IAcadObjectEvents")]
  3.     [Guid("F3448242-A117-4E8E-97A4-646EB9CC2565")]
  4.     public class AcadPointCloudExClass : IAcadPointCloudEx2, AcadPointCloudEx, IAcadObjectEvents_Event
  5.     {
  6.         ...
  7.         [DispId(7)]
  8.         public virtual string get_ColorScheme();
  9.         [DispId(7)]
  10.         public virtual void set_ColorScheme(int val);//-------------------------------------
  11.         ...
  12.     }
  13.  
« Last Edit: December 02, 2023, 10:53:44 PM by It's Alive! »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #5 on: December 02, 2023, 10:58:18 PM »
the string is the array
#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#

Code - Python: [Select]
  1. def PyRxCmd_doit3():
  2.     try:
  3.         axApp = Ax.getApp()
  4.         entres = axApp.ActiveDocument.Utility.GetEntity("\nPick it:")
  5.         pc : Ax.IAcadPointCloudEx = entres[0]
  6.        
  7.         #Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#
  8.    
  9.         pc.Stylization = 4
  10.         pc.ColorScheme = 2 #= Grayscale
  11.        
  12.         print(pc.ColorScheme)
  13.  
  14.     except Exception as err:
  15.         traceback.print_exception(err)
  16.        
  17.  

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #6 on: December 02, 2023, 11:00:04 PM »
so the current scheme is before the #
Greens#Blues/Earth/Grayscale/Greens/Hydro/Reds/Spectrum/#

Noie1234

  • Mosquito
  • Posts: 4
Re: Pointcloud Stylization
« Reply #7 on: December 03, 2023, 04:59:45 AM »
Setting to an integer works perfectly cheers. 

You've lost me with how you found that. Is that c++ code?

Looks like I still need to read up on dictionaries to be able to set the min max heights etc.

Thanks again.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #8 on: December 03, 2023, 05:18:44 AM »
I used a C# .NET project and imported the ActiveX interface, that gave me the function signatures in visual studioís object browser
then I tested it with Python

while wrapping PointCloudEx in my python project, I noticed functions

Code - Python: [Select]
  1. setMinMaxElevation(min, max);
  2. setMinMaxIntensity(min, max);
  3.  

So they would also be in .net

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8586
  • AKA Daniel
Re: Pointcloud Stylization
« Reply #9 on: December 03, 2023, 06:16:11 AM »
Yeah, the min max are in the dictionary

Code - Python: [Select]
  1. def PyRxCmd_doit2():
  2.     try:
  3.        
  4.         es = Ed.Editor.entSel("\nSelect a pcloud: ",Db.PointCloudEx.desc())
  5.         if es[0] != Ed.PromptStatus.eOk:
  6.             return
  7.      
  8.         pc = Db.PointCloudEx(es[1], Db.OpenMode.kForWrite)
  9.         pc.setMinMaxElevation(-3000,1)
  10.         pc.setStylizationType(Db.PointCloudStylizationType.kHeightRamp)
  11.         pc.setCurrentColorScheme("Earth")
  12.         pc.setElevationOutOfRangeBehavior(Db.PointCloudDispOptionOutOfRange.kHidePoints)
  13.         pc.setElevationApplyToFixedRange(True)
  14.        
  15.     except Exception as err:
  16.         traceback.print_exception(err)
  17.    
  18.  


Noie1234

  • Mosquito
  • Posts: 4
Re: Pointcloud Stylization
« Reply #10 on: December 04, 2023, 05:02:27 AM »
That's perfect, thanks again for your help.

PKENEWELL

  • Bull Frog
  • Posts: 308
Re: Pointcloud Stylization
« Reply #11 on: December 04, 2023, 10:55:11 AM »
Great to hear you guys got it worked out!
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt