addRepItemToShape method
- IInstance shape,
- IInstance repItem,
- IInstance styleItem
Adds an IfcRepresentationItem to a shape with an optional IfcStyledItem.
This method composes the repItem and styledItem within the shape and
adds them to the shape's composite list of representation items. The styled item
provides visual styling information for the representation item.
This function will fail if repItem is null.
Returns the updated shape instance with the new representation item added, or null instance if the operation fails.
Example usage:
final shape = createInstance(typeName: 'IfcShapeRepresentation');
final repItem = instanceFromJson({
'@type': 'IfcExtrudedAreaSolid',
'SweptArea': {
'@type': 'IfcRectangleProfileDef',
'ProfileType': 'AREA',
'XDim': 100.0,
'YDim': 9000.0
},
'ExtrudedDirection': {
'DirectionRatios': [0.0, 0.0, 1.0]
},
'Depth': 1500.0
});
final styledItem = instanceFromJson({
'@type': 'IfcStyledItem',
'Styles': [
{
'@type': 'IfcSurfaceStyle',
'Side': 'POSITIVE',
'Styles': [
// IfcSurfaceStyleElementSelect
{
// IfcSurfaceStyleElementSelect selected type
'IfcSurfaceStyleRendering': {
// IfcColourRgb instance skipping @type since it is final
'SurfaceColour': {
'Red': 1.0,
'Green': 1.0,
'Blue': 1.0
},
'Transparency': 0.0
}
}
]
}
]
});
final updatedShape = addRepItemToShape(shape, repItem, styledItem);
if (!updatedShape.isNull) {
print('Representation item added successfully to shape');
} else {
print('Failed to add representation item to shape');
}
Implementation
@override
PIInstance addRepItemToShape(
IInstance shape, IInstance repItem, IInstance styleItem) {
if (repItem is! PIInstance ||
styleItem is! PIInstance ||
shape is! PIInstance) {
return PIInstance.nullInstance();
}
final struct = addRepItemToShapeFFI(
projectPtr, ptr, shape.ptr, repItem.ptr, styleItem.ptr);
return PIInstance.fromInstanceStruct(struct);
}