Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug in CreateViaOffset function

5 REPLIES 5
Reply
Message 1 of 6
hossam.amer666
222 Views, 5 Replies

Bug in CreateViaOffset function

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 ?

5 REPLIES 5
Message 2 of 6

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.

   

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 6

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 

Message 4 of 6

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

 

 

Message 5 of 6

Exactly! So instead of converting the lines like in the image it throws an exception 

Message 6 of 6

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.

 

RPTHOMAS108_0-1698062856085.png

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.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community