TBC Macros and Extensions

 View Only
Expand all | Collapse all

Accessing graphically selected Point Cloud Regions

  • 1.  Accessing graphically selected Point Cloud Regions

    Posted 10-18-2023 09:04

    Hi,

    I´m trying to access to graphically selected point cloud regions, i.e. by box where I just selected a small portion of a point cloud region.

    I´ve tried many many options and checked which kind of object type is read if i.e:

    • Trimble.Vce.Data.Scanning.ExposedPointCloudRegion or PointCloudRegion or DefaultPointCloudRegion, etc
    • Then saw in the PointCloudRegion.py sample when using .Integration (however no way to find that ".Integration." as is in the object cataloghe) then the point cloud is a Trimble.Vce.Scanning.SDEIntegration.SdePointCloudRegionIntegration

    So I can have access to the ExposedPointCloudRegion and through .Integration read the points etc but all points of that region, which is very time consuming and I would simply like to iterate through a small part of the region and then check i.e. highest/lowest, etc, but out of i.e. 1.000 points instead of 500 Million. For example only out of the following red marked area:

    Is there a way to get only those points and iterate through them similar to the way we can do it for the whole points of a region? i.e.:

    --------------------------------------------------------------

    r = self.regions.SelectedEntity()  # Selected Point Cloud Region from the list
    if r:
         self.currentProject.TransactionManager.AddBeginMark(Client.CommandGranularity.Command, self.Caption)
         wv = self.currentProject[Project.FixedSerial.WorldView]
         with TransactMethodCall(self.currentProject.TransactionCollector) as failGuard:
              try:  
                  count = 0
                  for p in r.Integration.GetPoints():
                       if count == 0:
                             self.dZmin = p.Z
                             self.dZmax = p.Z
                      count += 1
                      self.checkDistance(p)
                      ... etc ...
    --------------------------------------------------------------
    Additionally, is there a way to select that subregion from the code? I mean i.e. picking a point on the point cloud and reading the points in a radius of Xm around that picked point only.
    Thanks.
    Regards,
    Fernando


    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------


  • 2.  RE: Accessing graphically selected Point Cloud Regions

    Posted 10-18-2023 09:27
    Edited by Ronny Schneider 10-18-2023 09:27

    Hello Fernando,

    at least the answer to your first question is shown in some of my macros. (SCR_AnalyzeCloudAlongLine, SCR_AutoConnectPoints)

    https://github.com/RonnySchneider/SCR_Macros_Public

    Was changed at some point (V5.40) and it took me a while to find out how it's done in newer versions.

    See my old post https://community.trimble.com/communities/community-homepage/digestviewer/viewthread?MessageKey=ade232ec-479a-4f5d-8fec-784306caea03&CommunityKey=8a262af4-a35e-4e9a-9dd3-191cc785899a#bmade232ec-479a-4f5d-8fec-784306caea03

                selectionSet = GlobalSelection.Items(self.currentProject)
    
                cloudpoints = []
                ProgressBar.TBC_ProgressBar.Title = "retrieve selected Cloud-Points"
                for o in selectionSet:
                    if isinstance(o, self.pointcloudType):
                        integration = o.Integration  # = SdePointCloudRegionIntegration
                        selectedid = integration.GetSelectedCloudId() # it seems the selected points form a sub-cloud
    
                        regiondb = integration.PointCloudDatabase # PointCloudDatabase
                        sdedb = regiondb.Integration # SdePointCloudDatabaseIntegration
                        cps = sdedb.GetPoints(selectedid)
                        #cloudpoints = sdedb.GetPointInfos(selectedid)
    
                        for p in cps:
                            cloudpoints.Add(p)



    ------------------------------
    Ronny Schneider
    ------------------------------



  • 3.  RE: Accessing graphically selected Point Cloud Regions

    Posted 10-18-2023 10:11

    Hi Rony,

    thanks a lot for your quick reply and infos ! Really appreciate it ;-)

    One of the things that I already tried was with the .GetSelectedCloudId() and realized that it´s the same for the whole region but changing even for the same selection but didn´t find the way to define a new subregion or similar passing this selected cloud id.

    I´ll have a look at your code and will try to integrate it.

    Thanks again.

    Regards,

    Fernando



    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 4.  RE: Accessing graphically selected Point Cloud Regions

    Posted 10-18-2023 11:08

    Hi again Ronny,

    I tried your recommendation and it works ! thanks so much again !

    I also downloaded your whole macros and I´m simply IMPRESSED ! WOW ! Amazing work, Ronny, congratulations for such achievements and I acknowledge how much work and research and trial and error it means, so in your language "Hut ab".

    Thanks also for sharing all the source code which will help many developers a lot, starting with me.

    Regards,

    Fernando



    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 5.  RE: Accessing graphically selected Point Cloud Regions

    Posted 10-18-2023 12:13

    Hi Fernando,

    was pure luck that I saw your post that quickly. Been killing some time waiting for dinner and my laundry to finish. I'm currently "shredding" the mountains in Switzerland with my bike.

    It seems you missed the Christmas Gift Post :-)

    Cheers

    Ronny



    ------------------------------
    Ronny Schneider
    ------------------------------