### Configure Custom IfcOpenShell Build Version (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Demonstrates how to configure a custom IfcOpenShell binary version using system settings. This allows users to specify particular builds or commits. The example also shows enabling quantity calculation and layer set application.
```java
import org.bimserver.models.store.ObjectDefinition;
import org.bimserver.models.store.StoreFactory;
import org.bimserver.plugins.PluginConfiguration;
// Configure custom build version
PluginConfiguration config = new PluginConfiguration() {
@Override
public String getString(String key) {
if ("buildversion".equals(key)) {
return "v0.8.0-abc123"; // custom version tag
}
return null;
}
@Override
public Boolean getBoolean(String key, boolean defaultValue) {
if ("calculatequantities".equals(key)) return true;
if ("applylayersets".equals(key)) return true;
if ("disableopeningsubtrations".equals(key)) return false;
return defaultValue;
}
};
IfcOpenShellEnginePlugin plugin = new IfcOpenShellEnginePlugin();
try {
plugin.init(pluginContext, config);
// Plugin downloads: https://s3.amazonaws.com/ifcopenshell-builds/IfcGeomServer-v0.8.0-abc123-linux64.zip
System.out.println("Version: " + plugin.getVersionInfo().getBuildVersion());
} catch (Exception e) {
System.err.println("Failed to load custom build: " + e.getMessage());
}
```
--------------------------------
### Maven POM Configuration for Plugin (XML)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Example Maven POM (Project Object Model) configuration for the IfcOpenShell BIMserver plugin. It specifies project coordinates, dependencies (like pluginbase), and build settings including the Java compiler version.
```xml
org.opensourcebim
ifcopenshellplugin
0.5.98-SNAPSHOT
org.opensourcebim
pluginbase
1.5.189-SNAPSHOT
src
maven-compiler-plugin
3.10.1
8
```
--------------------------------
### Initialize IfcOpenShell Plugin and Create Render Engine (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Initializes the IfcOpenShell plugin with default settings and creates a render engine for a specific IFC schema. The plugin automatically handles binary downloads. It requires BIMserver's PluginContext and PluginConfiguration.
```java
import org.bimserver.plugins.PluginConfiguration;
import org.bimserver.plugins.PluginContext;
import org.bimserver.plugins.renderengine.RenderEngine;
import org.bimserver.plugins.renderengine.RenderEngineException;
import org.ifcopenshell.IfcOpenShellEnginePlugin;
import org.ifcopenshell.IfcOpenShellEngine;
// Initialize plugin with default settings
IfcOpenShellEnginePlugin plugin = new IfcOpenShellEnginePlugin();
PluginContext pluginContext = ...; // provided by BIMserver
PluginConfiguration systemSettings = ...; // provided by BIMserver
try {
// Plugin downloads binary from S3 if not cached
// Default version: v0.7.0-c7830e9
plugin.init(pluginContext, systemSettings);
// Create render engine for IFC2X3 schema
RenderEngine engine = plugin.createRenderEngine(null, "IFC2X3");
// Initialize engine and process IFC file
engine.init();
// ... use engine to process geometry
engine.close();
} catch (Exception e) {
System.err.println("Plugin initialization failed: " + e.getMessage());
}
```
--------------------------------
### Build IfcOpenShell Plugin (Bash)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Command to build the IfcOpenShell BIMserver plugin using Maven. This command cleans previous build artifacts and packages the project into a deployable format.
```bash
# Build plugin
mvn clean package
```
--------------------------------
### IfcGeomServerClient: Native Process Communication and Geometry Loading (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Demonstrates how to use IfcGeomServerClient to download, configure, and run the IfcOpenShell executable for processing IFC models. It covers loading IFC files, iterating through geometric entities, and retrieving protocol and build information. The client handles native process communication and geometry data retrieval.
```java
import org.ifcopenshell.IfcGeomServerClient;
import org.ifcopenshell.IfcGeomServerClient.ExecutableSource;
import org.ifcopenshell.IfcGeomServerClientEntity;
import java.io.FileInputStream;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
// Download from S3 and cache in user home
String buildVersion = "v0.7.0-c7830e9";
IfcGeomServerClient client = new IfcGeomServerClient(
ExecutableSource.S3,
buildVersion,
Paths.get(System.getProperty("user.home"))
);
try {
// Configure settings before starting process
client.setCalculateQuantities(true);
client.setApplyLayersets(true);
client.setDisableOpeningSubtractions(false);
// Start process and load IFC model
FileInputStream ifcStream = new FileInputStream("project.ifc");
client.loadModel(ifcStream);
// Iterate through all geometric entities
List entities = new ArrayList<>();
while (client.hasNext()) {
IfcGeomServerClientEntity entity = client.getNext();
entities.add(entity);
System.out.println("Entity: " + entity.getType() + " #" + entity.getId());
System.out.println(" GUID: " + entity.getGuid());
System.out.println(" Name: " + entity.getName());
System.out.println(" Vertices: " + entity.getPositions().remaining() / 24 + " doubles");
System.out.println(" Normals: " + entity.getNormals().remaining() / 24 + " doubles");
System.out.println(" Indices: " + entity.getIndices().remaining() / 4 + " ints");
}
System.out.println("Protocol: " + client.getProtocolVersion());
System.out.println("Build date: " + client.getBuildDateTime().getTime());
System.out.println("Platform: " + client.getPlatform());
} catch (Exception e) {
System.err.println("Processing failed: " + e.getMessage());
} finally {
client.close(); // Terminates native process gracefully
}
```
--------------------------------
### Define Plugin System Settings (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Defines configurable parameters for the IfcOpenShell BIMserver plugin, exposed in the BIMserver admin interface. It iterates through parameter definitions to display their names, descriptions, and default values.
```java
import org.bimserver.models.store.ObjectDefinition;
import org.bimserver.models.store.ParameterDefinition;
IfcOpenShellEnginePlugin plugin = new IfcOpenShellEnginePlugin();
ObjectDefinition settings = plugin.getSystemSettingsDefinition();
// Available settings:
// 1. buildversion (String, default: "v0.7.0-c7830e9")
// - Specifies IfcOpenShell binary version/commit
// - Format: "v{version}-{commit-sha}" or tag name
//
// 2. calculatequantities (Boolean, default: true)
// - Calculates volumes and areas for elements
// - Adds ~15% processing time
//
// 3. applylayersets (Boolean, default: true)
// - Splits layered elements (walls, slabs) into separate geometries
// - Can increase processing time 10x for complex models
//
// 4. disableopeningsubtrations (Boolean, default: false)
// - Skips boolean subtraction of openings (doors/windows) from walls
// - Faster processing but less accurate geometry
for (ParameterDefinition param : settings.getParameters()) {
System.out.println(param.getName() + ": " + param.getDescription());
System.out.println(" Default: " + param.getDefaultValue());
}
```
--------------------------------
### Detect Platform and Construct Binary URL (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Automatically detects the operating system platform (e.g., 'win64', 'linux64') and constructs the download URL for the IfcOpenShell binary. It also determines the expected location of the cached binary based on the platform and user home directory.
```java
import org.ifcopenshell.IfcGeomServerClient;
import java.nio.file.Path;
// Get platform identifier
String platform = client.getPlatform();
// Returns: "win32", "win64", "linux32", "linux64", "macos64"
// S3 URL construction pattern:
// https://s3.amazonaws.com/ifcopenshell-builds/IfcGeomServer-{version}-{platform}.zip
String buildVersion = "v0.7.0-c7830e9";
String url = String.format(
"https://s3.amazonaws.com/ifcopenshell-builds/IfcGeomServer-%s-%s.zip",
buildVersion,
platform
);
// Binary cache location (user home directory):
// ~/IfcGeomServer-{version}-{platform}.exe (Windows)
// ~/IfcGeomServer-{version}-{platform} (Linux/Mac)
Path cachedBinary = Paths.get(
System.getProperty("user.home"),
"IfcGeomServer-" + buildVersion + "-" + platform +
(System.getProperty("os.name").toLowerCase().contains("windows") ? ".exe" : "")
);
System.out.println("Binary location: " + cachedBinary);
System.out.println("Download URL: " + url);
```
--------------------------------
### IfcOpenShellEngine: Initialize and Process IFC Geometry
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Initializes the IfcOpenShellEngine to process IFC files for geometry generation. It manages the lifecycle of the IfcGeomServerClient, takes IFC input streams, and provides methods to generate general geometry or specific element geometry with transformation matrices. Errors during processing are caught and logged.
```java
import org.bimserver.plugins.renderengine.RenderEngine;
import org.bimserver.plugins.renderengine.RenderEngineModel;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
Path executablePath = Paths.get("/home/user/.bimserver/IfcGeomServer-v0.7.0-c7830e9-linux64");
IfcOpenShellEngine engine = new IfcOpenShellEngine(
executablePath,
true, // calculateQuantities
true, // applyLayerSets
false // disableOpeningSubtractions
);
try {
engine.init();
// Load IFC file
InputStream ifcStream = new FileInputStream("/path/to/model.ifc");
RenderEngineModel model = engine.openModel(ifcStream);
// Generate all geometry
model.generateGeneralGeometry();
// Access specific element geometry
long expressId = 12345; // IFC entity ID
RenderEngineInstance instance = model.getInstanceFromExpressId(expressId);
RenderEngineGeometry geometry = instance.generateGeometry();
// Get transformation matrix (16 doubles in column-major order)
double[] matrix = instance.getTransformationMatrix();
model.close();
engine.close();
} catch (Exception e) {
System.err.println("Geometry generation failed: " + e.getMessage());
e.printStackTrace();
}
```
--------------------------------
### Wrap IFC Entity Instance for Geometry Retrieval (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Wraps an IFC entity instance from IfcGeomServerClient to implement BIMserver's RenderEngineInstance interface. It retrieves transformation matrices, generates geometry data (vertices, normals, indices, colors), and accesses additional metadata like volume.
```java
import org.ifcopenshell.IfcOpenShellEntityInstance;
import org.ifcopenshell.IfcGeomServerClientEntity;
import org.bimserver.plugins.renderengine.RenderEngineGeometry;
import com.fasterxml.jackson.databind.node.ObjectNode;
// Entity from IfcGeomServerClient
IfcGeomServerClientEntity entity = client.getNext();
IfcOpenShellEntityInstance instance = new IfcOpenShellEntityInstance(entity);
// Get transformation matrix
double[] transform = instance.getTransformationMatrix();
// Returns 16 doubles: [m00, m10, m20, m30, m01, m11, m21, m31, ...]
// Generate geometry object
RenderEngineGeometry geometry = instance.generateGeometry();
if (geometry != null) {
ByteBuffer vertices = geometry.getVertices();
ByteBuffer normals = geometry.getNormals();
ByteBuffer indices = geometry.getIndices();
ByteBuffer colors = geometry.getColors();
ByteBuffer materialIndices = geometry.getMaterialIndices();
// Process geometry data for rendering
System.out.println("Vertex count: " + vertices.remaining() / 24);
System.out.println("Triangle count: " + indices.remaining() / 12);
}
// Access additional metadata (volumes, areas, material info)
try {
ObjectNode additionalData = instance.getAdditionalData();
if (additionalData != null && additionalData.has("volume")) {
double volume = additionalData.get("volume").asDouble();
System.out.println("Volume: " + volume + " cubic meters");
}
} catch (Exception e) {
System.err.println("Additional data unavailable");
}
```
--------------------------------
### IfcOpenShellModel: Load and Manage IFC Model Geometry
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Manages IFC model loading and geometry generation using IfcOpenShellModel. It interfaces with IfcGeomServerClient, processes IFC streams to generate geometry for all entities, and allows retrieval of individual entity instances by their express IDs, including their transformation matrices. The model is closed in a finally block to ensure resource cleanup.
```java
import org.ifcopenshell.IfcGeomServerClient;
import org.ifcopenshell.IfcOpenShellModel;
import org.bimserver.plugins.renderengine.RenderEngineInstance;
import java.io.FileInputStream;
import java.util.Map;
import java.util.HashMap;
// Initialize client and load model
IfcGeomServerClient client = new IfcGeomServerClient(executablePath);
FileInputStream ifcStream = new FileInputStream("building.ifc");
long fileSize = new File("building.ifc").length();
IfcOpenShellModel model = new IfcOpenShellModel(client, ifcStream, fileSize);
try {
// Generate geometry for all entities
model.generateGeneralGeometry();
// Logs: "Took X seconds to obtain representations for Y entities"
// Retrieve entity by IFC express ID
Map processedEntities = new HashMap<>();
for (long expressId : entityIds) {
try {
RenderEngineInstance instance = model.getInstanceFromExpressId(expressId);
RenderEngineGeometry geom = instance.generateGeometry();
processedEntities.put(expressId, new EntityData(
geom.getIndices(),
geom.getVertices(),
geom.getNormals(),
instance.getTransformationMatrix()
));
} catch (EntityNotFoundException e) {
System.err.println("Entity " + expressId + " has no geometry");
}
}
} finally {
model.close();
}
```
--------------------------------
### IfcGeomServerClientEntity: Accessing IFC Geometric Entity Data (Java)
Source: https://context7.com/opensourcebim/ifcopenshell-bimserver-plugin/llms.txt
Details how to access and interpret the geometric and extended data of an IFC entity retrieved from IfcGeomServerClient. It covers extracting basic information, transformation matrices, mesh data (positions, normals, indices), color, and material information, as well as parsing extended JSON data.
```java
import org.ifcopenshell.IfcGeomServerClientEntity;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
// Entity retrieved from IfcGeomServerClient.getNext()
IfcGeomServerClientEntity entity = client.getNext();
// Basic entity information
long ifcId = entity.getId(); // IFC EXPRESS ID
String guid = entity.getGuid(); // IFC GlobalId
String name = entity.getName(); // Entity name/label
String type = entity.getType(); // IFC type (IfcWall, IfcWindow, etc.)
long parentId = entity.getParentId(); // Parent element ID
int repId = entity.getRepId(); // Representation ID
// Transformation matrix (16 doubles, column-major, pre-oriented for BIMserver)
double[] matrix = entity.getMatrix();
// Geometry data as ByteBuffers (little-endian)
ByteBuffer positions = entity.getPositions(); // 3 doubles per vertex (x,y,z)
ByteBuffer normals = entity.getNormals(); // 3 doubles per vertex
ByteBuffer indices = entity.getIndices(); // 1 int per index
ByteBuffer colors = entity.getColors(); // RGBA color data
ByteBuffer materialIndices = entity.getMaterialIndices(); // Material mapping
// Convert positions to double array
positions.order(ByteOrder.LITTLE_ENDIAN);
double[] vertices = new double[positions.remaining() / 8];
positions.asDoubleBuffer().get(vertices);
// Convert indices to int array
indices.order(ByteOrder.LITTLE_ENDIAN);
int[] triangleIndices = new int[indices.remaining() / 4];
indices.asIntBuffer().get(triangleIndices);
// Extended data (JSON) - quantities, properties, etc.
try {
ObjectNode extendedData = entity.getAllExtendedData();
if (extendedData != null) {
System.out.println("Extended data: " + extendedData.toString());
}
} catch (Exception e) {
System.err.println("No extended data available");
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.