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
    ------------------------------