TBC Macros and Extensions

 View Only
Expand all | Collapse all

Updated Training Materials

  • 1.  Updated Training Materials

    Posted 03-20-2025 14:56

    Hello Everyone, 

    I am an established developer with years of C#, .NET, and WPF experience to name a few, creating plugins for Autodesk products as well as many others. I now have a need and desire to start developing plugins/macros for TBC. I am curious if there is any newer documentation or training materials anywhere, as the ones posted within the community are very dated and do not correlate with TBC 2024. I can't seem to even see how to load a compiled .dll into TBC. It is very unclear. Any help or direction to additional materials would be greatly appreciated. A very simple "Hello Word" walk through would be great. Like I said, even if I develop something it is unclear how to load it into TBC. An Autodesk equivalent to netload. Thank you in advance. 



    ------------------------------
    David Prontnicki
    ------------------------------


  • 2.  RE: Updated Training Materials

    Posted 23 days ago

    We are coming from the same place, and no, what you see is what you get. Here are some recommendations:

    • Have a look at my posts and the questions and answers related to them. Essentially you are going to create a DLL which you load with python. TBC will happily work as a debugger for both the py and cs files.
    • Also search for Ronny Schneider on here. He is working exclusively in python but he has a big collection of macros on Git that will be of immense help. Ronny, when I do an @ mention there are 4 results. Are they all you?
    • @Bryce Haire is also helpful. I believe he is with Trimble.
    • Create a python project in VS2019 - you can probably get 2022 to work but believe me - climb one mountain at a time. There are walkthroughs on here that will get your dev environment working. The python project must be the startup project.
    • You can either create your project in C:\ProgramData\Trimble\MacroCommands3\<MyCustomMacroFolder> or have a pre-debug script that compiles your DLL and copies the python folders and contents to the Macro3 directory. I don't know the python dev environment well enough to get it to do that, so I develop in the Macro3 directory. You will have to build you DLL before debugging or figure out how to do it as part of the debug process.
    • Create a folder for each macro in your python project. You will have an image file for the icon, the py file and the xaml file in each one. Ronny has a post on best practices here.
    • Add a C# Class Library project using Framework 4.8 to the project
    • Your xaml file will also be loaded as a loose file (as above). Don't put any xaml in your DLL

    Here is a little sample

    # the name of this class must match name from cmdData.UIForm (above)
    class MyProjectProperties(Window): # this inherits from the WPF Window control
    
        # constructor
        def __init__(self, currentProject, macroFileFolder):
            # import the C# library
            clr.AddReferenceToFileAndPath("C:\\ProgramData\\Trimble\\MacroCommands3\\MyMacros\\MyMacroLib.dll")
            # load the view
            with StreamReader(macroFileFolder + r"\MyProjectProperties.xaml") as s:
                wpf.LoadComponent(self, s)
    
            # configure the macro
            self.currentProject = currentProject
            self.macroFileFolder = macroFileFolder
    
            # create the view model
            from Db.Tbc import MyProjectProperties
            prop=MyProjectProperties(self.currentProject)
    
            # set view model properties
            prop.SupportTransactions = False
            prop.SupportPointManager = True
            prop.SupportFeatureCodeManager = False
            prop.SupportUiEvents = False
            prop.SupportUndo = True
    
            # set the datacontext of the view to the view model
            self.DataContext = prop

    Most of your projects will use StackPanel, but this is a dialog. Note that you can do MVVM because we have a data context!

    Also, I have a base class that abstracts out the contents of the try...catch...finally block so I can reuse code. It also has all the boilerplate for Transactions and some of the support snapins that your macros may need to access.

    I have one top level class per macro that inherits from by base class, which inherits from ViewModelBase in Trimble.Sdk.UI.  In the script I newed up the class, set some properties - often lots of properties - then set the data context of the xaml file to the class. You can also interact with the xaml from the python script. In that case you tend to marshal data in and out of the class quite a bit.

    Because this is a dialog, I load the form like this

        # show the properties dialog when the script is executed
    def Execute(cmd, currentProject, macroFileFolder, parameters):
        form = MyProjectProperties(currentProject, macroFileFolder).ShowDialog()
        return

    Lastly, for now, but certainly not least, load up your object explorer with a bunch of DLLs from the SDK. This is a good start, but unfortunately the hardest part of all is figuring out how to get to what you want.



    ------------------------------
    David Brubacher
    ------------------------------



  • 3.  RE: Updated Training Materials

    Posted 20 days ago

    Been a bit busy in the field lately and didn't have time to check the forum.

    @David Brubacher, yes, all 4 entries are me, unfortunately. Every time you work for a different company and want to access their Trimble Connect or Worksmanager/TCC projects you need a new TID. In the forum I try to post with my private account, unless I forget by mistake to switch accounts or browser. Use the gmail.com one.

    @David Prontnicki

    • Trimble never encouraged programming in C# or C++; it's definitely possible, but I'm just not a developer and don't know how to properly debug it without havening to restart TBC every time I change the code; with Python you simple have to restart the macro within TBC and it'll use the changed code
    • I assume you followed the getting started series TBC Macros and Extensions1 - Trimble Inc.
    • the latest macro SDK https://tbcrelease.blob.core.windows.net/download/trimble_macros_sdk_v2040.10.msi - they can't even name the file correct
    • collection of old sample TML, which potentially won't run since they have moved things around in the assembly namespaces since then - Sample TMLs
    • my public GitHub repo GitHub - RonnySchneider/SCR_Macros_Public - it's a ZIP-file you need to download and Unzip manually - I just wasn't sure how many potential users would know how to use GitHub the right way - my development repo is used the correct way from within VS
    • copy and paste from a previous post
      • are you planning to develop with Ironpython? Then the previous advice was and is not to use 2022 but to stay with 2019.

    I may add to this post later on.



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