Hello!
I'm trying to split a crop in a section view by some proportions calculated previosly. The first split works well, but when i try to split the other regions (regionIndex >= 1), the split does not follow the proportions given.
I've done some tests to see if i can find some logic behind the changes, but i didn't find an answer. The following image ilustrates the tests during the second split (regionIndex = 1), with varying values of leftPart and rightPart.
Has anyone figured this out?
Thank you!
Solved! Go to Solution.
Solved by matheus.limaQEDLV. Go to Solution.
What I've found is that if you want to split an existing region in half you use:
.SplitRegionHorizontally(Region, 0.4999, 0.5001) the right has to have a larger number than the left.
It is based on proportion of the current split region it seems.
Whilst the below functions give values based on the entire group of split regions i.e.
ViewCropRegionShapeManager.GetSplitRegionMinimum
ViewCropRegionShapeManager.GetSplitRegionMaximum
After testing the various arrangements indicated above the following results were calculated in Excel which were broadly in line with the API function output above.
On the left below you see the split region arrangement in relation to grids and on the right the corresponding values in terms of dividing 1 by the size of original unsplit crop and multiplying that by the start and end of each split region.
So you perhaps need to consider what you have in terms of the split regions to calculate what you need to use next. You probably also need to unsplit to reassign the extents of a region (knowing that each region is split in order).
Thank you so much for the testing!
Were the splits indicated in the first image made through the API? Because when i try to replicate the same proportions, the second and third splits doesn't seem to follow the proportions given, even if calculated based on the current splited regions. Can you share the code you used for that part?
No, I've since struggled to understand the numbers required by the API function for splitting also.
If you use values of 49.995, 50.001 then the existing region you split will be split equally in half. However if you use values of 74.995, 75.001 then the split doesn't appear to be 3/4 over from the left end and likewise a split of 24.995, 25.001 also doesn't cause the split to be 1/4 from the left end (although in both cases they head in the right direction they are not quite at the location I would have expected.
So I need to look in more detail to see if I am missing something or if I'm right in what I expect and the function is wrong. It is kind of hard at this point in time to see how the function could be right.
Today i have been able to split it correctly by always changing the first region (regionIndex = 0), changing the other regions doesn't seems to follow any logic.
I will post a sample code along this thread, if anyone needs a quick answer.
Thank you very much!
proportions = [0.32, 0.54, 0.12, 0.87, 0.42]
proportions.sort()
proportions.reverse()
currentCropSize = originalCropSize #Got previously
leftProportion = proportions[1]
rightProportion = proportions[0]
for index,proportion in enumerate(proportions):
t.Start()
if index <= len(proportions)-2:
offset = 1/currentCropSize
leftLimit = leftProportion + offset
rightLimit = rightProportion - offset
cropManager = cutView.GetCropRegionShapeManager() #Got previously
cropManager.SplitRegionHorizontally(0, leftLimit, rightLimit)
if index <= len(proportions)-3:
distanceLeftProportion = proportions[index+2] * originalCropSize
distanceRightProportion = proportions[index+1] * originalCropSize
currentCropSize = currentCropSize - (1-(leftLimit)) * currentCropSize
leftProportion = (distanceLeftProportion/currentCropSize)
rightProportion = (distanceRightProportion/currentCropSize)
t.Commit()
Can't find what you're looking for? Ask the community or share your knowledge.