Can not access Parameter of FamilyInstance

Hi guys,


I am trying to access the Space property as per the picture above, but then I can not get or access their Parameter. I would like to get information of Room Name and Room Number of them.

Here is my code:

def UpdateSpaceInfo(ele):
    roomName = None  # Khởi tạo mặc định
    roomNumber = None


    with Transaction(doc, "Update Space Info") as t:
        t.Start()
        lstCheck = []
        try:
            if isinstance(ele, FamilyInstance):
                # Lấy vị trí của FamilyInstance
                space = ele.Space
                # roomName = Element.Name.__get__(space)
                # roomNumber = Element.Number.__get__(space)
                roomName = space.get_Parameter(BuiltInParameter.ROOM_NAME).AsString()
                roomNumber = space.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString()

                # location = ele.Location
                # if location and isinstance(location, LocationPoint):
                #     point = location.Point
                #
                #     # Tìm Space tại vị trí đó
                #     space = doc.GetRoomAtPoint(point)


                    # if space:
                    #     roomName = space.get_Parameter(BuiltInParameter.ROOM_NAME).AsString() or "N/A"
                    #     roomNumber = space.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString() or "N/A"
                    # 
                    #     # Lấy Parameter cần cập nhật
                    #     DPNameSpace = ele.LookupParameter("DP Space Name")
                    #     DPNumberSpace = ele.LookupParameter("DP Space Number")
                    # 
                    #     # Cập nhật giá trị nếu Parameter tồn tại
                    #     if DPNameSpace and roomName:
                    #         DPNameSpace.Set(roomName)
                    #     if DPNumberSpace and roomNumber:
                    #         DPNumberSpace.Set(roomNumber)

        except Exception as ex:
            print("Failed to update element {}: {}".format(ele.Id, ex))

        t.Commit()


    return roomName,roomNumber

I tried it by C# and it works but when I try by Python it doesn’t work. Can anyone help me to solve it by Python?

This is what I return when print them:
‘indexer#’ object has no attribute ‘get_Parameter’

ironpython is getting confused and think your space = ele.Space as the overload that takes a phase input. try ele.get_Space() instead.

But the parameters you get are readonly though at least in rvt 25.

DPNameSpace.Set(roomName)
DPNumberSpace.Set(roomNumber)             
1 Like

Hi ,

I do some research and found that I can not access as per that way. So I tried to a new way to approach it. Here is my code:

            if isinstance(ele, FamilyInstance):
                point = ele.Location.Point
                space = doc.GetSpaceAtPoint(point)

I can not access by ele.get_Space() either

feed a default phase to it then. if GetSpaceAtPoint works then stick to that. not worth it to get bogged down with such kind of issue in my opinion.

lol it seems to be alright with cpython3.

1 Like

ya I think it depends on the library we are using