| 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 |