TBC Macros and Extensions

 View Only
Expand all | Collapse all

Issues settings up VS2019 and accessing Ironpython WPF Window

  • 1.  Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-10-2022 14:17
    Trying to follow the library instructions on getting started with programming TML's, but my VS2019 absolutely does not want to cooperate with doing what the instructions are saying. I've installed the studio, installed ironpython and made sure it was checked in individual components, installed Trimble MacroSDK. First, my TBCMacro template doesn't show up under the python section of project creation, but I am able to get it when I search for it. Once I'm in the project, I am stuck at the instructions to "Add New Item..." because there is no ironpython WPF Window option, or anything ironpython in there at all. My environment is set to iron python, but I can't seem to get past this step.

    ------------------------------
    john chronister
    ------------------------------


  • 2.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-10-2022 21:59
    You should nearly have everything you need.
    In theory you should copy the ZIP-File from "C:\Program Files (x86)\Trimble\Macros SDK\Templates\2019" to
    "C:\Users\your user path\Documents\Visual Studio 2019\Templates\ProjectTemplates".

    The thing is that this template is rather old and won't really work with TBC 5.50 and above, the namespaces did change a bit. Better copy the attached one into the template folder. And once you've setup your solution you don't want to create a new solution for every single macro. You only create a new subfolder, copy and paste a previous macro into it and rename it. You only need this template once, at least I do it this way.

    You don't have to re-start TBC after every code change, just close and re-start the macro.
    Though, in order to interactively edit the UI in the XAML editor you need to stop debugging and close TBC. If you know exactly what you do and you don't need the graphic feedback of the XAML editor you can just edit the code and re-start the macro in TBC.

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

    Attachment(s)

    zip
    TbcMacros.zip   58 KB 1 version


  • 3.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-11-2022 06:00
    Thank you so much for your help, this was awesome. We're almost there, but the only part i'm having issues on right now is getting any custom macro that isn't a part of the RPS solutions to show up on my Macro Ribbon. I have a bunch of macros in my MacroCommands folder that don't show up at all unless they're specifically a part of the RPS Solutions. 

    Wait, there is one that shows up. It's the "ListProjectObjects" macro. That will show up on my ribbon, nothing else though. Any idea why this is happening?






    ------------------------------
    john chronister
    ------------------------------



  • 4.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-11-2022 06:11
    Nevermind! I didn't use your attached template at first. All is working now. Thank you so much for your help! Now to just learn to program.......

    ------------------------------
    john chronister
    ------------------------------



  • 5.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-11-2022 06:41
    Last Question, I promise...


    When you mouse hover over the object name and that menu shows up, mine doesn't do that? How are you able to do that?



    ------------------------------
    john chronister
    ------------------------------



  • 6.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 05-11-2022 14:21
    That inspecting only works if the macro has reached that breakpoint and is halted.

    You need to click OK in the macro window to start it. Since it doesn't have any code it should reach the line with the breakpoint quickly. Once you see the yellow arrow in the red breakpoint dot you should be able to inspect variables/objects.

    On rare occasions I have seen that it doesn't work if you restructured your solution, i.e. moved a macro to a subfolder. Then it starts working again if you stop debugging, close VS, restart VS, load the solution and start debugging again.

    I often add a line like 
    tt = 1
    or similar to my code, i.e. in loops in order to set a breakpoint and inspect the content of variables before the next iteration.

    Stepping through the code, as you might know it from VisualBasic, or Intellisense, or code completion all doesn't work with Ironpython. Debugging is very limited to setting breakpoints and inspect variables.

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



  • 7.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 07-19-2022 16:56
    Stepping through the code, as you might know it from VisualBasic, or Intellisense, or code completion all doesn't work with Ironpython. Debugging is very limited to setting breakpoints and inspect variables

    Since the python code is called from release code (not debug), you should turn off the "Enable Just My Code" option in "Debug Options". This enables F10 to step thru the macro.




    ------------------------------
    Gary Lantaff
    ------------------------------



  • 8.  RE: Issues settings up VS2019 and accessing Ironpython WPF Window

    Posted 07-19-2022 17:48
    Thanks Gary,
    didn't know that. Still a total noob when it comes to using VS.

    But no chance for Intellisense is there?

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