yogeshv.info
happy I’m thankful

Area value retrieval - IfcOpeningElement

Dear Ruben de Laat ,

Thank you so much for the RelDefines relationship which i was missing. I was unable to figure out the getIsDefinedBy method.

Please clarify the following in the same code you have written.

I separately loaded IfcElementQuantity like
List qty = model.getAll(IfcElementQuantity.class);
out.println("element qty size is "+qty.size());

It is printing as 6.

Trying the following, if (relatingPropertyDefinition instanceof IfcElementQuantity)

No element quantity detected, code does not enter this if loop.

Kindly please help me if i am doing anything wrong obviously.

This is being used for a research program and i am in a situation to get it done for favorable results. Thank you very very much in advance.

package org.bimserver.querycompiler;

import java.io.PrintWriter;
import org.bimserver.ifc.database.IfcDatabase;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import org.bimserver.ifc.emf.Ifc2x3.*;

public class Query implements QueryInterface {

private IfcDatabase model;
private PrintWriter out;

@Override
public void query(IfcDatabase model, PrintWriter out) {

List qty = model.getAll(IfcElementQuantity.class);
out.println("element qty size is "+qty.size());

List stories = model.getAll(IfcBuildingStorey.class);
List Opening_subjectToArea = new ArrayList();

if(!(stories.isEmpty())){
for (IfcBuildingStorey storey : stories) {
for (IfcRelContainedInSpatialStructure rel : storey.getContainsElements()) {
for (IfcProduct product : rel.getRelatedElements()) {
if (product instanceof IfcSlab) {
IfcSlab tempSlab = (IfcSlab)product;
IfcElement ifcslabElement = (IfcElement)tempSlab;
for(IfcRelVoidsElement relVoids : ifcslabElement.getHasOpenings()){
Opening_subjectToArea.add(relVoids.getRelatedOpeningElement());
out.println("here 0");
}
}
}
}
}
}
else{out.println("Building stories not available...");}

if(!(Opening_subjectToArea.isEmpty())){
Iterator OE_it = Opening_subjectToArea.iterator();
while(OE_it.hasNext()){
IfcOpeningElement openingElement = (IfcOpeningElement)OE_it.next();
for (IfcRelDefines defines : openingElement.getIsDefinedBy()) {
if (defines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties definesByProperties = (IfcRelDefinesByProperties)defines;
IfcPropertySetDefinition relatingPropertyDefinition = definesByProperties.getRelatingPropertyDefinition();
Iterator qit = qty.iterator();
while(qit.hasNext()){
qit.next();
out.println("running");
//if(qit.next() == (IfcElementQuantity)relatingPropertyDefinition){out.println("exist");}
//else{out.println("running");}
}
if (relatingPropertyDefinition instanceof IfcElementQuantity) {
out.println("here 4");
IfcElementQuantity elementQuantity = (IfcElementQuantity)relatingPropertyDefinition;
for (IfcPhysicalQuantity physicalQuantity : elementQuantity.getQuantities()) {
if (physicalQuantity instanceof IfcQuantityArea) {

IfcQuantityArea area = (IfcQuantityArea)physicalQuantity;
float areaValue = area.getAreaValue();
out.println("Area value : "+areaValue);
}
}
}
}
}
}
}
else{out.println("No match for Opening element incorporated to slab");}
}
}

Thank you!
1 person has
this question
+1
Reply

  • Hi,

    When the data you ask for is not in the IFC model, of course it won't show up after running the query.
    Please provide us your IFC model for debugging.
    Thank you.

    Greetings,
    Léon
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly

  • yogeshv.info
    Hi Léon,

    Thank you. We will send the model to you soon.

    Regards,
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly

  • Hi, here is a modified version of your code, it does show some area's, not sure if those are what you are looking for, let me know.


    if (!(Opening_subjectToArea.isEmpty())) {
    out.println("Total Opening Element in the model which are associated to slabs are " + Opening_subjectToArea.size());
    Iterator OE_it = Opening_subjectToArea.iterator();
    while (OE_it.hasNext()) {
    IfcOpeningElement openingElement = (IfcOpeningElement) OE_it.next();
    for (IfcRelDefines ifcRelDefines : openingElement.getIsDefinedBy()) {
    if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
    IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
    IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
    if (relatingPropertyDefinition instanceof IfcPropertySet) {
    IfcPropertySet ifcPropertySet = (IfcPropertySet)relatingPropertyDefinition;
    for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
    if (ifcProperty instanceof IfcPropertySingleValue) {
    IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue)ifcProperty;
    if (ifcPropertySingleValue.getNominalValue() instanceof IfcAreaMeasure) {
    IfcAreaMeasure ifcAreaMeasure = (IfcAreaMeasure)ifcPropertySingleValue.getNominalValue();
    System.out.println("Area for " + openingElement + ": " + ifcAreaMeasure.getWrappedValue());
    }
    }
    }
    }
    }
    }
    }
    } else {
    out.println("No match for Opening element incorporated to slab");
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly

  • This reply was removed on 2011-07-18.
    see the change log