MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / addCustomBlock

Method addCustomBlock

src/model/FoundationKiva.cpp:344–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343
344 bool FoundationKiva_Impl::addCustomBlock(const CustomBlock& customBlock) {
345 bool result;
346
347 unsigned int num = numberofCustomBlocks();
348 // Max number of custom blocks is 10
349 if (num >= 10) {
350 LOG(Warn, briefDescription() << " already has 10 custom blocks which is the limit");
351 result = false;
352 } else {
353 // Push an extensible group
354 auto eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>();
355 bool material = eg.setPointer(OS_Foundation_KivaExtensibleFields::CustomBlockMaterialName, customBlock.material().handle());
356 bool depth = eg.setDouble(OS_Foundation_KivaExtensibleFields::CustomBlockDepth, customBlock.depth());
357 bool xPosition = eg.setDouble(OS_Foundation_KivaExtensibleFields::CustomBlockXPosition, customBlock.xPosition());
358 bool zPosition = eg.setDouble(OS_Foundation_KivaExtensibleFields::CustomBlockZPosition, customBlock.zPosition());
359 if (material && depth && xPosition && zPosition) {
360 result = true;
361 } else {
362 // Something went wrong
363 // So erase the new extensible group
364 getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex());
365 result = false;
366 }
367 result = true;
368 }
369 return result;
370 }
371
372 bool FoundationKiva_Impl::addCustomBlock(const Material& material, double depth, double xPosition, double zPosition) {
373 // Make a custom block, and then call the above function

Callers 2

TEST_FFunction · 0.80

Calls 10

pushExtensibleGroupMethod · 0.80
xPositionMethod · 0.80
zPositionMethod · 0.80
eraseExtensibleGroupMethod · 0.80
groupIndexMethod · 0.80
setPointerMethod · 0.45
handleMethod · 0.45
materialMethod · 0.45
setDoubleMethod · 0.45
depthMethod · 0.45

Tested by 1

TEST_FFunction · 0.64