OSArch Community

P_BOUNDEDVALUE: how to set the range to a custom PSET property?

  1. M

    Hi there!

    I wanted to use a range for a value so I've set P_BOUNDEDVALUE in PSET template.

    ! When I add this custom PSET to my object the propeties are missing.

    ! Am I doing something wrong?

    Thank you very much!

  1. M
  1. M

    @Moult I made a script to set these values.

    
    import bonsai.tool as tool 
    
    import ifcopenshell
    
    import ifcopenshell.guid
    
    import logging
    
    import sys
    
    logger = logging.getLogger("Pset_mod") 
    
    logger.setLevel(logging.DEBUG) 
    
    stream_handler = logging.StreamHandler(sys.stdout)
    
    stream_handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
    
    logger.addHandler(stream_handler) 
    
    ifc_file = tool.Ifc.get() 
    
    if not ifc_file:
    
        raise Exception("IFC file not loaded.")
    
    elements = ifc_file.by_type("IfcWall")
    
    for element in elements:
    
        existing_pset = None
    
        for rel in element.IsDefinedBy:
    
            if rel.is_a("IfcRelDefinesByProperties") and rel.RelatingPropertyDefinition.is_a("IfcPropertySet"):
    
                if rel.RelatingPropertyDefinition.Name == "DIA_design":
    
                    existing_pset = rel.RelatingPropertyDefinition
    
                    break
    
        owner_history = None
    
        if ifc_file.by_type('IfcOwnerHistory'):
    
            owner_history = ifc_file.by_type('IfcOwnerHistory')[0]
    
        if not existing_pset:
    
            existing_pset = ifc_file.createIfcPropertySet(
    
                ifcopenshell.guid.new(),
    
                owner_history,
    
                'DIA_design',
    
                None,
    
                []
    
            )
    
            ifc_file.createIfcRelDefinesByProperties(
    
                ifcopenshell.guid.new(),
    
                owner_history,
    
                None,
    
                None,
    
                [element],
    
                existing_pset
    
            )
    
        ac_ratio = ifc_file.createIfcPropertyBoundedValue(
    
            'A/C',
    
            None,
    
            ifc_file.createIfcRatioMeasure(1),  # Upper bound
    
            ifc_file.createIfcRatioMeasure(0.9),  # Lower bound
    
            ifc_file.createIfcRatioMeasure(0.95),  # Nominal value
    
            None
    
        )
    
        peso_specifico = ifc_file.createIfcPropertyBoundedValue(
    
            'Peso_specifico',
    
            None,
    
            ifc_file.createIfcMassDensityMeasure(1650),  # Upper bound
    
            ifc_file.createIfcMassDensityMeasure(1450),  # Lower bound
    
            ifc_file.createIfcMassDensityMeasure(1550),  # Nominal value
    
            None
    
        )
    
        viscosita = ifc_file.createIfcPropertyBoundedValue(
    
            'Viscosità',
    
            None,
    
            ifc_file.createIfcTimeMeasure(50),  # Upper bound
    
            ifc_file.createIfcTimeMeasure(47),  # Lower bound
    
            ifc_file.createIfcTimeMeasure(48),  # Nominal value
    
            None
    
        )
    
        new_properties = []
    
        for prop in existing_pset.HasProperties:
    
            if prop.Name not in ['A/C', 'Peso_specifico', 'Viscosità']:
    
                new_properties.append(prop)
    
        new_properties.extend([ac_ratio, peso_specifico, viscosita])
    
        existing_pset.HasProperties = tuple(new_properties)
    
    logger.info("Done.")
    

    This is what it looks like on blender

    !

    And in BimVision I get exatcly what I was looking for:

    !

    ( I don't know why it shows kg/m² instad of kg/m³ but it must be a bug of BimVision)

  1. M

    Uhm I tried to validate from buildingSMART and it looks bad :S

    Schema - Unit (occurred 1002 times)

    ⓘ Note: a high number of occurrences were identified. Only the first 10 occurrences are displayed below.
    
    Id  Entity  Severity    Message
    
    #28828  IfcPropertyBoundedValue Error   With attribute:
    
        <attribute Unit?: <select IfcUnit: (<entity IfcDerivedUnit> | <entity IfcMonetaryUnit> | <entity IfcNamedUnit>)>>
    
    Value:
    
        IfcTimeMeasure(48.)
    
    Not valid
    
    #28829  IfcPropertyBoundedValue Error   With attribute:
    
        <attribute Unit?: <select IfcUnit: (<entity IfcDerivedUnit> | <entity IfcMonetaryUnit> | <entity IfcNamedUnit>)>>
    
    Value:
    
        IfcRatioMeasure(0.95)
    
    Not valid
    
    #28830  IfcPropertyBoundedValue Error   With attribute:
    
        <attribute Unit?: <select IfcUnit: (<entity IfcDerivedUnit> | <entity IfcMonetaryUnit> | <entity IfcNamedUnit>)>>
    
    Value:
    
        IfcMassDensityMeasure(1550.)
    
    Not valid

Login or Register to reply.