TBC Macros and Extensions

 View Only
Expand all | Collapse all

additional user attributes for drawing entities

  • 1.  additional user attributes for drawing entities

    Posted 12-10-2021 04:29
    How can you add additional attributes to entities like the 12d importer does for line strings.

    I found them actually in the Trimble.Vce.Core.Components.UserDefinedAttributes = 27 as protected dictionary.

    How can you add or change those.

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


  • 2.  RE: additional user attributes for drawing entities

    Posted 12-10-2021 04:52
    Hi Ronny,

    you can use the customattributes which work really great. I use them a lot for many of my macros as I store own attributes like object type, dimensions, material, floor, room, etc, etc.

    For example, to assign attributes to selected objects:

    for o in self.objs.SelectedMembers(self.currentProject):
              userAttributes = SnapInAttributeExtension.UserAttributes.Overloads[ISnapIn](o)
              if( userAttributes.ContainsKey("Position") == False):
                       userAttributes.Add("Position", strPosNum + "_" + strPosDesc + "_" + strPosType)
             else:
                      userAttributes ["Position"] = strPosNum + "_" + strPosDesc + "_" + strPosType
                     

    And then when I look for the objects in the project that contain my own attributes:

    for o in self.objsTree.SelectedMembers(self.currentProject):
              #Check if the object has Position and description
              userAttributes = SnapInAttributeExtension.UserAttributes.Overloads[ISnapIn](o)
              if(userAttributes.ContainsKey("Position")):
              strPosition = userAttributes ["Position"]

    I hope this helps.

    Regards,
    Fernando

    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 3.  RE: additional user attributes for drawing entities

    Posted 12-10-2021 18:49
    Edited by Ronny Schneider 12-10-2021 19:02
    Hi Fernando,
    thanks for that. That works, but they are only accessible by the macro. Would you know how to show them in the properties pane?

    It's actually working when I use SITECH's Key. So, how do I make the properties pane to show my custom key?


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



  • 4.  RE: additional user attributes for drawing entities

    Posted 12-11-2021 00:16
    Hi Ronny,

    so far I know, those userattributes are not shown on the properties pane. I created my own properties pane for showing custom atts.

    What you can do is using features of the FXL instead, so you can see all atributes on the  properties pane, also images and other attribute types.

    Not sure how 12d did that to show them on the properties pane.

    Regards,
    Fernando

    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 5.  RE: additional user attributes for drawing entities

    Posted 02-12-2023 16:52

    Hi Fernando, 

    Thanks for all your advice.

    I have a basic question, how would you access and assign/edit point attributes of the FXL? There are many classes associated with this but I still haven't figured out which one is the best approach.



    ------------------------------
    Weifan Zhou
    ------------------------------



  • 6.  RE: additional user attributes for drawing entities

    Posted 02-24-2023 10:20

    Hi Weifan,

    sorry for my late reply, but I´m not checking this forum in the last weeks due to high workload.

    Unfortunately I haven´t done anything with FXL attributes in TBC yet, only in Trimble Access accessing myself to the FXL attributes etc, but not in TBC, therefore I cannot tell you too much about the way to access them in TBC.

    I guess it´s using the Trimble.Vce.Data.FXL  

    Regards,

    Fernando



    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 7.  RE: additional user attributes for drawing entities

    Posted 03-08-2023 20:11

    Hi Fernando and Ronny,

    Sorry I didn't get back to you earlier, just came back from holiday. 

    With help from Ronny, "AssociatedRDFeatures" is the way to go for the feature code. 

    I have a new issue related to the topic. I have an IFC file, with each entity containing a long list of attributes. I tried to use "UserAttributes" but the count is zero, which means these attributes are not "UserAttributes" (unless i am doing something wrong here?)

    I also tried to use "UserDefinedAttributes.GetTypedValue" but I am not sure what parameter i should feed to it. 

    How would you extract the attributes out of an entity? 

    Thanks in advance

    Weifan



    ------------------------------
    Weifan Zhou
    ------------------------------



  • 8.  RE: additional user attributes for drawing entities

    Posted 03-12-2023 00:45
      |   view attached

    Hello Weifan,

    in cases like this I always use my inspect macro that allows me to select a single entity and reach a stop point where I can inspect its properties.

        def OkClicked(self, cmd, e):
            Keyboard.Focus(self.okBtn)
            self.error.Content=''
            
            #wv = self.currentProject [Project.FixedSerial.WorldView]
            #ProgressBar.TBC_ProgressBar.Title = ""
            
            for o in self.objs:
                tt = o
                tt2 = o

    In case of one of my IFC's I can see that it is an IFCMesh object.

    Using the object browser I can see that IFCMesh doesn't have any methods handling its properties. But it resides within BIMEntity (m_site).

    And that one does provide PropertiesCount, GetProperty.

    So, the following code will create a list with all the attributes of the object.

        def OkClicked(self, cmd, e):
            Keyboard.Focus(self.okBtn)
            self.error.Content=''
            
            #wv = self.currentProject [Project.FixedSerial.WorldView]
            #ProgressBar.TBC_ProgressBar.Title = ""
            
            properties = []
    
            for o in self.objs:
                bimentity = o.GetSite()
                for i in xrange(bimentity.PropertiesCount):
                    properties.Add(bimentity.GetProperty(i))
    
                tt2 = o



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

    Attachment(s)

    zip
    SCR_InspectObject.zip   5 KB 1 version


  • 9.  RE: additional user attributes for drawing entities

    Posted 03-13-2023 15:06

    Thank you so much Ronny, that worked.



    ------------------------------
    Weifan Zhou
    ------------------------------



  • 10.  RE: additional user attributes for drawing entities

    Posted 03-16-2023 17:24

    Hi Ronny, 

    One more question for you. Extracting entity attributes/features never seem to be so straightforward, now lines. 

    Do you know how can I set the line feature and change all its feature attributes?

    Thanks in advance 



    ------------------------------
    Weifan Zhou
    ------------------------------



  • 11.  RE: additional user attributes for drawing entities

    Posted 03-19-2023 02:16

    Hello Weifan,

    I haven't done much with line features yet.

    So far I've found out how to get the values and how to remove them.

    Base on the Trimble ViewProjectData macro and changing the code from my InspectObject macro as follows.

    from Trimble.Vce.Features import LineFeature
    
    
            for obj in self.objs:
                # the things we are looking at.
                observes = self.currentProject.Concordance.GetIsObservedBy(obj.SerialNumber)
                
                for o in observes:
                    if isinstance(o, LineFeature):
                        for att in o.Attributes:
                            tt = o.Remove(att)
                            tt2 = tt
    

    Each object is observed by others and is also observing things. In case of a Linestring i.e. it is observing the points it might be connected to and the LineFeature.

    LineFeature.Remove works.

    LineFeature.Create are all protected and I have to find out how to circumvent this.



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



  • 12.  RE: additional user attributes for drawing entities

    Posted 03-19-2023 20:17

    Thanks Ronny, 

    Before even changing the attributes, I want to change the Feature itself first. 

    I tried to define a new LineFeature with a certain FeatureDefinition, then tried to remove the LF from a linestrings's observe list and then add the new one in, but doesn't seem to work that way...

    I will keep trying...



    ------------------------------
    Weifan Zhou
    ------------------------------



  • 13.  RE: additional user attributes for drawing entities

    Posted 06-19-2023 07:02

    Hi Ronny, 

    Hope you are well!

    I tried the above method to create 12d Attribute but got an error on "UIEvents.RaiseAfterDataProcessing(self, UIEventArgs())" as below. Also, the object is corrupted probably due to the interruption of the transaction.  Have you encountered this before? 

    Thanks

    Andy



    ------------------------------
    ANDY ZHOU
    ------------------------------



  • 14.  RE: additional user attributes for drawing entities

    Posted 06-19-2023 14:20

    Hello Andy,

    I'd need to see the code that is causing it in order to narrow it down. If you don't want to upload it here you can also send me a private message.

    Which TBC/Ironpython version are you using?



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



  • 15.  RE: additional user attributes for drawing entities

    Posted 06-19-2023 23:29

    Hi Ronny, I think I figured it out. 

    The error message from yesterday was because of a syntax error in the loop before it, then I think somehow the error interrupted the transaction manager (TM) then it corrupted the project. Even though I fixed the syntax error, the TM started to throw errors. I woke up this morning and started fresh on the project, everything seems to be fine now. 

    I was thinking wrongly that the Sitech key doesn't work with the TM, but it was because of a corrupted project. 

    By the way, did you end up finding a way to create your own key rather than using Sitech's ? 

    Thanks 

    Andy



    ------------------------------
    ANDY ZHOU
    ------------------------------



  • 16.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 00:16

    No, I never investigated much further into this, and I won't in the near future. I'm currently making sure that all my macros work with V5.90. Which will be a challenge since I'll leave my current job by the end of June and take unpaid leave until at least next year. I won't have access to a TBC license anymore and who knows what brand of gear I'll be working with in the future. Looking back at 3 years of paid for Worksmanager improvement it might be time for a change.

    There will be a full release of all of my macros under GPL3 license on GitHub within the next week. I'll post that separately.



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



  • 17.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 08:07
    Edited by Morteza Kiani 06-20-2023 08:08

    Good luck Ronny! 

    I want to thank you for your hints and responses. 

    Thanks,



    ------------------------------
    Morteza Kiani
    ------------------------------



  • 18.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 15:46

    All the best Ronny, thanks for all your selfless contributions to the Trimble community, I am sure someday we will cross paths again!



    ------------------------------
    ANDY ZHOU
    ------------------------------



  • 19.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 14:31

    What's the "Sitech key" you guys are talking about using here?



    ------------------------------
    Dylan Towler
    dylan_towler@buildingpoint.com.au
    https://tbcanz.com/anz-toolbox/
    ------------------------------



  • 20.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 15:51

    Hi Dylan, 

    As described in post 3 by Ronny, we would like to have the capability to have our own UserAttributes. At the moment, if we put in any key, we can create the UserAttributes but only accessible by the macro and won't be shown in the property panel. The "Sitech12dAttributes" key, however, will be shown in the property panel. So we were just wondering what is special about the "Sitech12dAttributes" key and how can we create something similar for ourselves. 



    ------------------------------
    ANDY ZHOU
    ------------------------------



  • 21.  RE: additional user attributes for drawing entities

    Posted 06-20-2023 18:43

    Oh right I see. I guess I can't stop you from using that key but just keep in mind that if your customers are using 12d import/export that it will very likely break their 12d workflow.

    In order to use your own key, but have them displayed in the properties UI you'll need to write a UIWrapper. Not sure if this is possible in python. It will be possible - just not sure if the scaffolding is there. You'd have to ask Trimble.

    Hope this helps.



    ------------------------------
    Dylan Towler
    dylan_towler@buildingpoint.com.au
    https://tbcanz.com/anz-toolbox/
    ------------------------------