TBC Macros and Extensions

 View Only

 Macro to perform batch operations across multiple point clouds

Andrew Manning's profile image
Andrew Manning posted 02-19-2025 18:23

Hi TBC macro community,

I'm looking into the feasibility of creating a macro to run a set list of commands across numerous pointclouds and would appreciate any pointing in the right direction

There are a large number of large pointclouds (100+ las files which are a couple of gb each)

Ideally the macro would function in the following way

  • In TBC - specify folder containing all pointclouds
  • Macro then opens a pointcloud, 
  • Runs extract trees command, 
  • Saves output points, 
  • Closes pointcloud, 
  • Opens next pointcloud - rinse and repeat

I've got my VS environment setup but am yet to look into the actual coding part of the macro but am keen to learn

Any pointers in the right direction in regard to methods i will likely need or any existing threads would be much appreciated

Bryce Haire's profile image
Bryce Haire

Hi Andrew, 
Happy to help out. It sounds like you have perused the "Library" area of TBC Macros community so I would go through those if you haven't. 

I would also like to share a post from Ronny about training videos/setup he has graciously put together about how to get up and running for macro development. This is extremely well put together and has been much appreciated by a lot of developers getting started. 

https://community.trimble.com/question/june-2024-installation-for-macros 

These two resources should help you jump in and start the journey of writing your own set of macros!

Ronny Schneider's profile image
Ronny Schneider

@Bryce Haire

The mentioned information will help with some basic tasks like drawing a line, but it definitely doesn't help with finding out how the whole point cloud database system works, how for instance to import a LAS file with a macro, without any GUI window popping up. How to start a specific classification run with a macro.

Or even simple basics, how exactly the extraction from an existing cloud works, what are those "Integrations", how do those cloud ID's exactly work.

The VS Object Browser shows rather little information when it comes to Pointclouds.

It took me hours to find out the absolute basic retrieval of the on-screen selected cloud points as Point3D's.

                selectionSet = GlobalSelection.Items(self.currentProject)
                cloudselectionids = []
                for o in selectionSet:   
                    if isinstance(o, self.pointcloudType): # self.pointcloudType = clr.GetClrType(PointCloudRegion)

                        # the cloudids must be the ID's of the single scan stations
                        # we iterate through the different cloud regions (i.e default, ground, Wall)
                        # and retrieve the scan station ids which contain data for the currently selected cloud parts
                        cloudselectionids.Add(o.Integration.GetSelectedCloudId())

                        # ???? what is Integration within another Integration
                        # what does that word mean here, havent come across it elsewhere in TBC???
                        cloudintegration = o.Integration.PointCloudDatabase.Integration 

                # now get from the database the selected points from each scan station
                cps = cloudintegration.GetSelectedPoints(cloudselectionids)

What's the difference between "PointCloudRegion" and "ExposedPointCloudRegion".

Nothing is properly documented, how it's intertwined. I'm nearing my 100th macro now and still haven't figured point clouds out properly. We need a decent documentation as we have for the Access SDK. I'm wasting so much time with trail and fail on how to use everything properly, the reasoning of the person who wrote the code at some point.

Andrew Manning's profile image
Andrew Manning

Hey guys, 

Thanks for the pointers - sounds like I might be in for a bit of a hard time haha! Nothing a bit of digging cant fix!

I do have one issue - when I open the object browser I can't see any Trimble objects, which is slightly hindering my ability to even start looking around 

Are there any common blunders that would cause this?

Also confirming that TBC macros use IronPython 3.x going forwards now? not 2?

Thanks for your help

Ronny Schneider's profile image
Ronny Schneider

Since V5.90 TBC uses Ironpython 3.

Check the following video from 2:15 on how to add the SDK to the object browser.

TBC Macros and Extensions1 - Trimble Inc.

You could do the same with the DLL's directly from "C:\Program Files\Trimble\Trimble Business Center" but then you'd miss the comments in the object browser, in case there are some. Still a few assemblies without proper documentation.

You also want to add the attached macro to your macro folder. It comes from Gary's blogpost Sample TMLs (TBC version 5.90) (trimble.com). That's an old Trimble Sample macro helping you understand the project tree and to find objects by name or serial number and how they may be intertwined, which container they belong to ..... . Inexplicable why this one isn't delivered with the standard TBC installation anymore, but only the rather useless ListProjectObjects. That archive in the blogpost contains all the former Trimble sample macros, but as rather old version. Don't copy them to your macro folder, they most likely produce errors during startup. I'll keep them someplace else but have them all open in my Notepadd++ to search for hints. Those are actually the best and only we have as decent documentation. Without those I'd never been able to figure most things out. But they don't cover pointclouds or IFC handling.