Hello,
I was using CreateViaOffset to offset a curve loop and then use it so set crop shape for a callout as foloowing:
var offestedCurveLoop = CurveLoop.CreateViaOffset(curveloop, offset, XYZ.BasisZ);
regionManager.SetCropShape(offestedCurveLoop);
but I noticed that the CreateViaOffset is working fine if the offset <= 35 cm but if I set a higher value for offset it throws the following exception
Autodesk.Revit.Exceptions.InternalException: 'An internal error has occurred.'
Is there an alternative way to do the same job without this function ?
Sure you can reprogram the entire implementation of the CreateViaOffset method yourself ands avoid using the built-in method. Challenging, though. No, I am not aware of a viable alternative. If you share a complete minimal reproducible case demonstrating the error you describe we may be able to take a closer look and discover the cause.
I found that this error happens if the curveloop has 3 curve form U shape like in the attached image so actually the 30 cm I mentioned is the half of the U shape's base length because now those three lines after this value should be turn into straight line
It sounds like by offsetting that distance you are on the verge of creating a self intersecting curve loop which isn't suitable for a shaped crop.
You should get ArgumentException when setting the crop for that however
Exactly! So instead of converting the lines like in the image it throws an exception
My understanding is that the function isn't going to remove any lines or rationalise two lines into a single continuous line, from what I read and experience elsewhere it just tries to trim them where possible. So it likely wasn't going to remove such a notch.
The only issue I can see here is the right exception isn't being thrown. So you are getting an internal exception instead of the expected API one but either way the fault is due to how the function is being used.
Besides what you have is one interpretation of the offset where it behaves similar to offset command in AutoCAD for polyline, here is another interpretation where it doesn't remove curve overlaps.
So if you were automatically removing zero length lines you would remove just one line above.
Probably two questions arise:
Can I create offsets some other way
Can I detect self intersecting curve loop and fix it
Not sure why you would have crop shape with those kind of notches? So the third option is to notify the user that their crop shape is too intricate for your function.
Can't find what you're looking for? Ask the community or share your knowledge.