TBC Macros and Extensions

 View Only

 Change Point Description and Feautre code

Jump to  Best Answer
Andy Zhou's profile image
Andy Zhou posted 02-09-2023 22:39

Hi everyone, 

I am quite new to TML. I want to create a simple macro to batch insert point Description1 for selected points. I have been using PointCollect as the container and seems to have the input part running, but never seem to be able to have the BD commit to the changes (The description is never changed). Does anyone have any suggestions? 

Thanks

Andy

Ronny Schneider's profile image
Ronny Schneider  Best Answer

Description is a normal property of a coordinatepoint.

Selecting the points can be done with a

<Wpf:MemberSelection x:Name="objs"/>

in the user interface XAML

In the python script it's then only a matter of looping through the selected entities, double checking that it is the appropriate type and changing its values.

        for o in self.objs:
            if isinstance(o, CoordPoint):

                o.Description1 = "whatever"
                o.Description2 = "whatever2"

I import that class under a different name in order to make the naming a bit more obvious, but that isn't a must.

from Trimble.Vce.Coordinates import Point as CoordPoint

You'll need to update/recompute the project to make the change visible in the properties window.

See post number 7 here

https://community.trimble.com/discussion/how-to-create-surface-from-surface-tie#bm06921534-5a76-434e-b71c-01862f0ae2ae

to see how you can do that automatically.

Andy Zhou's profile image
Andy Zhou

Thank you Ronny, that worked. 

Do you have any experience changing feature attributes in the fxl for points? I basically trying to go one step further, instead of changing descriptions, but also batch-insert certain attributes to all points inside the feature code.

Thanks 

Andy

Ronny Schneider's profile image
Ronny Schneider

Changing parts of existing codes (without losing attributes if it's a multi-attribute one) should work with this code

from Trimble.Vce.Data.RawData import PointManager
from Trimble.Vce.Coordinates import Point as CoordPoint


                for o in self.currentProject:
                #find PointManager as object, not sure if there is a better way
                    if isinstance(o, PointManager):
                        pm = o

                for o in self.objs:

                    if isinstance(o, CoordPoint):

                            features = pm.AssociatedRDFeatures(o.SerialNumber)
                            for fc in features:
                                oldstring = fc.Code
                                oldstring = oldstring.replace("a", "b")
                                fc.Code = oldstring

Creating new codes with the following (haven't used it yet)

pm.SetFeatureCodeAtPoint(uint ptSNr, string fCode)