Blockly Workspace Source Code
Reference data for every workspace template shipped with PIComposer
About This Page
This page hosts the full source for each Blockly workspace template referenced on the examples page. Each entry is fully self-contained: metadata (id, type, schema, description). Use the table of contents below to jump to any template.
Table of Contents
- partial-model-to-part21 (GENERICPROCEDURE)
- test-loop-function (GENERICPROCEDURE)
- IfcProduct-translate (INSTANCETRANSFORM)
- wall from indexed poly curve (PROCEDURALENTITY)
- ifc-platonic-cube (PROCEDURALENTITY)
- ifc-platonic-tetrahedron (PROCEDURALENTITY)
- IfcProduct-y-axis-rotation (INSTANCETRANSFORM)
- ifc-brep-box (PROCEDURALENTITY)
- poly curve profile (PROCEDURALENTITY)
- Pset_BeamCommon (PROCEDURALENTITY)
- test-user-defined-entity (USERDEFINEDENTITY)
- procedural wall (PROCEDURALENTITY)
- ap214-brep-box (PROCEDURALMODEL)
- ifc-platonic-octahedron (PROCEDURALENTITY)
- circular wall (PROCEDURALENTITY)
- 5-storey (2m height) (SPATIAL)
- 2-storey (2m height) (SPATIAL)
- Pset_SpaceCommon (PROPERTYSET)
- procedural-table (PROCEDURALENTITY)
- Qto_WallBaseQuantities (QUANTITYSET)
- Trapezoidal Prism (PROCEDURALENTITY)
- procedural-wall-door (PROCEDURALENTITY)
- procedural-shelf (PROCEDURALENTITY)
- boolean-substraction (INSTANCE)
- data-transfer (MODELTRANSFORM)
- procedural rebar (PROCEDURALENTITY)
- procedural house (PROCEDURALMODEL)
- half-circle swept disc (PROCEDURALENTITY)
- ifcextruded-solid (PROCEDURALENTITY)
- IfcProduct-z-axis-rotation (INSTANCETRANSFORM)
- export-model (GENERICPROCEDURE)
- IfcProduct-x-axis-rotation (INSTANCETRANSFORM)
- rotation-around-axis (INSTANCETRANSFORM)
- ifc-platonic-dodecahedron (PROCEDURALENTITY)
- ifc-platonic-icosahedron (PROCEDURALENTITY)
- wall-along-indexed-poly-curve (MODELTRANSFORM)
- weekday enum (ENUM)
partial-model-to-part21
export part of model to a part21 file
| Template ID | 01zFoeQhHD2Avc9aTaaaDJ |
|---|---|
| Type | PIBLOCKLYGENERICPROCEDURETEMPLATE (genericprocedure) |
| Schema | 14 (ifc4x3) |
| Input / Output | N/A |
| Generated Dart | procedure01zFoeQhHD2Avc9aTaaaDJ.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure01zFoeQhHD2Avc9aTaaaDJ.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 01zFoeQhHD2Avc9aTaaaDJ ==========
//========== type: generic procedure ==========
//========== input/output: N/A ==========
//========== name: partial-model-to-part21 ==========
//========== description: export part of model of part21 ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
bool _retVal = true;
Dictionary _input = {};
var _mappedIds;
var _bool;
PIStore _store = PIStore.nullStore();
var _ifcprojectInstanceId;
var _model;
var _ifcproject;
var _ostream;
var _processedShapeIds;
var _targetTypeId;
var _relAggTypeId;
var _projectId;
var _modelId;
var _typeName;
var _fileName;
var _project;
var _header;
/// end variable declarations ======================
dynamic _genericProcedure() {
//this procedure export a given type in a ifc model to part21 file
//Multiple functions are defined, include some that are recursive
//Since there are recursive calls, function should avoid using global variable as local values
//Parameter convention:
//1. prefix function parameter name with p_
//2. use parameter as local function variable, and prefix it with l_
//3. function parameter are dynamics, initialize with any value
//4. be careful with global variables inside recursive functions, make sure they are not being modified outside of the recursive function. Recommand using local variable.
_templateInput = {
"project_id": "STRING",
"model_id": "STRING",
"type_name": "STRING",
"file_name": "STRING"
};
_projectId = getDictionaryValue(_input, "project_id") ?? "";
_modelId = getDictionaryValue(_input, "model_id") ?? "";
_typeName = getDictionaryValue(_input, "type_name") ?? "";
_fileName = getDictionaryValue(_input, "file_name") ?? "";
//validate input
for (var inputValue in [_projectId, _modelId, _typeName, _fileName]) {
if (inputValue.isEmpty) {
//all input must be non-empty
logMsg(LogType.error, "invalid input");
return false;
}
}
_project = _store.getProject(_projectId);
if (NullChecker.isNull(_project)) {
logMsg(LogType.error, "project not found");
return false;
}
//load the project...
_bool = _project.activateProject();
_model = _project.getModel(_modelId);
if (NullChecker.isNull(_model) || !(_model as IModel).isIfc) {
logMsg(LogType.error, "model not found or is not ifc");
return false;
}
_ifcproject = _model.getIfcProject();
if (NullChecker.isNull(_ifcproject)) {
logMsg(LogType.error, "empty model, ifcproject not found");
return false;
}
//global constances and variables ==========
_ifcprojectInstanceId = _ifcproject.instanceId;
_relAggTypeId = toTypeId('IfcRelAggregates');
_targetTypeId = toTypeId(_typeName);
//if list, initialize as empty list.
_processedShapeIds = [];
_mappedIds = [];
//end global constances and variables ==========
_ostream = PIFileStream();
_bool = _ostream.open(_fileName);
if (!_bool) {
logMsg(LogType.error, "could not open file for output. make sure folder exists.");
return false;
}
_header = _model.getHeader();
//never, but we check
if (NullChecker.isNull(_header)) {
logMsg(LogType.error, "model header is null");
return false;
}
//Write the header section. This also writes the ISO10303 document start
_bool = _ostream.writeHeaderInstance(_header, ExportFormat.values[0]);
//write a separation line between end of header and start of DATA section
_bool = _ostream.writeString('\n');
_bool = _ostream.writeString('DATA;\n');
//write data section
//the two functions: _printSpatialHierachy and _printBuiltElement
//will recursively prints all products including:
//spatial relations, placement, and shapes
_printModelContext();
_printSpatialHierarchy(_ifcproject);
_printUnprocessedMappedShape(0, 0);
//write data section end
_bool = _ostream.writeString('ENDSEC;\n');
//write iso10303 end
_bool = _ostream.writeString('END-ISO-10303-21;\n');
_bool = _ostream.flush();
_bool = _ostream.close();
return _retVal;
}
void _printInstance(p_instance) {
//for parameter, use the prefix p_
if (NullChecker.isNull(p_instance)) {
return ;
}
for (var decomposition in p_instance.getDecomposition(includeAllReferences: false)) {
if (decomposition.isInstanceReference) {
continue;
}
_bool = _ostream.writeInstance(decomposition, ExportFormat.values[0]);
//log failure if occure
if (!_bool) {
logMsg(LogType.error, "instance write failed");
}
}
//decomposition does not include self
_bool = _ostream.writeInstance(p_instance, ExportFormat.values[0]);
}
void _printModelContext() {
//referenceType are global and shared within the model.
//they should be immutable for the life time of a model
for (var referenceType in ["IfcUnitAssignment", "IfcRepresentationContext", "IfcPerson", "IfcOrganization", "IfcPersonAndOrganization", "IfcApplication", "IfcOwnerHistory"]) {
//note we set include subtypes = true because we want all instances that are subtypes of IfcRepresentationContext.
for (var refInstance in _model.getInstancesByType(typeName: referenceType, includeSubType : true)) {
_printInstance(refInstance);
}
}
}
void _printPlacement(p_placedProduct, l_placement) {
//l_placement should be a composed instance referenced by p_placedProduct
l_placement = p_placedProduct.getInstance(attName: 'ObjectPlacement', resolveRef: true);
if (NullChecker.isNull(l_placement)) {
return ;
}
_printInstance(l_placement);
}
void _printShape(p_product, l_repType, l_source, l_mappedRep) {
//note: l_repType, l_source, l_mappedRep are parameters used as a local variable
//caller could initialize any values, but should not be used anywhere other than in this function
for (var shape in _model.getShapes(p_product)) {
//output the shape
_printInstance(shape);
//note: the return value is an option,we use a utility function to get the string value
l_repType = shape.getString(attName: 'RepresentationType').match(() => "", (v) => v);
l_repType = l_repType.toLowerCase();
//if shape is mappedrepresentation, we will recorded the shape id
//and export the mapped shape at the end
if (l_repType == "mappedrepresentation") {
//we assume the shape composes its dependency, so resolve reference is not set
for (var repItem in shape.getInstances(attName: 'items')) {
l_source = repItem.getInstance(attName: 'MappingSource');
l_mappedRep = l_source.getInstance(attName: 'MappedRepresentation');
//make sure no duplicate
if (NullChecker.isNull(l_mappedRep) || -1 > l_mappedRep.instanceId.indexOf(_mappedIds)) {
continue;
}
_mappedIds.add(l_mappedRep.instanceId);
}
} else {
//add the shape to the processed list
_processedShapeIds.add(shape.instanceId);
}
}
}
void _printUnprocessedMappedShape(l_handle, l_instance) {
for (var mappedId in _mappedIds) {
//for all the mapped representation that is not exported, we will write them here
if (-1 > _processedShapeIds.indexOf(mappedId)) {
continue;
}
l_handle = InstanceHandle.fromJson({
"instanceId": mappedId,
kInstanceTypeKey: "IfcShapeRepresentation"
});
//get the unprocessed shape that was mapped
l_instance = _model.getInstance(l_handle);
if (NullChecker.isNull(l_instance)) {
//something is not right, so we log it
logMsg(LogType.warning, "mapped shape not found");
continue;
}
//notice we call _printInstance not _printShape
_printInstance(l_instance);
}
}
void _printSpatialHierarchy(p_parent) {
//note: this is a recursive function, avoid global variables
if (_ifcprojectInstanceId == p_parent.instanceId) {
_bool = _ostream.writeInstance(_ifcproject, ExportFormat.values[0]);
} else {
_printInstance(p_parent);
_printPlacement(p_parent, 0);
//note: we just set some random values for local variables such as l_item
//we have to call _printShape with 4 arguments.
_printShape(p_parent, 0, 0, 0);
}
//get all relations that define p_parent as spatial parent
for (var relation in _model.getRelatingSpatialRelations(p_parent)) {
if (_relAggTypeId == relation.typeId) {
_bool = _ostream.writeInstance(relation, ExportFormat.values[0]);
//related is the actual instance, not a reference since resolve reference = true
for (var related in relation.getInstances(attName: 'RelatedObjects', resolveRef: true)) {
//recursively call itself...
_printSpatialHierarchy(related);
}
} else {
//process contained in spatial relation
_printSpatialBuiltElementChildren(relation, 0);
}
}
}
void _printSpatialBuiltElementChildren(p_relcontained, l_exportingElements) {
//set l_targets as a list, so we could add as we loop
l_exportingElements = [];
for (var btElement in p_relcontained.getInstances(attName: 'RelatedElements', resolveRef: true)) {
if (_targetTypeId == btElement.typeId) {
l_exportingElements.add(btElement);
}
}
if (l_exportingElements.isEmpty) {
return ;
}
//empty the RelatedElements attribute for the relcontained relation.
//It will only contain a subset from before when done
_bool = p_relcontained.setAttribute(attName: "RelatedElements", []);
for (var element in l_exportingElements) {
//we could just write the built element because resolve reference = true when calling getInstances
_printBuiltElement(element);
//add the built element to the related list
_bool = p_relcontained.addInstanceRef(element, attName: "RelatedElements", addInverse: true);
}
//now write the relcontained relation
_bool = _ostream.writeInstance(p_relcontained, ExportFormat.values[0]);
}
void _printBuiltElement(p_builtElement) {
_printInstance(p_builtElement);
_printPlacement(p_builtElement, 0);
_printShape(p_builtElement, 0, 0, 0);
//output all the relations
for (var relation in _model.getRelatingSpatialRelations(p_builtElement)) {
_bool = _ostream.writeInstance(relation, ExportFormat.values[0]);
}
//output all the children
for (var child in _model.getSpatialChildren(p_builtElement)) {
//recursive call...
_printBuiltElement(child);
}
}
/// procedure01zFoeQhHD2Avc9aTaaaDJ =============
bool procedure01zFoeQhHD2Avc9aTaaaDJ(PIStore iStore, Dictionary iInput) {
try {
_store = iStore;
_input = iInput;
return _genericProcedure() as bool;
} catch(e) {
logMsg(LogType.error, 'error in procedure: ${e.toString()}');
}
return false;
}
test-loop-function
loop and function test
| Template ID | 05YKXDsJXCtvSWQ2VDh94L |
|---|---|
| Type | PIBLOCKLYGENERICPROCEDURETEMPLATE (genericprocedure) |
| Schema | 14 (ifc4x3) |
| Input / Output | N/A |
| Generated Dart | procedure05YKXDsJXCtvSWQ2VDh94L.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure05YKXDsJXCtvSWQ2VDh94L.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 05YKXDsJXCtvSWQ2VDh94L ==========
//========== type: generic procedure ==========
//========== input/output: N/A ==========
//========== name: test-loop-function ==========
//========== description: loop and function test ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
bool _retVal = true;
Dictionary _input = {};
var _count;
PIStore _store = PIStore.nullStore();
var _x;
/// end variable declarations ======================
void test1(p_x, l_y) {
logMsg(LogType.info, "call test1 with parameter: ${p_x}");
l_y = "hello world, I am local";
logMsg(LogType.info, "call test1 with l_y: ${l_y}");
}
dynamic _genericProcedure() {
for (int count = 0; count < 10; count++) {
logMsg(LogType.info, "loop 1");
}
_count = 20;
num i_inc = (_count).abs().toDouble();
if (1 > _count) {
i_inc = -i_inc;
}
for (num i = 1; i_inc >= 0 ? i <= _count : i >= _count; i += i_inc) {
logMsg(LogType.info, "loop 1.5: i = ${i}");
}
for (var i = 1; i <= 10; i++) {
logMsg(LogType.info, "loop 2: i = ${i}");
}
for (var j in [0, 1, 2]) {
logMsg(LogType.info, "loop 3: j = ${j}");
}
//before we use _x (a dynamic global) we must set its value
_x = 0;
while (_x < 20) {
_x = _x + 1;
logMsg(LogType.info, "loop 4: _x = ${_x} ");
}
_x = 0;
while (!(_x == 20)) {
_x = _x + 1;
logMsg(LogType.info, "loop 4: _x = ${_x}");
}
test1(_x, 0);
logMsg(LogType.error, "procedure ended");
return _retVal;
}
/// procedure05YKXDsJXCtvSWQ2VDh94L =============
bool procedure05YKXDsJXCtvSWQ2VDh94L(PIStore iStore, Dictionary iInput) {
try {
_store = iStore;
_input = iInput;
return _genericProcedure() as bool;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in procedure id = 05YKXDsJXCtvSWQ2VDh94L: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return false;
}
IfcProduct-translate
translate a product local place by the user input vector
| Template ID | 0apg8fSn94IONLhEK9Pape |
|---|---|
| Type | PIBLOCKLYINSTANCETRANSFORMTEMPLATE (instancetransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcproduct |
| Generated Dart | procedure0apg8fSn94IONLhEK9Pape.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0apg8fSn94IONLhEK9Pape.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0apg8fSn94IONLhEK9Pape ==========
//========== type: instance transform ==========
//========== input/output: ifcproduct ==========
//========== name: IfcProduct-translate ==========
//========== description: translate a product by the user input vector ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
List _path = [];
var _location;
var _doubleX;
var _doubleY;
var _doubleZ;
var _placement;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//assumptions:
//1. input is an ifcproduct
//2. objectplacement attribute exists and is a IfcLocalPlacement
//=============
//define user input for template:
_templateInput = {
"x": "REAL",
"y": "REAL",
"z": "REAL"
};
//Note: this assume we are using IfcLocalPlacement
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D", "Location", "Coordinates"];
//If it is a PIComposer model, placement is a composed instance, no need to resolve reference
//But for other models such as reference models, it should be set to true.
_location = _instance.getAttributeByPathAsDynamic(_path, resolveRef: true);
//sanity check to make sure the returns is list of doubles
//If placement object is not a local placement or does not exist, we will return
if (_location is! List<double>) {
return _instance;
}
//retrieve user input for translation
_doubleX = getDictionaryValue(_input, "x") ?? 0;
_doubleY = getDictionaryValue(_input, "y") ?? 0;
_doubleZ = getDictionaryValue(_input, "z") ?? 0;
//add the translation to original location
if (_location.isEmpty) {
_location = [_doubleX, _doubleY, _doubleZ];
} else {
if (_location.length != 3) {
return _instance;
}
//add the translate to original location
_location = [_location[0] + _doubleX, _location[1] + _doubleY, _location[2] + _doubleZ];
}
//set attribute with path returns the updated placement instance, save it if not null.
_placement = _instance.setAttributeByPath(_path, _location);
//save the changes
if (!NullChecker.isNull(_placement)) {
_bool = _model.saveInstance(_placement);
}
//get the location coordinates of a product object placement
return _instance;
}
/// procedure0apg8fSn94IONLhEK9Pape =============
IInstance procedure0apg8fSn94IONLhEK9Pape(PIModel iModel, IInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in instance transform: ${e.toString()}');
}
return PIInstance.nullInstance();
}
wall from indexed poly curve
create wall from index poly curve as profile.
| Template ID | 0H1Nh1zlXD7v871tZBuXTG |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcwall |
| Generated Dart | procedure0H1Nh1zlXD7v871tZBuXTG.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0H1Nh1zlXD7v871tZBuXTG.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0H1Nh1zlXD7v871tZBuXTG ==========
//========== type: procedure entity ==========
//========== input/output: ifcwall ==========
//========== name: wall from indexed poly curve ==========
//========== description: create wall from index poly curve as profile ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _height;
var _coordlist;
var _segmentIndices;
var _context;
var _segments;
var _extrude;
var _shape;
var _segSelect;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//this is a utility procedure that is supposed to be used by other procedures
_templateInput = {
"height": "REAL",
"coord_list": "REALS2",
"segment_indices": "INTEGERS2"
};
_height = getDictionaryValue(_input, "height") ?? 2000;
_coordlist = getDictionaryValue(_input, "coord_list") ?? [];
_segmentIndices = getDictionaryValue(_input, "segment_indices") ?? [];
//validate data
if (_height < 500) {
_height = 500;
}
if (_coordlist.isEmpty || _coordlist.length != _segmentIndices.length) {
logMsg(LogType.error, "invalid input");
return _instance;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "could not find 3d geoconetxt");
return _instance;
}
//create segment select list from segement indices
//before we can add segment to _segments, we much initialize it as a list
_segments = [];
for (var segment in _segmentIndices) {
if (segment.length == 3) {
_segSelect = _model.createSelect(typeName: "IfcSegmentIndexSelect", selectedTypeName: "IfcArcIndex");
}else if (segment.length == 2) {
_segSelect = _model.createSelect(typeName: "IfcSegmentIndexSelect", selectedTypeName: "IfcLineIndex");
}
_segments.add(_segSelect);
_bool = _segSelect.setValue(segment);
if (!_bool) {
logMsg(LogType.error, "error create segment in procedure 0H1Nh1zlXD7v871tZBuXTG");
//note: _instance is still null
return _instance;
}
}
_extrude = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcExtrudedAreaSolid",
"SweptArea": {
kInstanceTypeKey: "IfcArbitraryClosedProfileDef",
"ProfileType": "AREA",
"OuterCurve": {
kInstanceTypeKey: "IfcIndexedPolyCurve",
"Points": {
kInstanceTypeKey: "IfcCartesianPointList2D",
//list of 2d coordinates
"CoordList": _coordlist
},
//list of selects
"Segments": _segments
}
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
_shape = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcShapeRepresentation",
"ContextOfItems": _context.instanceHandle,
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid"
});
_shape = _model.addRepItemToShape(_shape, _extrude, PIInstance.nullInstance());
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "shape creation failed");
return _instance;
}
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcWall",
"name": "wall",
"description": "wall from index poly curve"
});
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "slab creation failed");
return _instance;
}
_shape = _model.addShape(_instance, _shape);
return _instance;
}
/// procedure0H1Nh1zlXD7v871tZBuXTG =============
IInstance procedure0H1Nh1zlXD7v871tZBuXTG(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in entity procedure id = 0H1Nh1zlXD7v871tZBuXTG: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
ifc-platonic-cube
the cubic platonic solid
| Template ID | 0mM5J34jX4kgenOvMG2zWq |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure0mM5J34jX4kgenOvMG2zWq.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0mM5J34jX4kgenOvMG2zWq.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0mM5J34jX4kgenOvMG2zWq ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-platonic-cube ==========
//========== description: the cubic platonic solid ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _length;
var _context;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _pt6;
var _pt7;
var _bottom;
var _top;
var _front;
var _back;
var _left;
var _right;
var _brep;
var _bool;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//set up user input
_templateInput = {
"edge_length": "REAL"
};
//retrieve user input and put it in the _length variable
_length = getDictionaryValue(_input, "edge_length") ?? 1000;
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "error get geo context");
return _instance;
}
//create the shape
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "ifcShapeRepresentation",
"ContextOfItems": {
kReferenceKey: _context.instanceHandle
},
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep"
});
_pt0 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, 0, 0]
});
_pt1 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_length, 0, 0]
});
_pt2 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_length, _length, 0]
});
_pt3 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, _length, 0]
});
_pt4 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, 0, _length]
});
_pt5 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_length, 0, _length]
});
_pt6 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_length, _length, _length]
});
_pt7 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, _length, _length]
});
_bottom = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
//polyloop references the points
"Polygon": [_pt0.instanceHandle, _pt3.instanceHandle, _pt2.instanceHandle, _pt1.instanceHandle]
},
"Orientation": true
}]
});
_top = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt4.instanceHandle, _pt5.instanceHandle, _pt6.instanceHandle, _pt7.instanceHandle]
},
"Orientation": true
}]
});
_front = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt5.instanceHandle, _pt4.instanceHandle]
},
"Orientation": true
}]
});
_back = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt7.instanceHandle, _pt6.instanceHandle, _pt2.instanceHandle]
},
"Orientation": true
}]
});
_left = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt4.instanceHandle, _pt7.instanceHandle, _pt3.instanceHandle]
},
"Orientation": true
}]
});
_right = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt2.instanceHandle, _pt6.instanceHandle, _pt5.instanceHandle]
},
"Orientation": true
}]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
//shell is composed in brep
"Outer": {
"@type": "IfcClosedShell",
//faces composed in closed shell
"CfsFaces": [_bottom, _top, _front, _back, _left, _right]
}
});
//store the points in _instance
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5, _pt6, _pt7]);
_style = (_model as IIfcModel).createStyledItem([0, 0.9, 0.9]);
_instance = _model.addRepItemToShape(_instance, _brep, _style);
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "error adding brep to shape");
}
return _instance;
}
/// procedure0mM5J34jX4kgenOvMG2zWq =============
IInstance procedure0mM5J34jX4kgenOvMG2zWq(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
ifc-platonic-tetrahedron
platonic brep tetrahedron
| Template ID | 0n9KilNqH9bhYh87aas9mA |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure0n9KilNqH9bhYh87aas9mA.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0n9KilNqH9bhYh87aas9mA.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0n9KilNqH9bhYh87aas9mA ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-platonic-tetrahedron ==========
//========== description: a ifc brep tetrahedron ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _len;
var _context;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _bool;
var _loop;
var _faceBound;
var _face0;
var _face1;
var _face2;
var _face3;
var _shell;
var _brep;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//define user input
_templateInput = {
"edge_length": "REAL"
};
//get the value of user input
_len = getDictionaryValue(_input, "edge_length") ?? 1000;
_len = 0.5 * _len;
_context = (_model as IIfcModel).getBody3dGeometricContext();
//no 3d context, returns a null instance
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "could not find model context");
return _instance;
}
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"ContextOfItems": _context.instanceHandle,
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep"
});
//create the vertex points
_pt0 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"Coordinates": [_len, _len, _len]
});
_pt1 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"Coordinates": [-1 * _len, _len, -1 * _len]
});
_pt2 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"Coordinates": [_len, -1 * _len, -1 * _len]
});
_pt3 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"Coordinates": [-1 * _len, -1 * _len, _len]
});
//add points to instance as composites. They are contained in instance
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3]);
_loop = _model.createInstanceFromDictionary({
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt2.instanceHandle]
});
//note: _loop is composed
_faceBound = _model.createInstanceFromDictionary({
"@type": "IfcFaceOuterBound",
"orientation": true,
"Bound": _loop
});
//note: _faceBound is composed
_face0 = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [_faceBound]
});
_loop = _model.createInstanceFromDictionary({
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt3.instanceHandle, _pt2.instanceHandle]
});
_faceBound = _model.createInstanceFromDictionary({
"@type": "IfcFaceOuterBound",
"orientation": true,
"Bound": _loop
});
_face1 = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [_faceBound]
});
_loop = _model.createInstanceFromDictionary({
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt2.instanceHandle, _pt3.instanceHandle]
});
_faceBound = _model.createInstanceFromDictionary({
"@type": "IfcFaceOuterBound",
"orientation": true,
"Bound": _loop
});
_face2 = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [_faceBound]
});
_loop = _model.createInstanceFromDictionary({
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt3.instanceHandle, _pt1.instanceHandle]
});
_faceBound = _model.createInstanceFromDictionary({
"@type": "IfcFaceOuterBound",
"orientation": true,
"Bound": _loop
});
_face3 = _model.createInstanceFromDictionary({
"@type": "IfcFace",
"Bounds": [_faceBound]
});
_shell = _model.createInstanceFromDictionary({
"@type": "IfcClosedShell",
"CfsFaces": [_face0, _face1, _face2, _face3]
});
//note: shell, faces and facebounds and loops are heiarchically composed by brep.
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
"outer": _shell
});
_style = (_model as IIfcModel).createStyledItem([0.596, 0.8352, 0.905]);
_instance = _model.addRepItemToShape(_instance, _brep, _style);
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "error adding brep to shape");
}
return _instance;
}
/// procedure0n9KilNqH9bhYh87aas9mA =============
IInstance procedure0n9KilNqH9bhYh87aas9mA(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
IfcProduct-y-axis-rotation
rotate a Product placement around the y-axis (angle in degrees)
| Template ID | 0OTew485H5FhEnnB8acr1m |
|---|---|
| Type | PIBLOCKLYINSTANCETRANSFORMTEMPLATE (instancetransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcproduct |
| Generated Dart | procedure0OTew485H5FhEnnB8acr1m.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0OTew485H5FhEnnB8acr1m.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0OTew485H5FhEnnB8acr1m ==========
//========== type: instance transform ==========
//========== input/output: ifcproduct ==========
//========== name: IfcProduct-y-axis-rotation ==========
//========== description: rotate an IfcProduct around the y-axis, angle in degrees ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
var _angle;
PIIfcModel _model = PIIfcModel.nullModel();
var _inputMatrix;
var _path;
var _axis2Placement;
var _resultMatrix;
var _inst;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
_templateInput = {
"rotation_degree": "REAL"
};
_angle = getDictionaryValue(_input, "rotation_degree") ?? 0;
_angle = (_angle * Math.pi) / 180.0;
_inputMatrix = Matrix4.rotationY(_angle);
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D"];
//If it is a PIComposer model, placement is a composed instance, no need to resolve reference
//But for other models such as reference models, it should be set to true.
_axis2Placement = _instance.getAttributeByPathAsDynamic(_path, resolveRef: true);
if (NullChecker.isNull(_axis2Placement)) {
_axis2Placement = _model.createInstance(typeName: 'IfcAxis2Placement3D');
}
_resultMatrix = axis2Placement3dToMatrix(_axis2Placement);
_inputMatrix.multiply(_resultMatrix);
_axis2Placement = _model.axis2Placement3dFromMatrix(_inputMatrix);
_inst = _instance.setAttributeByPath(_path, _axis2Placement);
_bool = _model.saveInstance(_inst);
return _instance;
}
/// procedure0OTew485H5FhEnnB8acr1m =============
IInstance procedure0OTew485H5FhEnnB8acr1m(PIModel iModel, IInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in instance transform id = 0OTew485H5FhEnnB8acr1m: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
ifc-brep-box
ifc brep rectangular box
| Template ID | 0Rt1MuvUj3qxGR8COtWTrD |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure0Rt1MuvUj3qxGR8COtWTrD.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0Rt1MuvUj3qxGR8COtWTrD.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0Rt1MuvUj3qxGR8COtWTrD ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-brep-box ==========
//========== description: ifc brep rectangular box ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _x;
var _y;
var _z;
var _context;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _pt6;
var _pt7;
var _brep;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//define user input.
_templateInput = {
"x": "REAL",
"y": "REAL",
"z": "REAL"
};
_x = getDictionaryValue(_input, "x") ?? 300;
_y = getDictionaryValue(_input, "y") ?? 200;
_z = getDictionaryValue(_input, "z") ?? 2500;
//make context exists
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "could not find model context");
return _instance;
}
//create the vertex points
//each point will be shared amount many faces of the brep
//points will be added to the shape as composites.
_pt0 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0, 0, 0]
});
_pt1 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_x, 0, 0]
});
_pt2 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_x, _y, 0]
});
_pt3 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0, _y, 0]
});
_pt4 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0, 0, _z]
});
_pt5 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_x, 0, _z]
});
_pt6 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_x, _y, _z]
});
_pt7 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0, _y, _z]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
"outer": {
"@type": "IfcClosedShell",
"CfsFaces": [{
//top face:
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt4.instanceHandle, _pt5.instanceHandle, _pt6.instanceHandle, _pt7.instanceHandle]
}
}]
}, {
//left face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt4.instanceHandle, _pt7.instanceHandle, _pt3.instanceHandle]
}
}]
}, {
//back face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt7.instanceHandle, _pt6.instanceHandle, _pt2.instanceHandle]
}
}]
}, {
//front face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt5.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
//right face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt2.instanceHandle, _pt6.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
//bottom face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt3.instanceHandle, _pt2.instanceHandle, _pt1.instanceHandle]
}
}]
}]
}
});
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep",
"ContextOfItems": _context.instanceHandle
});
//add to points to shape as composites.
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5, _pt6, _pt7]);
//add the brep to shape. Note: shape is saved. Style object is optional
_instance = _model.addRepItemToShape(_instance, _brep, PIInstance.nullInstance());
return _instance;
}
/// procedure0Rt1MuvUj3qxGR8COtWTrD =============
IInstance procedure0Rt1MuvUj3qxGR8COtWTrD(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
poly curve profile
poly curve profile with one arc.
| Template ID | 0rtN8DIoP3ePxd7JrWO8BF |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcindexedpolycurve |
| Generated Dart | procedure0rtN8DIoP3ePxd7JrWO8BF.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0rtN8DIoP3ePxd7JrWO8BF.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0rtN8DIoP3ePxd7JrWO8BF ==========
//========== type: procedure entity ==========
//========== input/output: ifcindexedpolycurve ==========
//========== name: poly curve profile ==========
//========== description: poly curve profile with one arc ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _length;
var _width;
var _r;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//length: x dimension
//width: y dimension
//we will add an arc with centered at the mid point for the rectangle
_templateInput = {
"length": "REAL",
"width": "REAL"
};
_length = getDictionaryValue(_input, "length") ?? 500;
_width = getDictionaryValue(_input, "width") ?? 500;
//validate data, we require dimensions to be >= 500 mm
if (_length < 500) {
_length = 500;
}
if (_width < 500) {
_width = 500;
}
//radius from center of rect(length, width) to (x/2,0)
_r = 0.5 * Math.sqrt(_length * _length + _width * _width);
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcIndexedPolyCurve",
"points": {
kInstanceTypeKey: "IfcCartesianPointList2D",
"CoordList": [[-0.5 * _length, 0], [0, 0.5 * _width - _r], [0.5 * _length, 0], [0.5 * _length, _width], [-0.5 * _length, _width]]
},
"Segments": [{
"IfcArcIndex": [1, 2, 3]
}, {
"IfcLineIndex": [3, 4]
}, {
"IfcLineIndex": [4, 5]
}, {
"IfcLineIndex": [5, 1]
}],
"SelfIntersect": false
});
return _instance;
}
/// procedure0rtN8DIoP3ePxd7JrWO8BF =============
IInstance procedure0rtN8DIoP3ePxd7JrWO8BF(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in entity procedure id = 0rtN8DIoP3ePxd7JrWO8BF: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
Pset_BeamCommon
beam common property set
| Template ID | 0TrEv13E5EbAPJniE0gc9B |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcreldefinesbyproperties |
| Generated Dart | procedure0TrEv13E5EbAPJniE0gc9B.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure0TrEv13E5EbAPJniE0gc9B.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 0TrEv13E5EbAPJniE0gc9B ==========
//========== type: procedure entity ==========
//========== input/output: ifcreldefinesbyproperties ==========
//========== name: Pset_BeamCommon ==========
//========== description: pset beam common ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
/// end variable declarations ======================
dynamic _instanceProcedure() {
//this procedure demonstrate how to create propertyset with complex property
//In particular, property with value of type: IfcPropertyEnumeratedValue
//This could be modified to take user input to fill in property values as desired.
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcRelDefinesByProperties",
//note: we do not set GlobalId because it is automatically done
"Name": "Pset_BeamCommon",
"Description": "Properties common to the definition of all occurrence and type objects of beam.",
"RelatingPropertyDefinition": {
//IfcPropertySetDefinitionSelect selects IfcPropertySet
"IfcPropertySet": {
"HasProperties": [{
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "Reference",
"NominalValue": {
//IfcValue selects IfcSimpleValue
"IfcSimpleValue": {
//IfcSimpleValue selects IfcIdentifier
"IfcIdentifier": ""
}
}
}, {
kInstanceTypeKey: "IfcPropertyEnumeratedValue",
"Name": "Status",
"EnumerationValues": [{
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "UNSET"
}
}],
"EnumerationReference": {
kInstanceTypeKey: "IfcPropertyEnumeration",
//list of ifcvalue
"EnumerationValues": [{
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "DEMOLISH"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "EXISTING"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "NEW"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "TEMPORARY"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "OTHER"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "NOTKNOWN"
}
}, {
"IfcSimpleValue": {
//IfcSimpleValue selects IfcLabel
"IfcLabel": "UNSET"
}
}]
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "Span",
"NominalValue": {
//IfcValue selects IfcMeasureValue
"IfcMeasureValue": {
"IfcPositiveLengthMeasure": 1
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "Slop",
"NominalValue": {
//IfcValue selects IfcMeasureValue
"IfcMeasureValue": {
"IfcPlaneAngleMeasure": 0
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "Roll",
"NominalValue": {
//IfcValue selects IfcMeasureValue
"IfcMeasureValue": {
"IfcPlaneAngleMeasure": 0
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "IsExternal",
"NominalValue": {
"IfcSimpleValue": {
"IfcBoolean": true
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "ThermalTransmittance",
"NominalValue": {
"IfcDerivedMeasureValue": {
"IfcThermalTransmittanceMeasure": 0
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "LoadBearing",
"NominalValue": {
"IfcSimpleValue": {
"IfcBoolean": true
}
}
}, {
kInstanceTypeKey: "IfcPropertySingleValue",
"Name": "FireRating",
"NominalValue": {
"IfcSimpleValue": {
"IfcLabel": ""
}
}
}]
}
}
});
return _instance;
}
/// procedure0TrEv13E5EbAPJniE0gc9B =============
IInstance procedure0TrEv13E5EbAPJniE0gc9B(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
test-user-defined-entity
test user defined entity
| Template ID | 16Lxli08z7OPNaXpW2K30i |
|---|---|
| Type | PIBLOCKLYUSERDEFINEDENTITYTEMPLATE (userdefinedentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | user entity |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "PITestEntity",
"str_attrbute": "STRING",
"int_attribute": "INTEGER",
"instance_attribute": "ENTITY"
}
procedural wall
simple extruded procedure wall (thickness = y direction)
| Template ID | 1az7RSyUz1WhWPcinJax3X |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcwall |
| Generated Dart | procedure1az7RSyUz1WhWPcinJax3X.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure1az7RSyUz1WhWPcinJax3X.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 1az7RSyUz1WhWPcinJax3X ==========
//========== type: procedure entity ==========
//========== input/output: ifcwall ==========
//========== name: procedural wall ==========
//========== description: simple extruded procedure wall (thickness = y direction) ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _thickness;
var _length;
var _height;
var _context;
var _shape;
var _extrude;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//define user input
_templateInput = {
"length": "REAL",
"thickness": "REAL",
"height": "REAL"
};
_thickness = getDictionaryValue(_input, "thickness") ?? 100;
//wall thickness should be at least 100 mm
if (_thickness < 100) {
_thickness = 100;
}
_length = getDictionaryValue(_input, "length") ?? 25000;
//wall height is at least about 6 ft
_height = getDictionaryValue(_input, "height") ?? 1800;
if (_height < 1800) {
_height = 1800;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get context");
return _instance;
}
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "ifcwall",
"description": "procedural wall"
});
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "failed to create wall");
return _instance;
}
_shape = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcShapeRepresentation",
"ContextOfItems": _context.instanceHandle,
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid"
});
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to create shape");
return _instance;
}
_extrude = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifcextrudedareasolid",
"SweptArea": {
kInstanceTypeKey: "IfcRectangleProfileDef",
"ProfileType": "AREA",
"YDim": _thickness,
"XDim": _length
},
"ExtrudedDirection": {
//note: we skip the @type, since IfcDirection is final
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
if (NullChecker.isNull(_extrude)) {
logMsg(LogType.error, "failed to create extrude");
return _instance;
}
_style = (_model as IIfcModel).createStyledItem([0.5, 0.5, 0.5, 0.1]);
if (NullChecker.isNull(_style)) {
logMsg(LogType.error, "failed to create style");
return _instance;
}
//shape got saved, extrude and style are composed in shape
_shape = _model.addRepItemToShape(_shape, _extrude, _style);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to add extrude to shape");
return _instance;
}
//instance is saved
_shape = _model.addShape(_instance, _shape);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to add shape");
return _instance;
}
return _instance;
}
/// procedure1az7RSyUz1WhWPcinJax3X =============
IInstance procedure1az7RSyUz1WhWPcinJax3X(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
ap214-brep-box
ap214 model generator with rectangular brep
| Template ID | 1dy9mAZzLDfRoWfIR6sDPn |
|---|---|
| Type | PIBLOCKLYPROCEDURALMODELTEMPLATE (proceduralmodel) |
| Schema | 4 (ap214) |
| Input / Output | model |
| Generated Dart | procedure1dy9mAZzLDfRoWfIR6sDPn.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure1dy9mAZzLDfRoWfIR6sDPn.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 1dy9mAZzLDfRoWfIR6sDPn ==========
//========== type: procedure model ==========
//========== input/output: model ==========
//========== name: ap214-brep-box ==========
//========== schema: ap214 ==========
Dictionary _templateInput = {};
PISTPModel _model = PISTPModel.nullModel();
Dictionary _input = {};
var _length;
PIProject _project = PIProject.nullProject();
var _width;
var _height;
var _modelName;
var _modelDescription;
var _app_ctx;
var _to_save;
var _prod_ctx;
var _prod;
var _prod_def_formation;
var _prod_def_ctx;
var _prod_def;
var _prod_def_shape;
var _geo_ctx;
var _shape;
var _shape_def_rep;
var _composites;
var _tpnt1;
var _tv1;
var _tpnt2;
var _tv2;
var _tpnt3;
var _tv3;
var _tpnt4;
var _tv4;
var _tec1;
var _tedge1;
var _tec2;
var _tedge2;
var _tec3;
var _tedge3;
var _tec4;
var _tedge4;
var _tface1;
var _bpnt1;
var _bvt1;
var _bpnt2;
var _bvt2;
var _bpnt3;
var _bvt3;
var _bpnt4;
var _bvt4;
var _bec1;
var _bedge1;
var _bec2;
var _bedge2;
var _bec3;
var _bedge3;
var _bec4;
var _bedge4;
var _bface1;
var _fedge1;
var _fec2;
var _fedge2;
var _fedge3;
var _fec4;
var _fedge4;
var _fface1;
var _kedge1;
var _kec2;
var _kedge2;
var _kedge3;
var _kec4;
var _kedge4;
var _kface1;
var _ledge1;
var _ledge2;
var _ledge3;
var _ledge4;
var _lface1;
var _redge1;
var _redge2;
var _redge3;
var _redge4;
var _rface1;
var _brep;
var _bool;
/// end variable declarations ======================
dynamic _modelProcedure() {
_templateInput = {
"model_name": "STRING",
"model_description": "STRING",
"length": "REAL",
"width": "REAL",
"height": "REAL"
};
_length = getDictionaryValue(_input, "length") ?? 400;
_width = getDictionaryValue(_input, "width") ?? 400;
_height = getDictionaryValue(_input, "height") ?? 400;
_modelName = getDictionaryValue(_input, "model_name") ?? "ap214Test";
_modelDescription = getDictionaryValue(_input, "model_description") ?? "model with brep";
_model = _project.createModelEx(SupportedSchema.ap214, _modelName, _modelDescription, '') as PISTPModel;
//create app context
_app_ctx = _model.createAppContext();
//initialize _toSave as a list with one item
//_toSave contains all the stuff we will save to model
_to_save = <IInstance>[];
_to_save.add(_app_ctx);
//create product context, note that we are referenceing app_ctx
_prod_ctx = _model.createProductContext(_app_ctx);
_to_save.add(_prod_ctx);
_prod = _model.createInstanceFromDictionary({
"@type": "product",
"id": PIComposerAPIFFI.getGuid(),
"name": "brep product",
"description": "product with brep property",
//since we are using @reference, without setting @addInverse = false, _prod_ctx has an inverse pointing to _prod
"frame_of_reference": [{
kReferenceKey: _prod_ctx
}]
});
_to_save.add(_prod);
//create product_definition_formation
_prod_def_formation = _model.createInstanceFromDictionary({
"@type": "product_definition_formation",
"of_product": _prod.instanceHandle,
"id": PIComposerAPIFFI.getGuid(),
"description": "test brep"
});
_prod_def_ctx = _model.createProductDefinitionContext(_app_ctx, stage: "design");
//create product_definition, note we composed _pdf and _pdf_ctx
//_prod_def_formation and _prod_def_ctx are composed
_prod_def = _model.createInstanceFromDictionary({
"@type": "product_definition",
"formation": _prod_def_formation,
"id": PIComposerAPIFFI.getGuid(),
"description": "blockly product_definition",
"frame_of_reference": _prod_def_ctx
});
//next we create shape property for product definition.
//product_definition_shape is a subtype of property_definition
//attribute definition is a select of type characterized_definition (characterized_product_definition) of a select (product_definition)
_prod_def_shape = _model.createInstanceFromDictionary({
"@type": "product_definition_shape",
"definition": {
"characterized_product_definition": {
//prod_def is composed,
"product_definition": _prod_def
}
}
});
_to_save.add(_prod_def_shape);
_geo_ctx = _model.createGeometryContext(3, 0);
_to_save.add(_geo_ctx);
_shape = _model.createInstanceFromDictionary({
"@type": "shape_representation",
"name": "example shape_representation",
"context_of_items": _geo_ctx.instanceHandle,
"items": [{
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, 0, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
}
}]
});
_to_save.add(_shape);
_shape_def_rep = _model.createInstanceFromDictionary({
"@type": "shape_definition_representation",
//definition is a select of type: represented_definition
"definition": {
//selected type is: product_definition_shape
"product_definition_shape": _prod_def_shape.instanceHandle
},
"used_representation": _shape.instanceHandle
});
_to_save.add(_shape_def_rep);
//create brep and add to shape
//store shape dependent instances composites (just like IfcShapeRepresentation)
_composites = <IInstance>[];
//top face: (0,0,height), (length,0, height), (length,width,height), (0,width,height)
_tpnt1 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [0, 0, _height]
});
_composites.add(_tpnt1);
_tv1 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _tpnt1.instanceHandle
});
_composites.add(_tv1);
_tpnt2 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [_length, 0, _height]
});
_composites.add(_tpnt2);
_tv2 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _tpnt2.instanceHandle
});
_composites.add(_tv2);
_tpnt3 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [_length, _width, _height]
});
_composites.add(_tpnt3);
_tv3 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _tpnt3.instanceHandle
});
_composites.add(_tv3);
_tpnt4 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [0, _width, _height]
});
_composites.add(_tpnt4);
_tv4 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _tpnt4.instanceHandle
});
_composites.add(_tv4);
//top edge_curve 1
_tec1 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _tpnt1.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _tv1.instanceHandle,
"edge_end": _tv2.instanceHandle
});
_composites.add(_tec1);
_tedge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec1.instanceHandle,
"orientation": true
});
_tec2 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _tpnt2.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 1, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _tv2.instanceHandle,
"edge_end": _tv3.instanceHandle
});
_composites.add(_tec2);
_tedge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec2.instanceHandle,
"orientation": true
});
_tec3 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _tpnt3.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [-1, 0, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _tv3.instanceHandle,
"edge_end": _tv4.instanceHandle
});
_composites.add(_tec3);
_tedge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec3.instanceHandle,
"orientation": true
});
_tec4 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _tpnt4.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, -1, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _tv4.instanceHandle,
"edge_end": _tv1.instanceHandle
});
_composites.add(_tec4);
_tedge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec4.instanceHandle,
"orientation": true
});
//face contents are all composed, including all the edges
_tface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "top face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, 0, _height]
},
"axis": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "top loop",
"edge_list": [_tedge1, _tedge2, _tedge3, _tedge4]
},
"orientation": true
}],
"same_sense": true
});
//bottom face: (0,0,0), (length,0,0), (length,width,0), (0,width,0)
_bpnt1 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [0, 0, 0]
});
_composites.add(_bpnt1);
_bvt1 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _bpnt1.instanceHandle
});
_composites.add(_bvt1);
_bpnt2 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [_length, 0, 0]
});
_composites.add(_bpnt2);
_bvt2 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _bpnt2.instanceHandle
});
_composites.add(_bvt2);
_bpnt3 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [_length, _width, 0]
});
_composites.add(_bpnt3);
_bvt3 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _bpnt3.instanceHandle
});
_composites.add(_bvt3);
_bpnt4 = _model.createInstanceFromDictionary({
"@type": "cartesian_point",
"coordinates": [0, _width, 0]
});
_composites.add(_bpnt4);
_bvt4 = _model.createInstanceFromDictionary({
"@type": "vertex_point",
"vertex_geometry": _bpnt4.instanceHandle
});
_composites.add(_bvt4);
_bec1 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt1.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt1.instanceHandle,
"edge_end": _bvt2.instanceHandle
});
_composites.add(_bec1);
_bedge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec1.instanceHandle,
"orientation": false
});
_bec2 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt2.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 1, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt2.instanceHandle,
"edge_end": _bvt3.instanceHandle
});
_composites.add(_bec2);
_bedge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec2.instanceHandle,
"orientation": false
});
_bec3 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt3.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [-1, 0, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt3.instanceHandle,
"edge_end": _bvt4.instanceHandle
});
_composites.add(_bec3);
_bedge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec3.instanceHandle,
"orientation": false
});
_bec4 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt4.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, -1, 0]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt4.instanceHandle,
"edge_end": _bvt1.instanceHandle
});
_composites.add(_bec4);
_bedge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec4.instanceHandle,
"orientation": false
});
_bface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "bottom face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, 0, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [0, 0, -1]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "bottom loop",
"edge_list": [_bedge4, _bedge3, _bedge2, _bedge1]
},
"orientation": true
}],
"same_sense": true
});
//front face: (0,0,0), (length,0,0),(length,0,height),(0,0,height)
_fedge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec1.instanceHandle,
"orientation": false
});
_fec2 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt2.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt2.instanceHandle,
"edge_end": _tv2.instanceHandle
});
_composites.add(_fec2);
_fedge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _fec2.instanceHandle,
"orientation": true
});
_fedge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec1.instanceHandle,
"orientation": false
});
_fec4 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt1.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt1.instanceHandle,
"edge_end": _tv1.instanceHandle
});
_composites.add(_fec4);
_fedge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _fec4.instanceHandle,
"orientation": false
});
_fface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "front face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, 0, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [0, -1, 0]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [-1, 0, 0]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "front loop",
"edge_list": [_fedge1, _fedge2, _fedge3, _fedge4]
},
"orientation": true
}],
"same_sense": true
});
//back face: (0, width, 0) to (length, width, 0) to (length, width, height) to (0, width, height)
_kedge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec3.instanceHandle,
"orientation": false
});
_kec2 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt3.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt3.instanceHandle,
"edge_end": _tv3.instanceHandle
});
_composites.add(_kec2);
_kedge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _kec2.instanceHandle,
"orientation": true
});
_kedge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec3.instanceHandle,
"orientation": true
});
_kec4 = _model.createInstanceFromDictionary({
"@type": "edge_curve",
"edge_geometry": {
"@type": "line",
"pnt": _bpnt4.instanceHandle,
"dir": {
"@type": "vector",
"orientation": {
"@type": "direction",
"direction_ratios": [0, 0, -1]
},
"magnitude": 1
}
},
"same_sense": true,
"edge_start": _bvt4.instanceHandle,
"edge_end": _tv4.instanceHandle
});
_composites.add(_kec4);
_kedge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _kec4.instanceHandle,
"orientation": false
});
_kface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "back face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, _width, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [0, -1, 0]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [-1, 0, 0]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "back loop",
"edge_list": [_kedge1, _kedge2, _kedge3, _kedge4]
},
"orientation": true
}],
"same_sense": true
});
//left face: (0,0,0), (0,width,0), (0,width,height),(0,0,height)
_ledge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec4.instanceHandle,
"orientation": false
});
_ledge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _kec4.instanceHandle,
"orientation": true
});
_ledge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec4.instanceHandle,
"orientation": true
});
_ledge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _fec4.instanceHandle,
"orientation": false
});
_lface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "left face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [0, 0, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "left loop",
"edge_list": [_ledge1, _ledge2, _ledge3, _ledge4]
},
"orientation": true
}],
"same_sense": false
});
//right face: (length,0,0), (length,width,0), (length,width,height),(width,0,height)
_redge1 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _bec2.instanceHandle,
"orientation": true
});
_redge2 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _kec2.instanceHandle,
"orientation": true
});
_redge3 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _tec2.instanceHandle,
"orientation": false
});
_redge4 = _model.createInstanceFromDictionary({
"@type": "oriented_edge",
"edge_element": _fec2.instanceHandle,
"orientation": false
});
_rface1 = _model.createInstanceFromDictionary({
"@type": "advanced_face",
"name": "right face",
"face_geometry": {
"@type": "plane",
"position": {
"@type": "axis2_placement_3d",
"location": {
"@type": "cartesian_point",
"coordinates": [_length, 0, 0]
},
"axis": {
"@type": "direction",
"direction_ratios": [1, 0, 0]
},
"ref_direction": {
"@type": "direction",
"direction_ratios": [0, 0, 1]
}
}
},
"bounds": [{
"@type": "face_outer_bound",
"bound": {
"@type": "edge_loop",
"name": "rigth loop",
"edge_list": [_redge1, _redge2, _redge3, _redge4]
},
"orientation": true
}],
"same_sense": true
});
//all faces are composed in the brep
_brep = _model.createInstanceFromDictionary({
"@type": "manifold_solid_brep",
"outer": {
"@type": "closed_shell",
"cfs_faces": [_bface1, _fface1, _kface1, _lface1, _rface1, _tface1]
}
});
_composites.add(_brep);
_bool = _shape.setCompositesDynamic(_composites);
_bool = _shape.addInstanceRef(_brep, attName: "items", addInverse: true);
_bool = _model.saveInstances(_to_save);
return _model;
}
/// procedure1dy9mAZzLDfRoWfIR6sDPn =============
PIModel procedure1dy9mAZzLDfRoWfIR6sDPn(PIProject iProject, Dictionary iInput) {
try {
_project = iProject;
_input = iInput;
return _modelProcedure();
} catch(e) {
logMsg(LogType.error,'error in model procedure: ${e.toString()}');
}
return PIModel.nullModel();
}
ifc-platonic-octahedron
platonic octahedron brep
| Template ID | 1ho5zHSAr9hRzZp0UTlsye |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure1ho5zHSAr9hRzZp0UTlsye.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure1ho5zHSAr9hRzZp0UTlsye.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 1ho5zHSAr9hRzZp0UTlsye ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-platonic-octahedron ==========
//========== description: platonic octahedron brep ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _edgeLength;
var _a;
var _b;
var _geoContext;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _brep;
var _bool;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//define user input
_templateInput = {
"edge_length": "REAL"
};
_edgeLength = getDictionaryValue(_input, "edge_length") ?? 1000;
_a = _edgeLength / (2 * Math.sqrt(2));
_b = 0.5 * _edgeLength;
//get geo context from model to create shape
_geoContext = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_geoContext)) {
return _instance;
}
//create the vertex points and brep.
_pt0 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [_a, 0, _a]
});
_pt1 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [_a, 0, -1 * _a]
});
_pt2 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [-1 * _a, 0, _a]
});
_pt3 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [-1 * _a, 0, -1 * _a]
});
_pt4 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [0, _b, 0]
});
_pt5 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"Coordinates": [0, -1 * _b, 0]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
"outer": {
"@type": "IfcClosedShell",
"CfsFaces": [{
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt3.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt1.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt0.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt2.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt3.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt2.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt0.instanceHandle, _pt5.instanceHandle]
}
}]
}]
}
});
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep",
"ContextOfItems": _geoContext.instanceHandle
});
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5]);
_style = (_model as IIfcModel).createStyledItem([0.596078431372549, 0.8352941176470589, 0.9058823529411765, 1]);
_instance = _model.addRepItemToShape(_instance, _brep, _style);
return _instance;
}
/// procedure1ho5zHSAr9hRzZp0UTlsye =============
IInstance procedure1ho5zHSAr9hRzZp0UTlsye(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
circular wall
extruded circular wall (input angles are in degree)
| Template ID | 1in7EeUlr37PybZC5bsOiR |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcwall |
| Generated Dart | procedure1in7EeUlr37PybZC5bsOiR.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure1in7EeUlr37PybZC5bsOiR.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 1in7EeUlr37PybZC5bsOiR ==========
//========== type: procedure entity ==========
//========== input/output: ifcwall ==========
//========== name: circular wall ==========
//========== description: extruded circular wall (input angle are in degree) ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _radius;
var _startAngle;
var _endAngle;
var _thickness;
var _outerRadius;
var _height;
var _context;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _circularSeg1;
var _circularSeg2;
var _extrude;
var _style;
var _shape;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//user inputs:
_templateInput = {
"radius": "REAL",
"startAngle": "REAL",
"endAngle": "REAL",
"thickness": "REAL",
"height": "REAL"
};
//get user inputs from _input
_radius = getDictionaryValue(_input, "radius") ?? 1000;
//blockly sin/cos use degrees, do not convert to radian
_startAngle = getDictionaryValue(_input, "startAngle") ?? 0;
_endAngle = getDictionaryValue(_input, "endAngle") ?? 90;
_thickness = getDictionaryValue(_input, "thickness") ?? 10;
if (_thickness < 10) {
_thickness = 10;
}
_outerRadius = _thickness + _radius;
_height = getDictionaryValue(_input, "height") ?? 1900;
//make sure we have valid angle inputs. _instance is null
if ((_startAngle - _endAngle).abs() < 1e-10) {
return _instance;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get geocontext in model");
return _instance;
}
_pt0 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifccartesianpoint",
"coordinates": [_radius * Math.cos(_startAngle / 180 * Math.pi), _radius * Math.sin(_startAngle / 180 * Math.pi)]
});
_pt1 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifccartesianpoint",
"coordinates": [_outerRadius * Math.cos(_startAngle / 180 * Math.pi), _outerRadius * Math.sin(_startAngle / 180 * Math.pi)]
});
_pt2 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifccartesianpoint",
"coordinates": [_outerRadius * Math.cos(_endAngle / 180 * Math.pi), _outerRadius * Math.sin(_endAngle / 180 * Math.pi)]
});
_pt3 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifccartesianpoint",
"coordinates": [_radius * Math.cos(_endAngle / 180 * Math.pi), _radius * Math.sin(_endAngle / 180 * Math.pi)]
});
//create the circular segments first, otherwise too much nesting.
_circularSeg1 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCompositeCurveSegment",
"Transition": "CONTINUOUS",
"SameSense": true,
"ParentCurve": {
kInstanceTypeKey: "IfcTrimmedCurve",
"BasisCurve": {
kInstanceTypeKey: "IfcCircle",
"Radius": _outerRadius,
"Position": {
//set position selected type as attribute name
"IfcAxis2Placement2D": {
"location": {
kInstanceTypeKey: "ifccartesianpoint",
"coordinates": [0, 0]
},
"RefDirection": {
"DirectionRatios": [1, 0]
}
}
}
},
"SenseAgreement": true,
"Trim1": [{
//set IfcTrimmingSelect selected as Ifccartesianpoint
"IfcCartesianPoint": _pt1.instanceHandle
}],
"Trim2": [{
//set IfcTrimmingSelect selected as Ifccartesianpoint
"IfcCartesianPoint": _pt2.instanceHandle
}],
"MasterRepresentation": "CARTESIAN"
}
});
_circularSeg2 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCompositeCurveSegment",
"Transition": "CONTINUOUS",
"SameSense": true,
"ParentCurve": {
kInstanceTypeKey: "IfcTrimmedCurve",
"BasisCurve": {
kInstanceTypeKey: "IfcCircle",
"Radius": _radius,
"Position": {
//set position selected type as attribute name
"IfcAxis2Placement2D": {
"location": {
kInstanceTypeKey: "ifccartesianpoint",
"coordinates": [0, 0]
},
"RefDirection": {
"DirectionRatios": [1, 0]
}
}
}
},
"SenseAgreement": false,
"Trim1": [{
"IfcCartesianPoint": _pt3.instanceHandle
}],
"Trim2": [{
"IfcCartesianPoint": _pt1.instanceHandle
}],
"MasterRepresentation": "CARTESIAN"
}
});
_extrude = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcExtrudedAreaSolid",
"SweptArea": {
kInstanceTypeKey: "IfcArbitraryClosedProfileDef",
"ProfileType": "AREA",
"OuterCurve": {
kInstanceTypeKey: "IfcCompositeCurve",
//note: the circular segments are composed
"Segments": [{
kInstanceTypeKey: "IfcCompositeCurveSegment",
"Transition": "CONTINUOUS",
"SameSense": true,
"ParentCurve": {
kInstanceTypeKey: "IfcPolyline",
"Points": [_pt0.instanceHandle, _pt1.instanceHandle]
}
}, _circularSeg1, {
kInstanceTypeKey: "IfcCompositeCurveSegment",
"Transition": "CONTINUOUS",
"SameSense": true,
"ParentCurve": {
kInstanceTypeKey: "IfcPolyline",
"Points": [_pt2.instanceHandle, _pt3.instanceHandle]
}
}, _circularSeg2]
}
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
if (NullChecker.isNull(_extrude)) {
logMsg(LogType.error, "failed to create extrude");
return _instance;
}
_style = (_model as IIfcModel).createStyledItem([0.8, 0.6, 0.3, 0]);
if (NullChecker.isNull(_style)) {
logMsg(LogType.error, "failed to create style");
return _instance;
}
_shape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
"ContextOfItems": _context.instanceHandle
});
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to create shape");
return _instance;
}
//add the points to shape as composite elements.
_bool = _shape.addCompositeDynamic([_pt0, _pt1, _pt2, _pt3]);
//note: nothing has been save to the model yet until the next function calll
//this add extrude and style to shape as composites. Shape saved to model
_shape = _model.addRepItemToShape(_shape, _extrude, _style);
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcWall",
"name": "circular wall",
"description": "procedural circular wall"
});
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "failed to create wall");
return _instance;
}
_shape = _model.addShape(_instance, _shape);
_bool = _model.saveInstances([_shape, _instance]);
return _instance;
}
/// procedure1in7EeUlr37PybZC5bsOiR =============
IInstance procedure1in7EeUlr37PybZC5bsOiR(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
5-storey (2m height)
spatial teamplate with 5 storeys
| Template ID | 1J1OKa3ZT5098GcPKqkMKe |
|---|---|
| Type | PIBLOCKLYSPATIALTEMPLATE (spatial) |
| Schema | 14 (ifc4x3) |
| Input / Output | model |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "ifcproject",
"name": "spatial test",
"children": [
{
"@type": "ifcbuilding",
"name": "building south",
"children": [
{
"@type": "ifcbuildingstorey",
"name": "floor one"
},
{
"@type": "ifcbuildingstorey",
"name": "floor two",
"location": [
5e-324,
5e-324,
2000
]
},
{
"@type": "ifcbuildingstorey",
"name": "floor three",
"location": [
5e-324,
5e-324,
4000
]
},
{
"@type": "ifcbuildingstorey",
"name": "floor four",
"location": [
5e-324,
5e-324,
6000
]
},
{
"@type": "ifcbuildingstorey",
"name": "floor five",
"location": [
5e-324,
5e-324,
8000
]
}
]
}
]
}
2-storey (2m height)
2 storey spatial template
| Template ID | 1JZ64MOyPFzAznfbWsvUP4 |
|---|---|
| Type | PIBLOCKLYSPATIALTEMPLATE (spatial) |
| Schema | 14 (ifc4x3) |
| Input / Output | model |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "ifcproject",
"name": "2 storey house",
"children": [
{
"@type": "ifcbuilding",
"name": "building south",
"children": [
{
"@type": "ifcbuildingstorey",
"name": "ground floor"
},
{
"@type": "ifcbuildingstorey",
"name": "roof",
"location": [
5e-324,
5e-324,
2000
]
}
]
}
]
}
Pset_SpaceCommon
space common pset
| Template ID | 1k6djJNFnEahTebu0wMoKt |
|---|---|
| Type | PIBLOCKLYPROPERTYSETTEMPLATE (propertyset) |
| Schema | 14 (ifc4x3) |
| Input / Output | property |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "Pset_SpaceCommon",
"Reference": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcIdentifier"
},
"IsExternal": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcIdentifier"
},
"GrossPlannedArea": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcAreaMeasure"
},
"NetPlannedArea": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcAreaMeasure"
},
"PubliclyAccessible": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcBoolean"
},
"HandicapAccessible": {
"property_type": "P_SINGLEVALUE",
"value_type": "IfcBoolean"
}
}
procedural-table
procedural table with circular legs.
| Template ID | 1OlOZDHKTBuRY9xvw7NYlX |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcfurniture |
| Generated Dart | procedure1OlOZDHKTBuRY9xvw7NYlX.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure1OlOZDHKTBuRY9xvw7NYlX.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 1OlOZDHKTBuRY9xvw7NYlX ==========
//========== type: procedure entity ==========
//========== input/output: ifcfurniture ==========
//========== name: procedural-table ==========
//========== description: procedural table with circular legs. ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
var _topShape;
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _length;
var _width;
var _thickness;
var _height;
var _radius;
var _context;
var _extrude;
var _style;
var _legShape;
var _masterShape;
var _axis2Placement3d;
var _mappedItem;
var _bool;
var _legLocation;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//handle user input
_templateInput = {
"length": "REAL",
"width": "REAL",
"thickness": "REAL",
"height": "REAL",
"radius": "REAL"
};
_length = getDictionaryValue(_input, "length") ?? 2000;
_width = getDictionaryValue(_input, "width") ?? 1000;
_thickness = getDictionaryValue(_input, "thickness") ?? 100;
_height = getDictionaryValue(_input, "height") ?? 600;
_radius = getDictionaryValue(_input, "radius") ?? 50;
if (_radius > 0.2 * _width) {
_radius = 0.2 * _width;
}
if (_radius > 0.2 * _length) {
_radius = 0.2 * _length;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "model context not set up");
return _instance;
}
//create basic top shape
_extrude = _model.createInstanceFromDictionary({
"@type": "IfcExtrudedAreaSolid",
"SweptArea": {
"@type": "IfcRectangleProfileDef",
"ProfileType": "AREA",
"xDim": _length,
"yDim": _width
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _thickness
});
_topShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
//use handle to set reference without adding inverse.
//We do this since _context is global object no need to worry about life cycle
"ContextOfItems": _context.instanceHandle
});
_style = (_model as IIfcModel).createStyledItem([0.75, 0.5, 0.35, 0.1]);
_topShape = _model.addRepItemToShape(_topShape, _extrude, _style);
//create basic leg shape
_extrude = _model.createInstanceFromDictionary({
"@type": "IfcExtrudedAreaSolid",
"SweptArea": {
"@type": "IfcCircleProfileDef",
"ProfileType": "AREA",
"radius": _radius
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
_legShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
//use handle to set reference without adding inverse.
//We do this since _context is global object no need to worry about life cycle
"ContextOfItems": _context.instanceHandle
});
//style must be unique for each rep item. Duplicate it with new id.
_style = _style.duplicate(true);
_legShape = _model.addRepItemToShape(_legShape, _extrude, _style);
//create furniture instance
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcFurniture",
"name": "procedural table",
"PredefinedType": "TABLE"
});
_masterShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "MappedRepresentation",
"ContextOfItems": _context.instanceHandle
});
_axis2Placement3d = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcAxis2Placement3d",
"location": {
kInstanceTypeKey: "IfccartesianPoint",
"coordinates": [0, 0, 0]
},
"axis": {
"directionRatios": [0, 0, 1]
},
"refdirection": {
"directionRatios": [1, 0, 0]
}
});
if (NullChecker.isNull(_axis2Placement3d)) {
logMsg(LogType.error, "error create axis2placement");
return _instance;
}
//mapping of the top shape
_mappedItem = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcMappedItem",
"MappingSource": {
kInstanceTypeKey: "IfcRepresentationMap",
"MappingOrigin": {
"IfcAxis2Placement3D": _axis2Placement3d
},
"MappedRepresentation": _topShape.instanceHandle
},
"MappingTarget": {
kInstanceTypeKey: "IfcCartesianTransformationOperator3D",
"LocalOrigin": {
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [0, 0, _height]
}
}
});
_masterShape = _model.addRepItemToShape(_masterShape, _mappedItem, PIInstance.nullInstance());
//since masterShape references _topShape, add inverse to _topShape
//this prevent _topShape to be deleted before _masterShape
_bool = _topShape.addInverseDynamic(_masterShape.instanceHandle);
for (var i = 0; i <= 3; i++) {
//need to compose a new axis2placement3d, so duplicate it
//alternative is share it in the model and reference it
_axis2Placement3d = _axis2Placement3d.duplicate(true);
//note: _legLocaton is used in a json api, so does not need to strictly typed as List<double>.
if (i == 0) {
_legLocation = [-0.5 * _length + _radius, -0.5 * _width + _radius, 0];
}else if (i == 1) {
_legLocation = [-0.5 * _length + _radius, 0.5 * _width - _radius, 0];
}else if (i == 2) {
_legLocation = [0.5 * _length - _radius, 0.5 * _width - _radius, 0];
} else {
_legLocation = [0.5 * _length - _radius, -0.5 * _width + _radius, 0];
}
_mappedItem = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcMappedItem",
"MappingSource": {
kInstanceTypeKey: "IfcRepresentationMap",
"MappingOrigin": {
"IfcAxis2Placement3D": _axis2Placement3d
},
"MappedRepresentation": _legShape.instanceHandle
},
"MappingTarget": {
kInstanceTypeKey: "IfcCartesianTransformationOperator3D",
"LocalOrigin": {
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": _legLocation
}
}
});
_masterShape = _model.addRepItemToShape(_masterShape, _mappedItem, PIInstance.nullInstance());
}
_bool = _legShape.addInverseDynamic(_masterShape.instanceHandle);
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcFurniture",
"name": "procedural table",
"PredefinedType": "TABLE"
});
//note: this save _instance and _masterShape
_masterShape = _model.addShape(_instance, _masterShape);
//need to save the referenced shapes: _topShape and _legShape
_bool = _model.saveInstances(toTypedList<IInstance>([_topShape, _legShape]).getOrElse(() => <IInstance>[]));
return _instance;
}
/// procedure1OlOZDHKTBuRY9xvw7NYlX =============
IInstance procedure1OlOZDHKTBuRY9xvw7NYlX(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
_topShape;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
Qto_WallBaseQuantities
wall base quantities
| Template ID | 1uxe7LoAzCxxca0fDz6ek1 |
|---|---|
| Type | PIBLOCKLYQUANTITYSETTEMPLATE (quantityset) |
| Schema | 14 (ifc4x3) |
| Input / Output | quantity |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "Qto_WallBaseQuantities",
"Length": "Q_LENGTH",
"Width": "Q_LENGTH",
"Height": "Q_LENGTH",
"GrossFootprintArea": "Q_AREA",
"NetFootprintArea": "Q_AREA",
"GrossSideArea": "Q_AREA",
"NetSideArea": "Q_AREA",
"GrossVolume": "Q_VOLUME",
"NetVolume": "Q_VOLUME",
"GrossWeight": "Q_WEIGHT",
"NetWeight": "Q_WEIGHT"
}
Trapezoidal Prism
Brep Trapezoidal Prism
| Template ID | 22JbB0ao18kvy9JK5Ui2nS |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure22JbB0ao18kvy9JK5Ui2nS.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure22JbB0ao18kvy9JK5Ui2nS.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 22JbB0ao18kvy9JK5Ui2nS ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: Trapezoidal Prism ==========
//========== description: Trapezoidal Prism ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _length;
var _width;
var _height;
var _ratio;
var _context;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _pt6;
var _pt7;
var _brep;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//set up user input===
_templateInput = {
"length": "REAL",
"width": "REAL",
"height": "REAL",
"top_bottom_ratio": "REAL"
};
_length = getDictionaryValue(_input, "length") ?? 100;
_width = getDictionaryValue(_input, "width") ?? 100;
_height = getDictionaryValue(_input, "height") ?? 100;
_ratio = getDictionaryValue(_input, "top_bottom_ratio") ?? 0.8;
if (_ratio < 0.1) {
_ratio = 0.1;
if (_ratio > 2) {
_ratio = 2;
}
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "error get geometric context");
return _instance;
}
//the geometry will the center at the origin
_pt0 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [-0.5 * _length, -0.5 * _width, 0]
});
_pt1 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [-0.5 * _length, 0.5 * _width, 0]
});
_pt2 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0.5 * _length, 0.5 * _width, 0]
});
_pt3 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [0.5 * _length, -0.5 * _width, 0]
});
_pt4 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_ratio * (-0.5 * _length), _ratio * (-0.5 * _width), _height]
});
_pt5 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_ratio * (-0.5 * _length), _ratio * (0.5 * _width), _height]
});
_pt6 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_ratio * (0.5 * _length), _ratio * (0.5 * _width), _height]
});
_pt7 = _model.createInstanceFromDictionary({
"@type": "ifccartesianpoint",
"coordinates": [_ratio * (0.5 * _length), _ratio * (-0.5 * _width), _height]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
"outer": {
"@type": "IfcClosedShell",
"CfsFaces": [{
//top face:
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt4.instanceHandle, _pt5.instanceHandle, _pt6.instanceHandle, _pt7.instanceHandle]
}
}]
}, {
//left face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt4.instanceHandle, _pt7.instanceHandle, _pt3.instanceHandle]
}
}]
}, {
//back face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt7.instanceHandle, _pt6.instanceHandle, _pt2.instanceHandle]
}
}]
}, {
//front face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt5.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
//right face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt2.instanceHandle, _pt6.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
//bottom face
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt3.instanceHandle, _pt2.instanceHandle, _pt1.instanceHandle]
}
}]
}]
}
});
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep",
"ContextOfItems": _context.instanceHandle
});
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5, _pt6, _pt7]);
_instance = _model.addRepItemToShape(_instance, _brep, PIInstance.nullInstance());
return _instance;
}
/// procedure22JbB0ao18kvy9JK5Ui2nS =============
IInstance procedure22JbB0ao18kvy9JK5Ui2nS(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
procedural-wall-door
procedural wall with door and window
| Template ID | 2e4tiHDP5DBwlbChTamO1P |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcwall |
| Generated Dart | procedure2e4tiHDP5DBwlbChTamO1P.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2e4tiHDP5DBwlbChTamO1P.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2e4tiHDP5DBwlbChTamO1P ==========
//========== type: procedure entity ==========
//========== input/output: ifcwall ==========
//========== name: procedural-wall-door ==========
//========== description: procedural wall with door and window ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _thickness;
var _length;
var _height;
var _context;
var _wallProcedure;
var _extrudeShapeProcedure;
var _dict;
var _bool;
var _doorOpening;
var _shape;
var _door;
var _windowOpening;
var _window;
var _path;
var _placement;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//this procedure use two other procedures to complete its work, these procedure ids are:
//1. 1az7RSyUz1WhWPcinJax3X
//2. 2UdehL6ZvCmeQJdY5k180h
//define user input
_templateInput = {
"thickness": "REAL",
"length": "REAL",
"height": "REAL"
};
//get user input.
_thickness = getDictionaryValue(_input, "thickness") ?? 100;
//make wall at least 100 mm thick
if (_thickness < 100) {
_thickness = 100;
}
_length = getDictionaryValue(_input, "length") ?? 8000;
if (_length < 8000) {
_length = 8000;
}
_height = getDictionaryValue(_input, "height") ?? 1800;
if (_height < 1800) {
_height = 1800;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get context");
return _instance;
}
//get the wall procedure function by id.
_wallProcedure = getProcedureInstanceFunction('1az7RSyUz1WhWPcinJax3X');
if (NullChecker.isNull(_wallProcedure)) {
logMsg(LogType.error, "failed to find wall procedure");
return _instance;
}
//we will use two existing procedure to do some of the work
//get the extrude procedure by id.
_extrudeShapeProcedure = getProcedureInstanceFunction('2UdehL6ZvCmeQJdY5k180h');
if (NullChecker.isNull(_extrudeShapeProcedure)) {
logMsg(LogType.error, "failed to find wall procedure");
return _instance;
}
//set _dict as an empty dictionary. This gives it a time
_dict = <String,dynamic>{};
//_input to wall procedure
_dict = {
"length": _length,
"thickness": _thickness,
"height": _height
};
//create the wall
_instance = _wallProcedure(_model, _dict);
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "failed to create wall");
return _instance;
}
_bool = _model.saveInstance(_instance);
//create the door opening. Dictionary key must match the _input name of the target procedure
_doorOpening = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcOpeningElement",
"name": "door opening",
"description": "opening for door"
});
_dict = {
"length": 1600,
"width": _thickness + 100,
"height": _height - 250
};
//create the shape for opening
_shape = _extrudeShapeProcedure(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to opening shape");
return _instance;
}
_shape = _model.addShape(_doorOpening, _shape);
_bool = _model.addChild(_instance, _doorOpening);
//create the door
_door = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcDoor",
"name": "door",
"description": "simple door"
});
if (NullChecker.isNull(_door)) {
logMsg(LogType.error, "failed to create door");
return _instance;
}
_dict = {
"length": 1600,
"width": _thickness * 0.5,
"height": _height - 250
};
//create shape for door
_shape = _extrudeShapeProcedure(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to door shape");
return _instance;
}
_shape = _model.addShape(_door, _shape);
_bool = _model.addChild(_doorOpening, _door);
//open the wall for window
_windowOpening = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcOpeningElement",
"name": "window opening",
"description": "opening for windows"
});
_dict = {
"length": 2000,
"width": _thickness + 100,
"height": _height * 0.4
};
_shape = _extrudeShapeProcedure(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to window openging shape");
return _instance;
}
_shape = _model.addShape(_windowOpening, _shape);
//add window opening to the wall
_bool = _model.addChild(_instance, _windowOpening);
//create window
_window = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcWindow",
"name": "procedural window",
"description": "window for the wall system"
});
_dict = {
"length": 2000,
"width": _thickness * 0.25,
"height": _height * 0.4
};
_shape = _extrudeShapeProcedure(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to create window opening shape");
return _instance;
}
_shape = _model.addShape(_window, _shape);
_bool = _model.addChild(_windowOpening, _window);
//place the window by changing location of opening local placement of window
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D", "Location", "Coordinates"];
_placement = _windowOpening.setAttributeByPath(_path, [2800, 0, _height * 0.35]);
if (NullChecker.isNull(_placement)) {
logMsg(LogType.error, "failed to move window opening");
return _instance;
}
_bool = _model.saveInstance(_placement);
return _instance;
}
/// procedure2e4tiHDP5DBwlbChTamO1P =============
IInstance procedure2e4tiHDP5DBwlbChTamO1P(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
procedural-shelf
procedural book shelf
| Template ID | 2IN6vw3516c8axFXZoC40l |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcfurniture |
| Generated Dart | procedure2IN6vw3516c8axFXZoC40l.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2IN6vw3516c8axFXZoC40l.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2IN6vw3516c8axFXZoC40l ==========
//========== type: procedure entity ==========
//========== input/output: ifcfurniture ==========
//========== name: procedural-shelf ==========
//========== description: procedure book shelf ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _length;
var _width;
var _height;
var _thickness;
var _context;
var _extrude;
var _panelShape;
var _style;
var _shelfShape;
var _masterShape;
var _axis2Placement3d;
var _bool;
var _stepSize;
var _location;
var _mappedItem;
/// end variable declarations ======================
dynamic _instanceProcedure() {
// set up user input
_templateInput = {
"length": "REAL",
"width": "REAL",
"height": "REAL",
"thickness": "REAL"
};
_length = getDictionaryValue(_input, "length") ?? 600;
_width = getDictionaryValue(_input, "width") ?? 200;
_height = getDictionaryValue(_input, "height") ?? 600;
_thickness = getDictionaryValue(_input, "thickness") ?? 30;
if (_height < 400) {
_height = 400;
}
if (_thickness > 0.05 * _height) {
_thickness = 0.05 * _height;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "model context not set up");
return _instance;
}
//create the shapes
_extrude = _model.createInstanceFromDictionary({
"@type": "IfcExtrudedAreaSolid",
"SweptArea": {
"@type": "IfcRectangleProfileDef",
"ProfileType": "AREA",
"xDim": _thickness,
"yDim": _width
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
_panelShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
"ContextOfItems": _context.instanceHandle
});
_style = (_model as IIfcModel).createStyledItem([0.75, 0.5, 0.35, 0.1]);
_panelShape = _model.addRepItemToShape(_panelShape, _extrude, _style);
_extrude = _model.createInstanceFromDictionary({
"@type": "IfcExtrudedAreaSolid",
"SweptArea": {
"@type": "IfcRectangleProfileDef",
"ProfileType": "AREA",
"xDim": _length,
"yDim": _width
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _thickness
});
_shelfShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
"ContextOfItems": _context.instanceHandle
});
_style = _style.duplicate(true);
_shelfShape = _model.addRepItemToShape(_shelfShape, _extrude, _style);
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcFurniture",
"name": "procedural table",
"PredefinedType": "TABLE"
});
_masterShape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "MappedRepresentation",
"ContextOfItems": _context.instanceHandle
});
//create side panels
for (var i = 0; i <= 1; i++) {
_axis2Placement3d = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcAxis2Placement3d",
"location": {
kInstanceTypeKey: "IfccartesianPoint",
"coordinates": [0, 0, 0]
},
"axis": {
"directionRatios": [0, 0, 1]
},
"refdirection": {
"directionRatios": [1, 0, 0]
}
});
if (i == 0) {
_location = [-0.5 * _length, 0, 0];
} else {
_location = [0.5 * _length, 0, 0];
}
_mappedItem = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcMappedItem",
"MappingSource": {
kInstanceTypeKey: "IfcRepresentationMap",
"MappingOrigin": {
"IfcAxis2Placement3D": _axis2Placement3d
},
"MappedRepresentation": _panelShape.instanceHandle
},
"MappingTarget": {
kInstanceTypeKey: "IfcCartesianTransformationOperator3D",
"LocalOrigin": {
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": _location
}
}
});
_masterShape = _model.addRepItemToShape(_masterShape, _mappedItem, PIInstance.nullInstance());
}
//_panelShape is being referenced by _masterShape, so add inverse to panelShape
_bool = _panelShape.addInverseDynamic(_masterShape);
_stepSize = (_height * 0.334).floor();
//create shelfs
for (var j = 0; j <= 3; j++) {
_axis2Placement3d = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcAxis2Placement3d",
"location": {
kInstanceTypeKey: "IfccartesianPoint",
"coordinates": [0, 0, 0]
},
"axis": {
"directionRatios": [0, 0, 1]
},
"refdirection": {
"directionRatios": [1, 0, 0]
}
});
if (j < 3) {
_location = [0, 0, j * _stepSize];
} else {
_location = [0, 0, _height - _thickness];
}
_mappedItem = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcMappedItem",
"MappingSource": {
kInstanceTypeKey: "IfcRepresentationMap",
"MappingOrigin": {
"IfcAxis2Placement3D": _axis2Placement3d
},
"MappedRepresentation": _shelfShape.instanceHandle
},
"MappingTarget": {
kInstanceTypeKey: "IfcCartesianTransformationOperator3D",
"LocalOrigin": {
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": _location
}
}
});
_masterShape = _model.addRepItemToShape(_masterShape, _mappedItem, PIInstance.nullInstance());
}
_bool = _shelfShape.addInverseDynamic(_masterShape);
_masterShape = _model.addShape(_instance, _masterShape);
_bool = _model.saveInstances(toTypedList<IInstance>([_panelShape, _shelfShape]).getOrElse(() => <IInstance>[]));
return _instance;
}
/// procedure2IN6vw3516c8axFXZoC40l =============
IInstance procedure2IN6vw3516c8axFXZoC40l(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
boolean-substraction
CSG solid, buildingsmart bathtub example captured as instance template
| Template ID | 2jGXBuYnz5cARkxh6AilQl |
|---|---|
| Type | PIBLOCKLYINSTANCETEMPLATE (instance) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure2jGXBuYnz5cARkxh6AilQl.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2jGXBuYnz5cARkxh6AilQl.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2jGXBuYnz5cARkxh6AilQl ==========
//========== type: instance template ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: boolean-substraction ==========
//========== description: CSG solid, buildingsmart bathtub example ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _x;
var _y;
var _z;
var _thickness;
var _min;
var _temp;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//this instance template parametrize the geometry from a buildingsmart example
//https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/annex_e/advanced-geometric-shape/bath-csg-solid.html
//set up user input
_templateInput = {
"xlength": "REAL",
"ylength": "REAL",
"zlength": "REAL",
"thickness": "REAL"
};
_x = getDictionaryValue(_input, "xlength") ?? 2000;
_y = getDictionaryValue(_input, "ylength") ?? 800;
_z = getDictionaryValue(_input, "zlength") ?? 800;
_thickness = getDictionaryValue(_input, "thickness") ?? 100;
//validate input
if (_x < 1000) {
_x = 1000;
}
if (_y < 600) {
_y = 600;
}
if (_z < 500) {
_z = 500;
}
_min = 0;
for (var i in [_x, _y, _z]) {
if (_min < i) {
_min = i;
}
}
if (_thickness > 0.2 * _min) {
_thickness = 0.2 * _min;
}
if (_thickness < 0.05 * _min) {
_thickness = 0.05 * _min;
}
//to apply procedure on the instance template, you need know the basic structure of the original
//we are modifying the internal of the shape, the return value is instance
//instead of 1 call, we could also get the ifcblock by path, modify it then set it again
//the path api is eminently simipler
//instance is a IfcShapeRepresentation, so path starts at attribute: items
//change dimension of the ifcblock
_temp = _instance.setAttributeByPathWithJson(["items", 0, "treerootexpression", "IfcBooleanResult", "FirstOperand", "ifcblock"], {
"XLength": _x,
"YLength": _y,
"ZLength": _z
});
if (NullChecker.isNull(_temp)) {
logMsg(LogType.error, "error set block attributes ");
}
//update dimension of extrude
//update profile
_temp = _instance.setAttributeByPathWithJson(["items", 0, "treerootexpression", "IfcBooleanResult", "SecondOperand", "ifcextrudedAreasolid", "sweptarea"], {
"xdim": _x - 2 * _thickness,
"ydim": _y - 2 * _thickness,
"roundingradius": 2 * _thickness
});
if (NullChecker.isNull(_temp)) {
logMsg(LogType.error, "error set profile attributes ");
}
//update depth
_temp = _instance.setAttributeByPath(["items", 0, "treerootexpression", "IfcBooleanResult", "SecondOperand", "ifcextrudedAreasolid", "Depth"], (_z - _thickness));
//update location of extrude
_temp = _instance.setAttributeByPath(["items", 0, "treerootexpression", "IfcBooleanResult", "SecondOperand", "ifcextrudedAreasolid", "Position", "location", "coordinates"], [0.5 * _x, 0.5 * _y, _thickness]);
//save the changes
_bool = _model.saveInstance(_instance);
if (!_bool) {
logMsg(LogType.error, "failed to save instantiated instance");
}
return _instance;
}
/// procedure2jGXBuYnz5cARkxh6AilQl =============
IInstance procedure2jGXBuYnz5cARkxh6AilQl(PIModel iModel, PIInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in instance template id = 2jGXBuYnz5cARkxh6AilQl: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
data-transfer
data transfer demo
| Template ID | 2KFfixZwLFkg1auw2tGaCg |
|---|---|
| Type | PIBLOCKLYMODELTRANSFORMTEMPLATE (modeltransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | model |
| Generated Dart | procedure2KFfixZwLFkg1auw2tGaCg.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2KFfixZwLFkg1auw2tGaCg.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2KFfixZwLFkg1auw2tGaCg ==========
//========== type: model transform ==========
//========== input/output: model ==========
//========== name: data-transfer ==========
//========== description: data transfer demo ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
PIIfcModel _model = PIIfcModel.nullModel();
Dictionary _input = {};
PIProject _project = PIProject.nullProject();
var _fileName;
var _instanceTypes;
var _refModel;
var _fromStorey;
var _tostorey;
var _copied;
/// end variable declarations ======================
dynamic _modelProcedure() {
//this a ifc specific procedure
//transfertype are the instance type to transfer. To specify multiple type, use comma separated notation
//set up user input
_templateInput = {
"fileName": "STRING",
"transfterType": "STRING"
};
_fileName = getDictionaryValue(_input, "fileName") ?? "";
_instanceTypes = getDictionaryValue(_input, "transfterType") ?? "";
if (-1 < _instanceTypes.indexOf(",")) {
_instanceTypes = _instanceTypes.split(",");
} else {
_instanceTypes = [_instanceTypes];
}
//valid input
if (_fileName.isEmpty) {
logMsg(LogType.error, "invalid input, fileName must not be empty");
return _model;
}
//load the file as a readony model.
//For large file, it might be preferred to import as a reference model, then do transfer
//That way, you only load and index the import file once, and reuse many times
_refModel = PIProject.createMemoryReferenceModel(_fileName);
if (NullChecker.isNull(_refModel) || !(_refModel as IModel).isIfc) {
logMsg(LogType.error, "error loading model from file, or model is not ifc");
return _model;
}
_fromStorey = _refModel.getOneInstanceOfType(typeName: "ifcbuildingstorey");
if (NullChecker.isNull(_fromStorey)) {
logMsg(LogType.error, "could not get storey from reference model");
return _model;
}
_tostorey = _model.getOneInstanceOfType(typeName: "ifcbuildingstorey");
if (NullChecker.isNull(_tostorey)) {
logMsg(LogType.error, "no storey to transfer data to.");
return _model;
}
//this copy: placement, shape and the list of input relations
_copied = _model.copyChildrenOfTypesWithComposedDependency(_refModel, _fromStorey, _tostorey, _instanceTypes, includeRelTypes: ["IfcRelDefinesByProperties", "IfcRelDefinesByType", "IfcRelAssociatesMaterial"]);
//note all instances in copied are saved to _model
if (_copied.isEmpty) {
logMsg(LogType.info, "nothing was copy");
} else {
logMsg(LogType.info, "procedure copied ${_copied.length} instances");
}
return _model;
}
/// procedure2KFfixZwLFkg1auw2tGaCg =============
PIModel procedure2KFfixZwLFkg1auw2tGaCg(PIProject iProject, PIModel iModel, Dictionary iInput) {
try {
_project = iProject;
_model = iModel as PIIfcModel;
_input = iInput;
return _modelProcedure();
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in model transform id = 2KFfixZwLFkg1auw2tGaCg: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIModel.nullModel();
}
procedural rebar
reinforce bar with swept solid
| Template ID | 2mv2oLjfrDIuEKk1NDY7tp |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcreinforcingbar |
| Generated Dart | procedure2mv2oLjfrDIuEKk1NDY7tp.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2mv2oLjfrDIuEKk1NDY7tp.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2mv2oLjfrDIuEKk1NDY7tp ==========
//========== type: procedure entity ==========
//========== input/output: ifcreinforcingbar ==========
//========== name: procedural rebar ==========
//========== description: reinforce bar with swept solid ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _barRadius;
var _bendRadius;
var _length;
var _context;
var _sweptDisc;
var _style;
var _shape;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//set up user input
_templateInput = {
"bend_radius": "REAL",
"bar_radius": "REAL",
"length": "REAL"
};
_barRadius = getDictionaryValue(_input, "bar_radius") ?? 50;
_bendRadius = getDictionaryValue(_input, "bend_radius") ?? 200;
_length = getDictionaryValue(_input, "length") ?? 200;
if (0.2 * _bendRadius < _barRadius) {
_barRadius = 0.2 * _bendRadius;
}
if (_length < 0.5 * _bendRadius) {
_length = 0.5 * _bendRadius;
}
//set up context
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get context");
return _instance;
}
//bend center will be on the x-axis
_sweptDisc = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcSweptDiskSolid",
"Directrix": {
kInstanceTypeKey: "IfcIndexedPolyCurve",
"Points": {
kInstanceTypeKey: "IfcCartesianPointList3D",
"CoordList": [[-0.5 * _length + 0.1 * _bendRadius, _bendRadius, 0], [-0.5 * _length, _bendRadius, 0], [-0.5 * _length - _bendRadius, 0, 0], [-0.5 * _length, -1 * _bendRadius, 0], [0.5 * _length, -1 * _bendRadius, 0], [0.5 * _length + _bendRadius, 0, 0], [0.5 * _length, _bendRadius, 0], [0.5 * _length - 0.1 * _bendRadius, _bendRadius, 0]]
},
//list of IfcSegmentIndexSelect selects. So they are object with one key, the selected type
"Segments": [{
//index start at 1.
"IfcLineIndex": [1, 2]
}, {
"IfcArcIndex": [2, 3, 4]
}, {
"IfcLineIndex": [4, 5]
}, {
"IfcArcIndex": [5, 6, 7]
}, {
"IfcLineIndex": [7, 8]
}],
"SelfIntersect": false
},
"Radius": _barRadius
});
if (NullChecker.isNull(_sweptDisc)) {
logMsg(LogType.error, "failed to create sweptDisc");
return _instance;
}
_style = (_model as IIfcModel).createStyledItem([0.804, 0.361, 0.361, 0]);
_shape = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "AdvancedSweptSolid",
"ContextOfItems": _context.instanceHandle
});
_shape = _model.addRepItemToShape(_shape, _sweptDisc, _style);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to create shape");
return _instance;
}
_instance = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcReinforcingBar",
"name": "rebar",
"description": "procedural rebar"
});
//this save shape
_shape = _model.addShape(_instance, _shape);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "failed to add shape");
return _instance;
}
return _instance;
}
/// procedure2mv2oLjfrDIuEKk1NDY7tp =============
IInstance procedure2mv2oLjfrDIuEKk1NDY7tp(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
procedural house
procedural house. This procedure utilize other procedures.
| Template ID | 2QLj72i6168wyztwXoOYBx |
|---|---|
| Type | PIBLOCKLYPROCEDURALMODELTEMPLATE (proceduralmodel) |
| Schema | 14 (ifc4x3) |
| Input / Output | model |
| Generated Dart | procedure2QLj72i6168wyztwXoOYBx.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2QLj72i6168wyztwXoOYBx.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2QLj72i6168wyztwXoOYBx ==========
//========== type: procedure model ==========
//========== input/output: model ==========
//========== name: procedural house ==========
//========== description: procedural house ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
PIIfcModel _model = PIIfcModel.nullModel();
Dictionary _input = {};
PIProject _project = PIProject.nullProject();
var _length;
var _height;
var _width;
var _thickness;
var _ifcproject;
var _context;
var _ifcbuilding;
var _bool;
var _floor0;
var _wallWithDoorWindowProc;
var _translateTransform;
var _rotationTransform;
var _dict;
var _wall;
var _translateInput;
var _wallProc;
var _rotationInput;
var _prismProcedure;
var _floor1;
var _roof;
var _shape;
var _furnitureProc;
var _tableWidth;
var _furniture;
var _instanceTemplate;
var _tubShape;
var _instanceTempProc;
var _procInput;
var _tub;
var _platonicProcIds;
var _platonicNames;
var _id;
var _name;
var _platonicProc;
var _kerb;
var _offset;
/// end variable declarations ======================
dynamic _modelProcedure() {
//this procedure create a house with the given outer dimension: _width x _length
//It uses multiple procedures to complete its works.
//set up user input:
_templateInput = {
"front_length": "REAL",
"side_length": "REAL",
"height": "REAL"
};
_length = getDictionaryValue(_input, "front_length") ?? 8000;
if (_length < 8000) {
_length = 8000;
}
_height = getDictionaryValue(_input, "height") ?? 1800;
if (_height < 1800) {
_height = 1800;
}
_width = getDictionaryValue(_input, "side_length") ?? 0.5 * _length;
if (_width < 3000) {
_width = 3000;
}
//set all wall thickness to 200
_thickness = 200;
_model = _project.createModelEx(SupportedSchema.ifc4x3, 'procedural house', 'procedural house test', '') as PIIfcModel;
if (NullChecker.isNull(_model)) {
logMsg(LogType.error, "failed to create ifc model");
//note: model is null at this point
return _model;
}
//create the IfcProject and the a related context instances
//note: all instances are saved to model
_ifcproject = (_model as IIfcModel).createIfcProject();
if (NullChecker.isNull(_ifcproject)) {
logMsg(LogType.error, "failed to create ifcproject");
return _model;
}
//make sure geo context is created
//it would be used when creating shapes
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "geometric context not created");
return _model;
}
//create building
_ifcbuilding = _model.createInstanceFromDictionary({
kInstanceTypeKey: "ifcbuilding",
"name": "a little house"
});
//note: this save parent and child in model. A relation object is also created and save.
_bool = _model.addChild(_ifcproject, _ifcbuilding);
if (!_bool) {
logMsg(LogType.error, "failed to add building to project");
return _model;
}
//create buildingstoreys
//the top storey is for the roof
_floor0 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "ifcbuildingstorey",
"name": "floor one",
"description": "first floor of the procedural house"
});
_bool = _model.addChild(_ifcbuilding, _floor0);
if (!_bool) {
logMsg(LogType.error, "failed to add storey to building");
return _model;
}
_wallWithDoorWindowProc = getProcedureInstanceFunction('2e4tiHDP5DBwlbChTamO1P');
if (NullChecker.isNull(_wallWithDoorWindowProc)) {
logMsg(LogType.error, "wall-door-window procedure with id 2e4tiHDP5DBwlbChTamO1P not found");
return _model;
}
//set up all the transform we need
_translateTransform = getInstanceTransfromFunction('0apg8fSn94IONLhEK9Pape');
if (NullChecker.isNull(_translateTransform)) {
logMsg(LogType.error, "translate procedure id = 0apg8fSn94IONLhEK9Pape not found");
return _model;
}
_rotationTransform = getInstanceTransfromFunction('34AlzCyjHCmfV6kaR4lwsW');
if (NullChecker.isNull(_rotationTransform)) {
logMsg(LogType.error, "rotation procedure id = 34AlzCyjHCmfV6kaR4lwsW not found");
return _model;
}
_dict = {
"length": _length,
"height": _height,
"thickness": _thickness
};
//front wall
_wall = _wallWithDoorWindowProc(_model, _dict);
if (NullChecker.isNull(_wall)) {
logMsg(LogType.error, "failed to create wall");
return _model;
}
_bool = _model.addChild(_floor0, _wall);
if (!_bool) {
logMsg(LogType.error, "failed to add wall to storey");
return _model;
}
_translateInput = {
"x": 0,
"y": -0.5 * _thickness,
"z": 0
};
//we want the outer edge of the wall at the line y = 0.
_wall = _translateTransform(_model, _wall,_translateInput);
_wallProc = getProcedureInstanceFunction('1az7RSyUz1WhWPcinJax3X');
if (NullChecker.isNull(_wallProc)) {
logMsg(LogType.error, "wall procedure id = 1az7RSyUz1WhWPcinJax3X not found");
return _model;
}
//create back wall
_wall = _wallProc(_model, _dict);
if (NullChecker.isNull(_wall)) {
logMsg(LogType.error, "back wall creation failed");
return _model;
}
_bool = _model.addChild(_floor0, _wall);
//note: we must first add the wall to the floor first so there is local placement for the wall
//translate back wall in the y-direction
_translateInput = {
"x": 0,
"y": _width - (0.5 + _thickness),
"z": 0
};
//this place the outer edge of the wall at: y = length
_wall = _translateTransform(_model, _wall,_translateInput);
//create right wall
_rotationInput = {
"rotation_degree": 90
};
_dict = {
"thickness": _thickness,
"length": _width,
"height": _height
};
//create right wall
_wall = _wallProc(_model, _dict);
if (NullChecker.isNull(_wall)) {
logMsg(LogType.error, "right wall creation failed");
return _model;
}
_bool = _model.addChild(_floor0, _wall);
//rotate the wall
_wall = _rotationTransform(_model, _wall, _rotationInput);
//translate the wall
_translateInput = {
"x": 0.5 * _length - 0.5 * _thickness,
"y": 0.5 * _width - 0.5 * _thickness,
"z": 0
};
_wall = _translateTransform(_model, _wall, _translateInput);
//create left wall
_wall = _wallProc(_model, _dict);
if (NullChecker.isNull(_wall)) {
logMsg(LogType.error, "left wall creation failed");
return _model;
}
_bool = _model.addChild(_floor0, _wall);
//rotate left wall
_wall = _rotationTransform(_model, _wall, _rotationInput);
_translateInput = {
"x": -0.5 * _length + 0.5 * _thickness,
"y": 0.5 * _width - 0.5 * _thickness,
"z": 0
};
_wall = _translateTransform(_model, _wall, _translateInput);
//create storey for roof
_prismProcedure = getProcedureInstanceFunction('22JbB0ao18kvy9JK5Ui2nS');
if (NullChecker.isNull(_prismProcedure)) {
logMsg(LogType.error, "prism procedure id = 22JbB0ao18kvy9JK5Ui2nS not found");
return _model;
}
_floor1 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "Ifcbuildingstorey",
"name": "attic",
"description": "storey for attic"
});
if (NullChecker.isNull(_floor1)) {
logMsg(LogType.error, "failed to create floor1");
return _model;
}
_bool = _model.addChild(_ifcbuilding, _floor1);
_translateInput = {
"x": 0,
"y": 0,
"z": _height
};
_floor1 = _translateTransform(_model, _floor1, _translateInput);
_roof = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcSlab",
"name": "roof",
"description": "roof over the house",
"PredefinedType": "ROOF"
});
_bool = _model.addChild(_floor1, _roof);
if (!_bool) {
logMsg(LogType.error, "failed to create roof");
return _model;
}
_dict = {
"length": _length + 400,
"width": _width + 400,
"height": 500,
"top_bottom_ratio": 0.95
};
_shape = _prismProcedure(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "prism procedure failed");
return _model;
}
_bool = _model.addShape(_roof, _shape);
_translateInput = {
"x": 0,
"y": 0.5 * (_width - 200),
"z": 0
};
_roof = _translateTransform(_model, _roof, _translateInput);
//add furniture
//add table
_furnitureProc = getProcedureInstanceFunction('1OlOZDHKTBuRY9xvw7NYlX');
_tableWidth = 800;
_dict = {
"length": 1200,
"width": _tableWidth,
"thickness": 100,
"height": 600,
"radius": 50
};
_furniture = _furnitureProc(_model, _dict);
_bool = _model.addChild(_floor0, _furniture);
if (!_bool) {
logMsg(LogType.error, "table procedure failed");
return _model;
}
//put the table at the lower right corner
_translateInput = {
"x": 0.5 * _length - 1200,
"y": 0.5 * _tableWidth,
"z": 0
};
_furniture = _translateTransform(_model, _furniture, _translateInput);
//add bookshelf
_furnitureProc = getProcedureInstanceFunction('2IN6vw3516c8axFXZoC40l');
_dict = {
"length": 1200,
"width": 0.5 * _tableWidth,
"thickness": 30,
"height": 600
};
_furniture = _furnitureProc(_model, _dict);
_bool = _model.addChild(_floor0, _furniture);
if (!_bool) {
logMsg(LogType.error, "bookshelf procedure failed");
return _model;
}
_furniture = _rotationTransform(_model, _furniture, _rotationInput);
_translateInput = {
"x": 0.5 * (_length - _tableWidth),
"y": 2 * _tableWidth,
"z": 0
};
_furniture = _translateTransform(_model, _furniture, _translateInput);
//done add furniture
//add bathtub
_instanceTemplate = getInstanceTemplate('2jGXBuYnz5cARkxh6AilQl');
if (NullChecker.isNull(_instanceTemplate)) {
logMsg(LogType.error, "error getting instance template: 2jGXBuYnz5cARkxh6AilQl");
return _model;
}
_bool = (_instanceTemplate as PIBlocklyInstanceTemplate).instantiate(_model);
if (!_bool) {
logMsg(LogType.error, "error instantiating template: 2jGXBuYnz5cARkxh6AilQl");
return _model;
}
_tubShape = _instanceTemplate.getInstantiatedRootInstance();
if (NullChecker.isNull(_tubShape)) {
logMsg(LogType.error, "error instantiating template: 2jGXBuYnz5cARkxh6AilQl");
return _model;
}
_instanceTempProc = getInstanceTemplateFunction('2jGXBuYnz5cARkxh6AilQl');
if (NullChecker.isNull(_instanceTempProc)) {
logMsg(LogType.error, "error get instance template procecure");
return _model;
}
_procInput = {
"xlength": 1800,
"ylength": 800,
"zlength": 800,
"thickness": 100
};
_tubShape = _instanceTempProc(_model, _tubShape, _procInput);
if (NullChecker.isNull(_tubShape)) {
logMsg(LogType.error, "error applying instance transform");
return _model;
}
_tub = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcSanitaryTerminal",
"name": "bath tub",
"description": "boolean-substraction bath tub",
"PredefinedType": "BATH"
});
if (NullChecker.isNull(_tub)) {
logMsg(LogType.error, "error create tub");
return _model;
}
_tubShape = _model.addShape(_tub, _tubShape);
_bool = _model.addChild(_floor0, _tub);
//move tube to the right upper corner
_translateInput = {
"x": 0.5 * _length - (1800 + _thickness),
"y": _width - (900 + _thickness),
"z": 0
};
_tub = _translateTransform(_model, _tub, _translateInput);
//done bathtub
_platonicProcIds = ["0n9KilNqH9bhYh87aas9mA", "0mM5J34jX4kgenOvMG2zWq", "1ho5zHSAr9hRzZp0UTlsye", "3LN1ab6o9BmQoXpZ6tWiAF", "3oN3qaClv7XuMEsqNHOjan"];
_platonicNames = ["tetrahedron", "cube", "octahedron", "dodecahedron", "icosahedron"];
_dict = {
"edge_length": 500
};
for (var i = 0; i <= 4; i++) {
_id = _platonicProcIds[i];
_name = _platonicNames[i];
_platonicProc = getProcedureInstanceFunction(_id);
if (NullChecker.isNull(_platonicProc)) {
logMsg(LogType.error, (["instance procedure: ",_id," not found"].join()));
continue;
}
_shape = _platonicProc(_model, _dict);
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "platonic procedure ${_name} failed");
continue;
}
_kerb = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcKerb",
"name": _name,
"description": [_name,"solid"].join()
});
_bool = _model.addShape(_kerb, _shape);
_bool = _model.addChild(_floor0, _kerb);
if (i % 2 == 0) {
_offset = (i / 2) * 1000;
}else if (i == 1) {
_offset = -1000;
} else {
_offset = 2 * -1000;
}
_translateInput = {
"x": _offset,
"y": -1000,
"z": 0
};
_kerb = _translateTransform(_model, _kerb, _translateInput);
}
logMsg(LogType.error, "procedural house done.");
return _model;
}
/// procedure2QLj72i6168wyztwXoOYBx =============
PIModel procedure2QLj72i6168wyztwXoOYBx(PIProject iProject, Dictionary iInput) {
try {
_project = iProject;
_input = iInput;
return _modelProcedure();
} catch(e, stackTrace) {
logMsg(LogType.error,'error in model procedure id = 2QLj72i6168wyztwXoOYBx: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIModel.nullModel();
}
half-circle swept disc
half circle swept disc
| Template ID | 2sjKHDjuP0yB5ytOp78NFI |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure2sjKHDjuP0yB5ytOp78NFI.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2sjKHDjuP0yB5ytOp78NFI.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2sjKHDjuP0yB5ytOp78NFI ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: half-circle swept disc ==========
//========== description: half circle swept disc ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _directrixRadius;
var _discRadius;
var _context;
var _sweptDisc;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//set up user input
_templateInput = {
"directrixRadius": "REAL",
"dsicRadius": "REAL"
};
_directrixRadius = getDictionaryValue(_input, "directrixRadius") ?? 500;
_discRadius = getDictionaryValue(_input, "dsicRadius") ?? 50;
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get context");
return _instance;
}
_sweptDisc = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcSweptDiskSolid",
"Directrix": {
kInstanceTypeKey: "IfcIndexedPolyCurve",
"Points": {
kInstanceTypeKey: "IfcCartesianPointList3D",
"CoordList": [[_directrixRadius, 0, 0], [0.70710678118 * _directrixRadius, 0, 0.70710678118 * _directrixRadius], [0, 0, _directrixRadius], [-0.70710678118 * _directrixRadius, 0, 0.70710678118 * _directrixRadius], [-1 * _directrixRadius, 0, 0]]
},
//list of IfcSegmentIndexSelect selects. So they are object with one key, the selected type
"Segments": [{
//index start at 1.
"IfcArcIndex": [1, 2, 3]
}, {
//index start at 1.
"IfcArcIndex": [3, 4, 5]
}],
"SelfIntersect": false
},
"Radius": _discRadius
});
if (NullChecker.isNull(_sweptDisc)) {
logMsg(LogType.error, "failed to create sweptDisc");
return _instance;
}
_style = (_model as IIfcModel).createStyledItem([0.8, 0.6, 0.3, 0]);
if (NullChecker.isNull(_style)) {
logMsg(LogType.error, "failed to create style");
return _instance;
}
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "AdvancedSweptSolid",
"ContextOfItems": _context.instanceHandle
});
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "failed to create shape");
return _instance;
}
_instance = _model.addRepItemToShape(_instance, _sweptDisc, _style);
return _instance;
}
/// procedure2sjKHDjuP0yB5ytOp78NFI =============
IInstance procedure2sjKHDjuP0yB5ytOp78NFI(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
ifcextruded-solid
generates a rectangular extruded solid
| Template ID | 2UdehL6ZvCmeQJdY5k180h |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure2UdehL6ZvCmeQJdY5k180h.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure2UdehL6ZvCmeQJdY5k180h.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 2UdehL6ZvCmeQJdY5k180h ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifcextruded-solid ==========
//========== description: generates a rectangular extruded solid ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _x;
var _y;
var _z;
var _context;
var _extrude;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//define user input
//length run in the x-axis direction
_templateInput = {
"length": "REAL",
"width": "REAL",
"height": "REAL"
};
//take care of user input.
_x = getDictionaryValue(_input, "length") ?? 300;
_y = getDictionaryValue(_input, "width") ?? 200;
_z = getDictionaryValue(_input, "height") ?? 2500;
//get the context for shape we are about to create
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "failed to get geocontext in model");
//return from here
return _instance;
}
_extrude = _model.createInstanceFromDictionary({
"@type": "IfcExtrudedAreaSolid",
"SweptArea": {
"@type": "IfcRectangleProfileDef",
"ProfileType": "AREA",
"xDim": _x,
"yDim": _y
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _z
});
_style = (_model as IIfcModel).createStyledItem([0.8, 0.6, 0.3, 0]);
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid",
//use handle to set reference without adding inverse.
//We do this since _context is global object no need to worry about life cycle
"ContextOfItems": _context.instanceHandle
});
//this add extrude and style as composites to instance, and instance is saved
_instance = _model.addRepItemToShape(_instance, _extrude, _style);
if (NullChecker.isNull(_instance)) {
logMsg(LogType.error, "add extrude to shape failed");
}
return _instance;
}
/// procedure2UdehL6ZvCmeQJdY5k180h =============
IInstance procedure2UdehL6ZvCmeQJdY5k180h(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
IfcProduct-z-axis-rotation
rotate a IfcProduct local placement around z-axis by a given degree
| Template ID | 34AlzCyjHCmfV6kaR4lwsW |
|---|---|
| Type | PIBLOCKLYINSTANCETRANSFORMTEMPLATE (instancetransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcproduct |
| Generated Dart | procedure34AlzCyjHCmfV6kaR4lwsW.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure34AlzCyjHCmfV6kaR4lwsW.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 34AlzCyjHCmfV6kaR4lwsW ==========
//========== type: instance transform ==========
//========== input/output: ifcproduct ==========
//========== name: IfcProduct-z-axis-rotation ==========
//========== description: rotate a IfcProduct around z-axis ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _angle;
var _inputMatrix;
var _path;
var _axis2Placement;
var _resultMatrix;
var _placement;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//assumption:
//1. input instance is ifcproduct
//2. instance's objectplacement is a ifclocalplacement and is not nulll
//====================
//set up user input
_templateInput = {
"rotation_degree": "REAL"
};
_angle = getDictionaryValue(_input, "rotation_degree") ?? 0;
_angle = (_angle * Math.pi) / 180.0;
_inputMatrix = Matrix4.rotationZ(_angle);
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D"];
//If it is a PIComposer model, placement is a composed instance, no need to resolve reference
//But for other models such as reference models, it should be set to true.
_axis2Placement = _instance.getAttributeByPathAsDynamic(_path, resolveRef: true);
if (NullChecker.isNull(_axis2Placement)) {
//create the axis2placement instance if not exists
_axis2Placement = _model.createInstance(typeName: 'IfcAxis2Placement3D');
}
_resultMatrix = axis2Placement3dToMatrix(_axis2Placement);
_inputMatrix.multiply(_resultMatrix);
_axis2Placement = _model.axis2Placement3dFromMatrix(_inputMatrix);
//_inst is the instance that is actually changed, in this case it is not _instance.
_placement = _instance.setAttributeByPath(_path, _axis2Placement);
if (!NullChecker.isNull(_placement)) {
_bool = _model.saveInstance(_placement);
} else {
logMsg(LogType.error, "placement update failed");
}
logMsg(LogType.info, "apply rotation ${_angle} to instance (${_instance.typeName}, ${_instance.instanceId})");
return _instance;
}
/// procedure34AlzCyjHCmfV6kaR4lwsW =============
IInstance procedure34AlzCyjHCmfV6kaR4lwsW(PIModel iModel, IInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in instance transform id = 34AlzCyjHCmfV6kaR4lwsW: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
export-model
export model to part21 file
| Template ID | 3aZP0UfEb4SgJ38zaSslEr |
|---|---|
| Type | PIBLOCKLYGENERICPROCEDURETEMPLATE (genericprocedure) |
| Schema | 14 (ifc4x3) |
| Input / Output | N/A |
| Generated Dart | procedure3aZP0UfEb4SgJ38zaSslEr.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3aZP0UfEb4SgJ38zaSslEr.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3aZP0UfEb4SgJ38zaSslEr ==========
//========== type: generic procedure ==========
//========== input/output: N/A ==========
//========== name: export-model ==========
//========== description: export model to part21 file ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
bool _retVal = true;
Dictionary _input = {};
PIStore _store = PIStore.nullStore();
var _projectId;
var _modelId;
var _fileName;
var _bool;
var _ostream;
var _project;
var _model;
var _header;
var _handle;
var _instances;
/// end variable declarations ======================
void _printInstance(p_instance) {
//for parameter, use the prefix p_
//skip if instance is null or instance schema is not the same as model schema
//for example, user defined entity.
if (NullChecker.isNull(p_instance) || p_instance.instanceSchema != p_instance.modelSchema) {
return ;
} else {
}
//do not use global if function is recursive.
for (var instance in p_instance.getDecomposition(includeAllReferences: false)) {
_bool = _ostream.writeInstance(instance, ExportFormat.values[0]);
//log failure if occure
if (!_bool) {
logMsg(LogType.error, "instance write failed");
}
}
_bool = _ostream.writeInstance(p_instance, ExportFormat.values[0]);
}
dynamic _genericProcedure() {
//we will export content of a model by paging through all instances
//It is easily to just dump every without paging but that would load
//all instances of the model into memory
_templateInput = {
"project_id": "STRING",
"model_id": "STRING",
"file_name": "STRING"
};
_projectId = getDictionaryValue(_input, "project_id") ?? "";
_modelId = getDictionaryValue(_input, "model_id") ?? "";
_fileName = getDictionaryValue(_input, "file_name") ?? "";
//validate input
//the var inputValue is a loop varible and it should not be drag and drop outside of the loop
for (var inputValue in [_projectId, _modelId, _fileName]) {
if (inputValue.isEmpty) {
//all input must be non-empty
logMsg(LogType.error, "invalid input");
return false;
}
}
_ostream = PIFileStream();
_bool = _ostream.open(_fileName);
if (!_bool) {
logMsg(LogType.error, "could not open file for output. make sure folder exists.");
return false;
}
_project = _store.getProject(_projectId);
if (NullChecker.isNull(_project)) {
return false;
}
//load the project...
_bool = _project.activateProject();
_model = _project.getModel(_modelId);
if (NullChecker.isNull(_model)) {
logMsg(LogType.error, "model not found");
return false;
}
_header = _model.getHeader();
if (NullChecker.isNull(_header)) {
logMsg(LogType.error, "model header is null");
return false;
}
//Write the header section. This first writes the ISO10303 document start
_bool = _ostream.writeHeaderInstance(_header, ExportFormat.values[0]);
//insert empty line
_bool = _ostream.writeString('\n');
//write data section start
_bool = _ostream.writeString('DATA;\n');
_handle = InstanceHandle.fromJson({
kInstanceTypeKey: 0,
"instanceId": 0
});
_instances = _model.getInstancesPaginated(_handle, pageSize: 1000);
while (!_instances.isEmpty) {
//the var inst is a loop varible and it should not be drag and drop outside of the loop
for (var inst in _instances) {
_printInstance(inst);
}
//set up the starting point for the next page.
_handle = (_instances.last).instanceHandle;
_instances = _model.getInstancesPaginated(_handle, pageSize: 1000);
}
//write data section end
_bool = _ostream.writeString('ENDSEC;\n');
//write part 21 end
_bool = _ostream.writeString('END-ISO-10303-21;\n');
_bool = _ostream.flush();
_bool = _ostream.close();
return _retVal;
}
/// procedure3aZP0UfEb4SgJ38zaSslEr =============
bool procedure3aZP0UfEb4SgJ38zaSslEr(PIStore iStore, Dictionary iInput) {
try {
_store = iStore;
_input = iInput;
return _genericProcedure() as bool;
} catch(e) {
logMsg(LogType.error, 'error in procedure: ${e.toString()}');
}
return false;
}
IfcProduct-x-axis-rotation
rotates a product placement around the x-axis (angle in degree)
| Template ID | 3ba1LOlWP1VOfQE0waIRua |
|---|---|
| Type | PIBLOCKLYINSTANCETRANSFORMTEMPLATE (instancetransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcproduct |
| Generated Dart | procedure3ba1LOlWP1VOfQE0waIRua.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3ba1LOlWP1VOfQE0waIRua.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3ba1LOlWP1VOfQE0waIRua ==========
//========== type: instance transform ==========
//========== input/output: ifcproduct ==========
//========== name: IfcProduct-x-axis-rotation ==========
//========== description: rotates a ifcproduct around the x-axis in degree ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
var _angle;
PIIfcModel _model = PIIfcModel.nullModel();
var _inputMatrix;
var _path;
var _axis2Placement;
var _resultMatrix;
var _inst;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
_templateInput = {
"rotation_degree": "REAL"
};
_angle = getDictionaryValue(_input, "rotation_degree") ?? 0;
_angle = (_angle * Math.pi) / 180.0;
_inputMatrix = Matrix4.rotationX(_angle);
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D"];
//If it is a PIComposer model, placement is a composed instance, no need to resolve reference
//But for other models such as reference models, it should be set to true.
_axis2Placement = _instance.getAttributeByPathAsDynamic(_path, resolveRef: true);
if (NullChecker.isNull(_axis2Placement)) {
_axis2Placement = _model.createInstance(typeName: 'IfcAxis2Placement3D');
}
_resultMatrix = axis2Placement3dToMatrix(_axis2Placement);
_inputMatrix.multiply(_resultMatrix);
_axis2Placement = _model.axis2Placement3dFromMatrix(_inputMatrix);
_inst = _instance.setAttributeByPath(_path, _axis2Placement);
_bool = _model.saveInstance(_inst);
return _instance;
}
/// procedure3ba1LOlWP1VOfQE0waIRua =============
IInstance procedure3ba1LOlWP1VOfQE0waIRua(PIModel iModel, IInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in instance transform id = 3ba1LOlWP1VOfQE0waIRua: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIInstance.nullInstance();
}
rotation-around-axis
rotate product placement around any axis (angle in degree)
| Template ID | 3H3Ck84DX72OZJGGk1cl6M |
|---|---|
| Type | PIBLOCKLYINSTANCETRANSFORMTEMPLATE (instancetransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcproduct |
| Generated Dart | procedure3H3Ck84DX72OZJGGk1cl6M.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3H3Ck84DX72OZJGGk1cl6M.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3H3Ck84DX72OZJGGk1cl6M ==========
//========== type: instance transform ==========
//========== input/output: ifcproduct ==========
//========== name: rotation-around-axis ==========
//========== description: rotate an ifcproduct around an axis with angle in degree ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _angle;
var _axisX;
var _axisY;
var _axisZ;
var _doubleList;
var _axis;
var _vectorLength;
var _quaternion;
var _rotation;
var _transform;
var _path;
var _axis2Placement;
var _instMatrix;
var _inst;
var _bool;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//we assume the input instance's objectplacement is a ifclocalplacement
//declare user inputs
_templateInput = {
"rotation_degree": "REAL",
"axis-x": "REAL",
"axis-y": "REAL",
"axis-z": "REAL"
};
_angle = getDictionaryValue(_input, "rotation_degree") ?? 0;
_axisX = getDictionaryValue(_input, "axis-x") ?? 0;
_axisY = getDictionaryValue(_input, "axis-y") ?? 0;
_axisZ = getDictionaryValue(_input, "axis-z") ?? 0;
//_doubleList might just be a list of num (dart). so need coercion to doubles
_doubleList = toTypedList<double>([_axisX, _axisY, _axisZ]).getOrElse(() => <double>[]);
_axis = Vector3.array(_doubleList);
_vectorLength = _axis.normalize();
if (_vectorLength < 1e-10) {
//no valid axis input, default to z-axis
_doubleList = toTypedList<double>([0, 0, 1]).getOrElse(() => <double>[]);
_axis = Vector3.array(_doubleList);
}
//convert angle from degree to radian
_angle = (_angle * Math.pi) / 180.0;
//use quaternion to get the rotation matrix
_quaternion = Quaternion.axisAngle(_axis, _angle);
_rotation = _quaternion.asRotationMatrix();
_transform = Matrix4.identity();
_transform.setRotation(_rotation);
_path = ["ObjectPlacement", "RelativePlacement", "IfcAxis2Placement3D"];
_axis2Placement = _instance.getAttributeByPathAsDynamic(_path, resolveRef: true);
if (NullChecker.isNull(_axis2Placement)) {
_axis2Placement = _model.createInstance(typeName: 'IfcAxis2Placement3D');
}
_instMatrix = axis2Placement3dToMatrix(_axis2Placement);
_transform.multiply(_instMatrix);
_axis2Placement = _model.axis2Placement3dFromMatrix(_transform);
_inst = _instance.setAttributeByPath(_path, _axis2Placement);
_bool = _model.saveInstance(_inst);
return _instance;
}
/// procedure3H3Ck84DX72OZJGGk1cl6M =============
IInstance procedure3H3Ck84DX72OZJGGk1cl6M(PIModel iModel, IInstance iInstance, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_instance = iInstance;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in instance transform: ${e.toString()}');
}
return PIInstance.nullInstance();
}
ifc-platonic-dodecahedron
platonic dodecahedron brep
| Template ID | 3LN1ab6o9BmQoXpZ6tWiAF |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure3LN1ab6o9BmQoXpZ6tWiAF.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3LN1ab6o9BmQoXpZ6tWiAF.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3LN1ab6o9BmQoXpZ6tWiAF ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-platonic-dodecahedron ==========
//========== description: platonic dodecahedron brep ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
var _edgeLength;
PIIfcModel _model = PIIfcModel.nullModel();
var _halfEdge;
var _phi;
var _b;
var _c;
var _geoContext;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _pt6;
var _pt7;
var _pt8;
var _pt9;
var _pt10;
var _pt11;
var _pt12;
var _pt13;
var _pt14;
var _pt15;
var _pt16;
var _pt17;
var _pt18;
var _pt19;
var _brep;
var _bool;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
_templateInput = {
"edge_length": "REAL"
};
_edgeLength = getDictionaryValue(_input, "edge_length") ?? 1000;
_halfEdge = 0.5 * _edgeLength;
_phi = (1 + Math.sqrt(5)) / 2;
_b = _halfEdge / _phi;
_c = _halfEdge / (_phi * _phi);
_geoContext = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_geoContext)) {
return _instance;
}
_pt0 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [0, _halfEdge, _c]
});
_pt1 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [0, _halfEdge, -1 * _c]
});
_pt2 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [0, -1 * _halfEdge, _c]
});
_pt3 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [0, -1 * _halfEdge, -1 * _c]
});
_pt4 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_halfEdge, _c, 0]
});
_pt5 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_halfEdge, -1 * _c, 0]
});
_pt6 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _halfEdge, _c, 0]
});
_pt7 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _halfEdge, -1 * _c, 0]
});
_pt8 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_b, _b, _b]
});
_pt9 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_b, _b, -1 * _b]
});
_pt10 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_b, -1 * _b, _b]
});
_pt11 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_b, -1 * _b, -1 * _b]
});
_pt12 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _b, _b, _b]
});
_pt13 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _b, _b, -1 * _b]
});
_pt14 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _b, -1 * _b, _b]
});
_pt15 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _b, -1 * _b, -1 * _b]
});
_pt16 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_c, 0, _halfEdge]
});
_pt17 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [_c, 0, -1 * _halfEdge]
});
_pt18 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _c, 0, _halfEdge]
});
_pt19 = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcCartesianPoint",
"coordinates": [-1 * _c, 0, -1 * _halfEdge]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
"outer": {
"@type": "IfcClosedShell",
"CfsFaces": [{
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt16.instanceHandle, _pt18.instanceHandle, _pt12.instanceHandle, _pt0.instanceHandle, _pt8.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt18.instanceHandle, _pt16.instanceHandle, _pt10.instanceHandle, _pt2.instanceHandle, _pt14.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt17.instanceHandle, _pt19.instanceHandle, _pt15.instanceHandle, _pt3.instanceHandle, _pt11.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt19.instanceHandle, _pt17.instanceHandle, _pt9.instanceHandle, _pt1.instanceHandle, _pt13.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt0.instanceHandle, _pt8.instanceHandle, _pt4.instanceHandle, _pt9.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt1.instanceHandle, _pt13.instanceHandle, _pt6.instanceHandle, _pt12.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt2.instanceHandle, _pt14.instanceHandle, _pt7.instanceHandle, _pt15.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt3.instanceHandle, _pt11.instanceHandle, _pt5.instanceHandle, _pt10.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt4.instanceHandle, _pt5.instanceHandle, _pt10.instanceHandle, _pt16.instanceHandle, _pt8.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt5.instanceHandle, _pt4.instanceHandle, _pt9.instanceHandle, _pt17.instanceHandle, _pt11.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt6.instanceHandle, _pt7.instanceHandle, _pt15.instanceHandle, _pt19.instanceHandle, _pt13.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt7.instanceHandle, _pt6.instanceHandle, _pt12.instanceHandle, _pt18.instanceHandle, _pt14.instanceHandle]
}
}]
}]
}
});
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep",
"ContextOfItems": _geoContext.instanceHandle
});
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5, _pt6, _pt7, _pt8, _pt9, _pt10, _pt11, _pt12, _pt13, _pt14, _pt15, _pt16, _pt17, _pt18, _pt19]);
_style = (_model as IIfcModel).createStyledItem([0.596078431372549, 0.8352941176470589, 0.9058823529411765, 1]);
_instance = _model.addRepItemToShape(_instance, _brep, _style);
return _instance;
}
/// procedure3LN1ab6o9BmQoXpZ6tWiAF =============
IInstance procedure3LN1ab6o9BmQoXpZ6tWiAF(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
ifc-platonic-icosahedron
platonic icosahedron brep
| Template ID | 3oN3qaClv7XuMEsqNHOjan |
|---|---|
| Type | PIBLOCKLYPROCEDURALENTITYTEMPLATE (proceduralentity) |
| Schema | 14 (ifc4x3) |
| Input / Output | ifcshaperepresentation |
| Generated Dart | procedure3oN3qaClv7XuMEsqNHOjan.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3oN3qaClv7XuMEsqNHOjan.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3oN3qaClv7XuMEsqNHOjan ==========
//========== type: procedure entity ==========
//========== input/output: ifcshaperepresentation ==========
//========== name: ifc-platonic-icosahedron ==========
//========== description: platonic icosahedron brep ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
IInstance _instance = PIInstance.nullInstance();
Dictionary _input = {};
PIIfcModel _model = PIIfcModel.nullModel();
var _edgeLength;
var _phi;
var _a;
var _b;
var _geoContext;
var _pt0;
var _pt1;
var _pt2;
var _pt3;
var _pt4;
var _pt5;
var _pt6;
var _pt7;
var _pt8;
var _pt9;
var _pt10;
var _pt11;
var _brep;
var _bool;
var _style;
/// end variable declarations ======================
dynamic _instanceProcedure() {
//set up user input
_templateInput = {
"edge_length": "REAL"
};
//get user entered input
_edgeLength = getDictionaryValue(_input, "edge_length") ?? 1000;
_phi = (1 + Math.sqrt(5)) / 2;
_a = _edgeLength / 2;
_b = _edgeLength / (2 * _phi);
_geoContext = (_model as IIfcModel).getBody3dGeometricContext();
//note: _instance is a null object at this point
if (NullChecker.isNull(_geoContext)) {
return _instance;
}
_pt0 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, _b, _a]
});
_pt1 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, _b, -1 * _a]
});
_pt2 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, -1 * _b, _a]
});
_pt3 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [0, -1 * _b, -1 * _a]
});
_pt4 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_a, 0, _b]
});
_pt5 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_a, 0, -1 * _b]
});
_pt6 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [-1 * _a, 0, _b]
});
_pt7 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [-1 * _a, 0, -1 * _b]
});
_pt8 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_b, _a, 0]
});
_pt9 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [_b, -1 * _a, 0]
});
_pt10 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [-1 * _b, _a, 0]
});
_pt11 = _model.createInstanceFromDictionary({
"@type": "IfcCartesianPoint",
"coordinates": [-1 * _b, -1 * _a, 0]
});
_brep = _model.createInstanceFromDictionary({
"@type": "IfcFacetedBrep",
//shell is composed in brep
"Outer": {
"@type": "IfcClosedShell",
//faces composed in closed shell
"CfsFaces": [{
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt8.instanceHandle, _pt10.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt10.instanceHandle, _pt8.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt2.instanceHandle, _pt6.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt4.instanceHandle, _pt2.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt3.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt7.instanceHandle, _pt3.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt9.instanceHandle, _pt11.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt11.instanceHandle, _pt9.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt10.instanceHandle, _pt6.instanceHandle, _pt7.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt11.instanceHandle, _pt7.instanceHandle, _pt6.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt8.instanceHandle, _pt5.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt9.instanceHandle, _pt4.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt6.instanceHandle, _pt10.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt0.instanceHandle, _pt8.instanceHandle, _pt4.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt10.instanceHandle, _pt7.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt1.instanceHandle, _pt5.instanceHandle, _pt8.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt7.instanceHandle, _pt11.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt3.instanceHandle, _pt9.instanceHandle, _pt5.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt11.instanceHandle, _pt6.instanceHandle]
}
}]
}, {
"@type": "ifcface",
"Bounds": [{
"@type": "IfcFaceOuterBound",
"Orientation": true,
"bound": {
"@type": "IfcPolyLoop",
"Polygon": [_pt2.instanceHandle, _pt4.instanceHandle, _pt9.instanceHandle]
}
}]
}]
}
});
_instance = _model.createInstanceFromDictionary({
"@type": "IfcShapeRepresentation",
"RepresentationIdentifier": "Body",
"RepresentationType": "Brep",
"ContextOfItems": _geoContext.instanceHandle
});
_bool = _instance.setCompositesDynamic([_pt0, _pt1, _pt2, _pt3, _pt4, _pt5, _pt6, _pt7, _pt8, _pt9, _pt10, _pt11]);
_style = (_model as IIfcModel).createStyledItem([0.596078431372549, 0.8352941176470589, 0.9058823529411765, 1]);
//_brep added as composite to _instance also
_instance = _model.addRepItemToShape(_instance, _brep, _style);
return _instance;
}
/// procedure3oN3qaClv7XuMEsqNHOjan =============
IInstance procedure3oN3qaClv7XuMEsqNHOjan(PIModel iModel, Dictionary iInput) {
try {
_model = iModel as PIIfcModel;
_input = iInput;
return _instanceProcedure() as PIInstance;
} catch(e) {
logMsg(LogType.error, 'error in entity procedure: ${e.toString()}');
}
return PIInstance.nullInstance();
}
wall-along-indexed-poly-curve
add walls along a indexed poly curve
| Template ID | 3SDT3v5tPECAR8EHTlkJ5k |
|---|---|
| Type | PIBLOCKLYMODELTRANSFORMTEMPLATE (modeltransform) |
| Schema | 14 (ifc4x3) |
| Input / Output | model |
| Generated Dart | procedure3SDT3v5tPECAR8EHTlkJ5k.dart |
Open in Workspace Viewer → ↑ back to table of contents
Show generated Dart source (procedure3SDT3v5tPECAR8EHTlkJ5k.dart)
// ignore_for_file: unused_import, unused_element, file_names, empty_catches, depend_on_referenced_packages
// ignore_for_file: prefer_typing_uninitialized_variables, library_prefixes, non_constant_identifier_names
// ignore_for_file: no_leading_underscores_for_local_identifiers, strict_top_level_inference
import 'dart:math' as Math;
import 'dart:convert';
import 'dart:io';
import 'package:vector_math/vector_math_64.dart';
import 'package:fpdart/fpdart.dart';
import 'package:schema_interface/schema_interface.dart';
import 'package:store_interface/store_interface.dart';
import 'package:schema_ffi/schema_ffi.dart';
import 'package:store_ffi/store_ffi.dart';
import 'package:picomposer_procedures/picomposer_procedures.dart';
//========== templateId: 3SDT3v5tPECAR8EHTlkJ5k ==========
//========== type: model transform ==========
//========== input/output: model ==========
//========== name: wall-along-indexed-poly-curve ==========
//========== description: add walls along a indexed poly curve ==========
//========== schema: ifc4x3 ==========
/// start variable declarations ======================
Dictionary _templateInput = {};
PIIfcModel _model = PIIfcModel.nullModel();
Dictionary _input = {};
PIProject _project = PIProject.nullProject();
var _segments;
var _coordList;
var _height;
var _thickness;
var _curveId;
var _storeyId;
var _arcIndexId;
var _handle;
var _storey;
var _extrude;
var _shape;
var _wallProcedure;
var _curve;
var _context;
var _points;
var _segCount;
var _segment;
var _wall;
var _bool;
/// end variable declarations ======================
dynamic _toZeroBaseIndex(indices, l_zeroBased) {
//this function convert one based index list to zero base list
l_zeroBased = [];
for (var i in indices) {
l_zeroBased.add((i - 1));
}
return l_zeroBased;
}
dynamic _getLimitingLineFromArcSegment(segment, isStarting, l_indices, l_pt1, l_pt2, l_pt3, l_center, l_dir) {
//this function returns a line from the center of the arc
//to the start point or the end point of the arc. Lines are represented as two list of doubles
//the first pair of double is the point, the second is the direction
l_indices = _toZeroBaseIndex(segment.getInts(), null);
if (l_indices.length != 3) {
return [];
}
l_pt1 = _coordList[l_indices.first];
l_pt2 = _coordList[l_indices[1]];
l_pt3 = _coordList[l_indices.last];
l_center = _getArcCenter(segment, null, null, null, null, null, null, null, null, null, null, null, null, null);
if (isStarting) {
l_dir = _directionFromPoints(l_center, l_pt1, null);
} else {
l_dir = _directionFromPoints(l_center, l_pt3, null);
}
return [l_center, l_dir];
}
dynamic _getArcCenter(segment, l_indices, l_d, l_d1, l_d2, l_d3, l_s1, l_s2, l_s3, l_pt1, l_pt2, l_pt3, l_x, l_y) {
//this function returns the center of the arc segment
//It assumes that the point are non-colinear
//points are represented as a list of two doubles
l_indices = _toZeroBaseIndex(segment.getInts(), null);
if (l_indices.length != 3) {
return [];
}
l_pt1 = _coordList[l_indices.first];
l_pt2 = _coordList[l_indices[1]];
l_pt3 = _coordList[l_indices.last];
l_s1 = l_pt1.first * l_pt1.first + l_pt1.last * l_pt1.last;
l_s2 = l_pt2.first * l_pt2.first + l_pt2.last * l_pt2.last;
l_s3 = l_pt3.first * l_pt3.first + l_pt3.last * l_pt3.last;
l_d1 = l_pt1.first * (l_pt2.last - l_pt3.last);
l_d2 = l_pt2.first * (l_pt3.last - l_pt1.last);
l_d3 = l_pt3.first * (l_pt1.last - l_pt2.last);
l_d = 2 * (l_d1 + (l_d2 + l_d3));
l_x = l_s1 * (l_pt2.last - l_pt3.last) + (l_s2 * (l_pt3.last - l_pt1.last) + l_s3 * (l_pt1.last - l_pt2.last));
l_y = l_s1 * (l_pt3.first - l_pt2.first) + (l_s2 * (l_pt1.first - l_pt3.first) + l_s3 * (l_pt2.first - l_pt1.first));
l_x = l_x / l_d;
l_y = l_y / l_d;
return [l_x, l_y];
}
dynamic _isCloseCurve(l_firstSeg, l_lastSeg, l_firstIndex, l_lastIndex) {
//this function check whether the indexed poly curve is close or not
if (_segments.length < 3) {
return false;
}
l_firstSeg = _segments.first;
l_lastSeg = _segments.last;
l_firstIndex = l_firstSeg.getInts().first;
l_lastIndex = l_lastSeg.getInts().last;
return l_firstIndex == l_lastIndex;
}
dynamic _directionFromPoints(pt1, pt2, l_dir) {
//this function returns the normal direction from pt1 to pt2
//vectors are represented as list of two doubles
l_dir = [pt2.first - pt1.first, pt2.last - pt1.last];
return _normalizeVector(l_dir, null);
}
dynamic _computeBisectingVector(vect1, vect2, l_epsilon, l_v1, l_v2, l_sum) {
//given two vectors, this function return a vector that bisect the two
l_epsilon = 1e-8;
l_v1 = _normalizeVector(vect1, null);
l_v2 = _normalizeVector(vect2, null);
l_sum = [l_v1.first + l_v2.first, l_v1.last + l_v2.last];
//opposite vectors
if (_2dDistance([0, 0], l_sum, null, null) < l_epsilon) {
return [-1 * l_v1.last, l_v1.first];
}
return _normalizeVector(l_sum, null);
}
dynamic _invertVector(vect) {
//this function inverts a given vector
return [-1 * vect.first, -1 * vect.last];
}
dynamic _computeLinesIntersection(line1, line2, l_pt1, l_vt1, l_pt2, l_vt2, l_diff, l_det, l_ratio) {
//this function computes the intersection of two lines
l_pt1 = line1.first;
l_vt1 = line1.last;
l_pt2 = line2.first;
l_vt2 = line2.last;
l_diff = (l_pt2.first - l_pt1.first) * l_vt2.last - (l_pt2.last - l_pt1.last) * l_vt2.first;
l_det = l_vt1.first * l_vt2.last - l_vt2.first * l_vt1.last;
l_ratio = l_diff / l_det;
return [l_pt1.first + l_vt1.first * l_ratio, l_pt1.last + l_vt1.last * l_ratio];
}
dynamic _normalizeVector(vect, l_norm) {
//this function normalizes a given vector. The vector is assume to be nontrivial
l_norm = Math.sqrt(vect.first * vect.first + vect.last * vect.last);
return [vect.first / l_norm, vect.last / l_norm];
}
dynamic _2dDistance(pt1, pt2, l_diffx, l_diffy) {
//this function computes the distance between 2 points
l_diffx = pt1.first - pt2.first;
l_diffy = pt1.last - pt2.last;
return Math.sqrt(l_diffx * l_diffx + l_diffy * l_diffy);
}
dynamic _evalPointOnLine(line, t, l_pt, l_vt) {
//this function evaluate the line at parameter t and returns the point
//a line is a pair of list of doubles
l_pt = line.first;
l_vt = line.last;
return [l_pt.first + t * l_vt.first, l_pt.last + t * l_vt.last];
}
dynamic _lineFromTwoPoints(pt1, pt2, l_dir) {
//this function constructs a line from two points
l_dir = _directionFromPoints(pt1, pt2, null);
return [pt1, l_dir];
}
dynamic _getParellelline(line, offset, l_prepDir) {
l_prepDir = [-1 * (line.last).last, (line.last).first];
return [_evalPointOnLine([line.first, l_prepDir], offset, null, null), line.last];
}
dynamic _getArcWallRadiis(center, ray1, ray2, segIndex, radius, l_radiis, l_limitingIndex, l_isStart, l_limitingSegment, l_indices, l_pt1, l_pt2, l_line, l_line1, l_line2, l_pt, l_ray) {
//this function computes the intersection between an arc and a line portion of the wall system
//Always use the starting line as limit
l_radiis = [radius - 0.5 * _thickness, radius + 0.5 * _thickness];
logMsg(LogType.error, "radius is: $radius");
logMsg(LogType.error, "initial radiis is: (${l_radiis[0]},${l_radiis[1]}) ");
if (_segments.length == 1) {
return l_radiis;
}
if (segIndex == 0) {
l_limitingIndex = 1;
l_isStart = false;
} else {
l_limitingIndex = segIndex - 1;
l_isStart = true;
}
l_limitingSegment = _segments[l_limitingIndex];
//just use default radiis if consecutive arcs
if (_arcIndexId == toTypeId(l_limitingSegment.selectedTypeName)) {
return l_radiis;
}
l_indices = _toZeroBaseIndex(l_limitingSegment.getInts(), null);
l_pt1 = _coordList[l_indices.first];
l_pt2 = _coordList[l_indices.last];
l_line = _lineFromTwoPoints(l_pt1, l_pt2, null);
l_line1 = _getParellelline(l_line, -0.5 * _thickness, null);
l_line2 = _getParellelline(l_line, 0.5 * _thickness, null);
if (l_isStart) {
l_ray = ray1;
} else {
l_ray = ray2;
}
l_pt = _computeLinesIntersection(l_ray, l_line1, null, null, null, null, null, null, null);
l_radiis[0] = _2dDistance(center, l_pt, null, null);
l_pt = _computeLinesIntersection(l_ray, l_line2, null, null, null, null, null, null, null);
l_radiis[1] = _2dDistance(center, l_pt, null, null);
logMsg(LogType.error, "radiis is: (${l_radiis[0]},${l_radiis[1]}) ");
return l_radiis;
}
dynamic _wallFromArcSegment(segment, segIndex, l_indices, l_pt1, l_pt2, l_pt3, l_center, l_radius, l_radiis, l_line1, l_line2, l_line3, l_indexedCurve, l_wall) {
//this function creates a circular wall with _thickness and _height centered on the arc segment.
l_indices = _toZeroBaseIndex(segment.getInts(), null);
if (l_indices.length != 3) {
return PIInstance.nullInstance();
}
l_pt1 = _coordList[l_indices.first];
l_pt2 = _coordList[l_indices[1]];
l_pt3 = _coordList[l_indices.last];
l_center = _getArcCenter(segment, null, null, null, null, null, null, null, null, null, null, null, null, null);
if (l_center.isEmpty) {
logMsg(LogType.error, "compute center for arc segment failed");
return PIInstance.nullInstance();
}
l_radius = _2dDistance(l_center, l_pt1, null, null);
l_line1 = _lineFromTwoPoints(l_center, l_pt1, null);
l_line2 = _lineFromTwoPoints(l_center, l_pt2, null);
l_line3 = _lineFromTwoPoints(l_center, l_pt3, null);
l_radiis = _getArcWallRadiis(l_center, l_line1, l_line3, segIndex, l_radius, null, null, null, null, null, null, null, null, null, null, null, null);
l_indexedCurve = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcIndexedPolyCurve",
"points": {
kInstanceTypeKey: "IfcCartesianPointList2D",
"CoordList": [_evalPointOnLine(l_line1, l_radiis.first, null, null), _evalPointOnLine(l_line1, l_radiis.last, null, null), _evalPointOnLine(l_line2, l_radiis.last, null, null), _evalPointOnLine(l_line3, l_radiis.last, null, null), _evalPointOnLine(l_line3, l_radiis.first, null, null), _evalPointOnLine(l_line2, l_radiis.first, null, null)]
},
"segments": [{
//first index start at 1 instead of the typical 0
"IfcLineIndex": [1, 2]
}, {
"IfcArcIndex": [2, 3, 4]
}, {
"IfcLineIndex": [4, 5]
}, {
"IfcArcIndex": [5, 6, 1]
}],
"SelfIntersect": false
});
_extrude = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcExtrudedAreaSolid",
"SweptArea": {
kInstanceTypeKey: "IfcArbitraryClosedProfileDef",
"ProfileType": "AREA",
"OuterCurve": l_indexedCurve
},
"ExtrudedDirection": {
"DirectionRatios": [0, 0, 1]
},
"Depth": _height
});
_shape = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcShapeRepresentation",
"ContextOfItems": _context.instanceHandle,
"RepresentationIdentifier": "Body",
"RepresentationType": "SweptSolid"
});
_shape = _model.addRepItemToShape(_shape, _extrude, PIInstance.nullInstance());
if (NullChecker.isNull(_shape)) {
logMsg(LogType.error, "shape creation failed");
return PIInstance.nullInstance();
}
l_wall = _model.createInstanceFromDictionary({
kInstanceTypeKey: "IfcWall",
"name": "wall from arc",
"description": "wall generated from arc segement"
});
_shape = _model.addShape(l_wall, _shape);
return l_wall;
}
dynamic _wallFromLineSegment(segment, segIndex, l_indices, l_pt1, l_pt2, l_dir, l_prep, l_line, l_line1, l_line2, l_limit1, l_limit2, l_startSegment, l_endSegement, l_procInput, l_wall) {
//This function create a wall with _thickness and _height centered on a line segment
//we create the indexed curve profile by computing the limiting lines
//then take intersections
l_indices = _toZeroBaseIndex(segment.getInts(), null);
if (l_indices.length != 2) {
return PIInstance.nullInstance();
}
l_pt1 = _coordList[l_indices.first];
l_pt2 = _coordList[l_indices.last];
//line for the segment
l_dir = _directionFromPoints(l_pt1, l_pt2, null);
l_line = _lineFromTwoPoints(l_pt1, l_pt2, null);
l_line1 = _getParellelline(l_line, -0.5 * _thickness, null);
l_line2 = _getParellelline(l_line, 0.5 * _thickness, null);
if (_isCloseCurve(null, null, null, null)) {
if (segIndex == 0) {
l_startSegment = _segments[_segments.length - 1];
} else {
l_startSegment = _segments[segIndex - 1];
}
//first case where starting limiting segment is an arc
if (_arcIndexId == toTypeId(l_startSegment.selectedTypeName)) {
//isStarting is false because we want the ending line from the arc segment
l_limit1 = _getLimitingLineFromArcSegment(l_startSegment, false, null, null, null, null, null, null);
} else {
//repurposing some local variables
l_indices = _toZeroBaseIndex(l_startSegment.getInts(), null);
//we want a vector going away from the starting point of segment
l_prep = _directionFromPoints(_coordList[l_indices.last], _coordList[l_indices.first], null);
l_limit1 = [l_pt1, _normalizeVector(_computeBisectingVector(l_dir, l_prep, null, null, null, null), null)];
}
//now the other line
if (segIndex == _segments.length - 1) {
l_endSegement = _segments.first;
} else {
l_endSegement = _segments[segIndex + 1];
}
if (_arcIndexId == toTypeId(l_endSegement.selectedTypeName)) {
//isStarting is true this time
l_limit2 = _getLimitingLineFromArcSegment(l_endSegement, true, null, null, null, null, null, null);
} else {
//repurposing some local variables
l_indices = _toZeroBaseIndex(l_endSegement.getInts(), null);
l_prep = _directionFromPoints(_coordList[l_indices.first], _coordList[l_indices.last], null);
l_limit2 = [l_pt2, _normalizeVector(_computeBisectingVector(_invertVector(l_dir), l_prep, null, null, null, null), null)];
}
} else {
if (segIndex == 0) {
l_limit1 = [l_pt1, l_prep];
} else {
l_startSegment = _segments[segIndex - 1];
if (_arcIndexId == toTypeId(l_startSegment.selectedTypeName)) {
//isStarting is false because we want the ending line from the arc segment
l_limit1 = _getLimitingLineFromArcSegment(l_startSegment, false, null, null, null, null, null, null);
} else {
//repurposing some local variables
l_indices = _toZeroBaseIndex(l_startSegment.getInts(), null);
//we want a vector going away from the starting point of segment
l_prep = _directionFromPoints(_coordList[l_indices.last], _coordList[l_indices.first], null);
l_limit1 = [l_pt1, _normalizeVector(_computeBisectingVector(l_dir, l_prep, null, null, null, null), null)];
}
}
if (segIndex == _segments.length - 1) {
l_limit2 = [l_pt2, l_prep];
} else {
l_endSegement = _segments[segIndex + 1];
if (_arcIndexId == toTypeId(l_endSegement.selectedTypeName)) {
l_limit2 = _getLimitingLineFromArcSegment(l_endSegement, true, null, null, null, null, null, null);
} else {
l_indices = _toZeroBaseIndex(l_endSegement.getInts(), null);
l_prep = _directionFromPoints(_coordList[l_indices.first], _coordList[l_indices.last], null);
l_limit2 = [l_pt2, _normalizeVector(_computeBisectingVector(_invertVector(l_dir), l_prep, null, null, null, null), null)];
}
}
}
l_procInput = {
"height": _height,
"coord_list": [_computeLinesIntersection(l_line1, l_limit1, null, null, null, null, null, null, null), _computeLinesIntersection(l_line2, l_limit1, null, null, null, null, null, null, null), _computeLinesIntersection(l_line2, l_limit2, null, null, null, null, null, null, null), _computeLinesIntersection(l_line1, l_limit2, null, null, null, null, null, null, null)],
"segment_indices": [[1, 2], [2, 3], [3, 4], [4, 1]]
};
l_wall = _wallProcedure(_model, l_procInput);
if (NullChecker.isNull(l_wall)) {
logMsg(LogType.error, "wall creation failed");
}
return l_wall;
}
dynamic _modelProcedure() {
//this procedure construct a wall system a long a given path and add all the wall to the storey
//Note: by convention, global variables in file are prefix with the underscore _. This
//is necessary to avoid name collision. The underscore keep the variable private to this file. Function parameters are hidden in global scope and do not need to follow this rule.
//function local variables are defined as parameters and prefix with l_
//set up user input
_templateInput = {
"height": "REAL",
"thickness": "REAL",
"curve_id": "INT64",
"storey_id": "INT64"
};
_height = getDictionaryValue(_input, "height") ?? 2000;
if (_height < 1000) {
_height = 1000;
}
_thickness = getDictionaryValue(_input, "thickness") ?? 100;
if (_thickness < 100) {
_thickness = 100;
}
_curveId = getDictionaryValue(_input, "curve_id") ?? 0;
_storeyId = getDictionaryValue(_input, "storey_id") ?? 0;
_handle = InstanceHandle.fromJson({
"instanceId": _storeyId,
kInstanceTypeKey: "IfcBuildingStorey"
});
_storey = _model.getInstance(_handle);
if (NullChecker.isNull(_storey)) {
logMsg(LogType.error, "storey not found");
return _model;
}
_handle = InstanceHandle.fromJson({
"instanceId": _curveId,
kInstanceTypeKey: "IfcIndexedPolyCurve"
});
_curve = _model.getInstance(_handle);
if (NullChecker.isNull(_curve)) {
logMsg(LogType.error, "indexed curved not found");
return _model;
}
_context = (_model as IIfcModel).getBody3dGeometricContext();
if (NullChecker.isNull(_context)) {
logMsg(LogType.error, "geo context not found");
return _model;
}
//we do not need to set resolve reference = true since we know _curve composed its attribute
_points = _curve.getInstance(attName: 'Points');
//_coordList and _segments will be consume by other functions
_coordList = _points.getReals2(attName: 'CoordList');
_segments = _curve.getSelects(attName: 'Segments');
_arcIndexId = toTypeId('IfcArcIndex');
_wallProcedure = getProcedureInstanceFunction('0H1Nh1zlXD7v871tZBuXTG');
if (NullChecker.isNull(_wallProcedure)) {
logMsg(LogType.error, "wall proceudre 0H1Nh1zlXD7v871tZBuXTG not found");
return _model;
}
_segCount = 0;
while (_segCount < _segments.length) {
_segment = _segments[_segCount];
if (_arcIndexId == toTypeId(_segment.selectedTypeName)) {
_wall = _wallFromArcSegment(_segment, _segCount, null, null, null, null, null, null, null, null, null, null, null, null);
} else {
_wall = _wallFromLineSegment(_segment, _segCount, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
}
if (NullChecker.isNull(_wall)) {
logMsg(LogType.error, "wall creation failed");
}
_bool = _model.addChild(_storey, _wall);
_segCount = _segCount + 1;
}
return _model;
}
/// procedure3SDT3v5tPECAR8EHTlkJ5k =============
PIModel procedure3SDT3v5tPECAR8EHTlkJ5k(PIProject iProject, PIModel iModel, Dictionary iInput) {
try {
_project = iProject;
_model = iModel as PIIfcModel;
_input = iInput;
return _modelProcedure();
} catch(e, stackTrace) {
logMsg(LogType.error, 'error in model transform id = 3SDT3v5tPECAR8EHTlkJ5k: ${e.toString()} with stack trace ${stackTrace.toString()}');
}
return PIModel.nullModel();
}
weekday enum
enum for weekday
| Template ID | 3W6lovx8bE08FTajqGkVjQ |
|---|---|
| Type | PIBLOCKLYENUMTEMPLATE (enum) |
| Schema | 14 (ifc4x3) |
| Input / Output | enum |
Open in Workspace Viewer → ↑ back to table of contents
Show generated JSON
{
"@type": "weekdays",
"values": [
"sunday",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday"
]
}