TBC Macros and Extensions

 View Only

 Assistance with Applying CreateCadPoints to Uploaded Point Cloud in Macro

nayef gmail.com's profile image
nayef gmail.com posted 09-14-2024 05:43

I am currently working on a macro that involves uploading a point cloud and applying the CreateCadPoints method on a selected point cloud region. While developing this, I referred to the "Upload" method from the training macro 3, this is the region I am choosing and the result I am getting in the vs 2019:

Could you provide guidance on:

  1. How to select the point cloud after uploading?
  2. The correct way to implement the CreateCadPoints method on the selected point cloud?

this function:
in the pointcloud ribbon

Any advice, sample code, or documentation references would be greatly appreciated!

Thank you for your help!

Ronny Schneider's profile image
Ronny Schneider

Hi Nayef,

retrieving the 3D information from the selected points works as follows. You might have to adjust the indentations, this is just copied and pasted from different locations but should work.

The selected points seem to form a sub-cloud of each selected point cloud region. That's why we need to loop through the selected regions and then get the selected points from each. There might be a better solution, but Trimble still hasn't bothered to provide anything that resembles a documentation. It was a lot of trial and error to get to the below.

from Trimble.Vce.Data.Scanning import PointCloudRegion
# GlobalSelection moved to Trimble.Vce.Core in TBC 5.90
try:
    from Trimble.Vce.Core import GlobalSelection
except:
    from Trimble.Vce.UI.Controls import GlobalSelection



self.pointcloudType = clr.GetClrType(PointCloudRegion) # you'll need to import this assembly at the start of the macro as shown above

selectionSet = GlobalSelection.Items(self.currentProject)

# retrieving the selected points from the cloud
            for o in selectionSet:
                if isinstance(o, self.pointcloudType):

                   # a long version to make the process more obvious
                    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)

                   # you can shorten the above to
                    cps = o.Integration.PointCloudDatabase.Integration.GetPoints(o.Integration.GetSelectedCloudId())

                   # now you can loop through those points and do what you want with them, i.e. draft them to worldview
                    for p in cps:
                      cadPoint = wv.Add(clr.GetClrType(CadPoint))
                      cadPoint.Point0 = p