修改IFC对象属性并写入IFC文件

Posted herd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改IFC对象属性并写入IFC文件相关的知识,希望对你有一定的参考价值。

修改IFC对象属性值并更新IFC文档内容。

public void updateIfcObjByIDIFC() throws IOException {
    IfcModel ifcModel = new IfcModel();
    File stepFile = new File(fileName1);
    
    File stepFileW = new File(fileNameW1);
    if(stepFileW.exists())
    {
        stepFileW.delete();
        stepFileW.createNewFile();
    }
    
    try {
        ifcModel.readStepFile(stepFile);
        IfcBeam ifcBeam1 = (IfcBeam) ifcModel.getIfcObjectByID(globalID);
        System.out.println("globalID:"+ifcBeam1.getGlobalId()+"   name:"+ifcBeam1.getName());
        
        STRING name1 = new STRING();
        name1.setDecodedValue("AAAAAA");
        IfcLabel ifcLabel1 = new IfcLabel();
        ifcLabel1.setValue(name1);
        
        ifcBeam1.setName(ifcLabel1);
        System.out.println("globalID:"+ifcBeam1.getGlobalId()+"   name:"+ifcBeam1.getName());
        
        ifcModel.writeStepfile(stepFileW);
        
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

原始IFC

#1239648= IFCCARTESIANPOINT((250.,0.,-300.));
#1239650= IFCAXIS2PLACEMENT3D(#1239648,#11,#21);
#1239651= IFCEXTRUDEDAREASOLID(#1239647,#1239650,#19,1500.);
#1239652= IFCSTYLEDITEM(#1239651,(#12078),$);
#1239655= IFCSHAPEREPRESENTATION(#88,‘Body‘,‘SweptSolid‘,(#1239651));
#1239657= IFCCARTESIANPOINT((2000.,0.));
#1239659= IFCPOLYLINE((#9,#1239657));
#1239661= IFCSHAPEREPRESENTATION(#86,‘Axis‘,‘Curve2D‘,(#1239659));
#1239663= IFCPRODUCTDEFINITIONSHAPE($,$,(#1239661,#1239655));
#1239665= IFCBEAM(‘149QalMb16deCMONmZNEiV1‘,#41,‘M_X26DF751DD571FX0-X277E95F626881X0:300 x 600mm:519271‘,$,‘M_X26DF751DD571FX0-X277E95F626881X0:300 x 600mm:114370‘,#1239643,#1239663,‘519271‘);
#1239668= IFCPROPERTYSINGLEVALUE(‘Span‘,$,IFCPOSITIVELENGTHMEASURE(2000.),$);
#1239669= IFCPROPERTYSET(‘149QalMb16deCMQfKZNEiV‘,#41,‘Pset_BeamCommon‘,$,(#2128,#4846,#4847,#12215,#1239668));
#1239671= IFCRELDEFINESBYPROPERTIES(‘38Dv0DtGD2lefR$zwqV_F6‘,#41,$,$,(#1239665),#1239669);
#1239675= IFCPROPERTYSINGLEVALUE(‘X25DE54F5C5E739762X0‘,$,IFCTEXT(‘X268079AD8X0 : F2‘),$);
#1239676= IFCPROPERTYSINGLEVALUE(‘X2526A5207957F5EA6X0‘,$,IFCLENGTHMEASURE(1500.),$);
#1239677= IFCPROPERTYSINGLEVALUE(‘X24F5379EFX0‘,$,IFCVOLUMEMEASURE(0.27),$);

修改以后的IFC

#1239648= IFCCARTESIANPOINT((250.,0.,-300.));
#1239650= IFCAXIS2PLACEMENT3D(#1239648,#11,#21);
#1239651= IFCEXTRUDEDAREASOLID(#1239647,#1239650,#19,1500.);
#1239652= IFCSTYLEDITEM(#1239651,(#12078),$);
#1239655= IFCSHAPEREPRESENTATION(#88,‘Body‘,‘SweptSolid‘,(#1239651));
#1239657= IFCCARTESIANPOINT((2000.,0.));
#1239659= IFCPOLYLINE((#9,#1239657));
#1239661= IFCSHAPEREPRESENTATION(#86,‘Axis‘,‘Curve2D‘,(#1239659));
#1239663= IFCPRODUCTDEFINITIONSHAPE($,$,(#1239661,#1239655));
#1239665= IFCBEAM(‘149QalMb16deCMONmZNEiV1‘,#41,‘M_X26DF751DD571FX0-X277E95F626881X0:300 x 600mm:519271‘,$,‘M_X26DF751DD571FX0-X277E95F626881X0:300 x 600mm:114370‘,#1239643,#1239663,‘519271‘);
#1239668= IFCPROPERTYSINGLEVALUE(‘Span‘,$,IFCPOSITIVELENGTHMEASURE(2000.),$);
#1239669= IFCPROPERTYSET(‘149QalMb16deCMQfKZNEiV‘,#41,‘Pset_BeamCommon‘,$,(#2128,#4846,#4847,#12215,#1239668));
#1239671= IFCRELDEFINESBYPROPERTIES(‘38Dv0DtGD2lefR$zwqV_F6‘,#41,$,$,(#1239665),#1239669);
#1239675= IFCPROPERTYSINGLEVALUE(‘X25DE54F5C5E739762X0‘,$,IFCTEXT(‘X268079AD8X0 : F2‘),$);
#1239676= IFCPROPERTYSINGLEVALUE(‘X2526A5207957F5EA6X0‘,$,IFCLENGTHMEASURE(1500.),$);
#1239677= IFCPROPERTYSINGLEVALUE(‘X24F5379EFX0‘,$,IFCVOLUMEMEASURE(0.27),$);
#1239678= IFCPROPERTYSINGLEVALUE(‘X2957F5EA6X0‘,$,IFCLENGTHMEASURE(2000.),$);
#1239679= IFCPROPERTYSINGLEVALUE(‘X2976279EFX0‘,$,IFCAREAMEASURE(1.53),$);
#1239680= IFCPROPERTYSET(‘0axrEt8Mj7$x3$SQByRQMS‘,#41,‘X251764ED6X0‘,$,(#12244,#12245,#12246,#12247,#12248));
#1239682= IFCRELDEFINESBYPROPERTIES(‘0P6n1YdebA8eyWRmk_WoYA‘,#41,$,$,(#1239665),#1239680);

以上是关于修改IFC对象属性并写入IFC文件的主要内容,如果未能解决你的问题,请参考以下文章

如何为 Ifc2x3 和 Ifc4 重用相同的 xBim 代码

IFC对象增加自定义属性

使用不同 Ifc 版本的相同代码的不同结果

IFC文档结构说明

Autodesk forge 将 rvt 转换为 IFC 并移入文件夹

xBIM 高级01 IFC多模型合并