i'm using python script to import many blocks, and merge them. but i cant use mergeBlocks correctly.
How to initialize "BlockVec" struct?do you have any example?
Not able to merge blocks either:
#!/usr/bin/env python # # Script: cc-merge_blocks.py # Purpose : merge bocks from ContextCapture project # Keywords: project reading, project data acess # # Script description: This script loads a project and allows to choose blocks for merge. # ****************************************************************************** import sys import ccmasterkernel import os # Note: replace paths with your references, or install SDK sample data in C:/CC_SDK_DATA projectDirPath = 'C:/ContextCapture/Test' projectName = os.path.basename(projectDirPath)+'.ccm' projectFilePath = os.path.join(projectDirPath, projectName) def main(): print('MasterKernel version %s' % ccmasterkernel.version()) print('') # -------------------------------------------------------------------- # load project # -------------------------------------------------------------------- project = ccmasterkernel.Project() err = project.readFromFile(projectFilePath) if not err.isNone(): print('Failed to load project. ' + projectFilePath + ' ' + err.message) sys.exit(0) print('Project %s successfully loaded.' % project.getName()) print('') # -------------------------------------------------------------------- # display project tree # -------------------------------------------------------------------- for iBlock in range(0, project.getNumBlocks()): block = project.getBlock(iBlock) print(str(iBlock) + ' -[%s]' % block.getName()) for iReconstruction in range(0, block.getNumReconstructions()): reconstruction = block.getReconstruction(iReconstruction) print(' -[%s]' % reconstruction.getName()) for iProduction in range(0, reconstruction.getNumProductions()): production = reconstruction.getProduction(iProduction) print(' -[%s]' % production.getName()) print('') iBlock1 = input('Enter a number for first block to merge:') #print (iBlock) if iBlock1 == '': sys.exit(0) print('') iBlock2 = input('Enter a number for second block to merge:') #print (iBlock) if iBlock2 == '': sys.exit(0) print('') # -------------------------------------------------------------------- # display block details # -------------------------------------------------------------------- block1 = project.getBlock(int(iBlock1)) block2 = project.getBlock(int(iBlock2)) print('--------------------------------------') print('Merging: '+'[%s]&[%s]:' % (block1.getName(), block2.getName())) #block2.getId blocks=[block1,block2] print(blocks) # canMergeBlocks testMerge = project.canMergeBlocks(blocks) if testMerge == None: print('Blocks can\'t be merged. Either do not have compatible positioning level or exceeds a size suited for license capability.') sys.exit(0) #mergeBlocks merge = project.mergeBlocks(block1,block2) if merge == None: print('Blocks can\'t be merged. Either do not have compatible positioning level or exceeds a size suited for license capability.') sys.exit(0) if __name__ == '__main__': main()
Results in error:
Boost.Python.ArgumentError: Python argument types in Project.canMergeBlocks(Project, int, int)did not match C++ signature: canMergeBlocks(class MasterKernel::Project {lvalue}, class std::vector<class MasterKernel::Block * __ptr64,class std::allocator<class MasterKernel::Block * __ptr64> > blocks)
Got reply from Bentley.This is how to initialize Blockvec:
# -------------------------------------------------------------------- # make block array # -------------------------------------------------------------------- blocks = ccmasterkernel.BlockVec() blocks.append(block1) blocks.append(block2)