jeremytammik / DirectObjLoader

Revit add-in to load a WaveFront OBJ model and generate a DirectShape element from it.
MIT License
17 stars 9 forks source link

try/catch suggestion #1

Closed truevis closed 9 years ago

truevis commented 9 years ago

I suggest adding try/catch around builder.AddFace

    try
    {
        builder.AddFace(new TessellatedFace(corners,
          ElementId.InvalidElementId));       
    }
    catch
    {
     // remember something went wrong here..
    }
jeremytammik commented 9 years ago

hi eric,

thank you for the suggestion!

why, though?

the whole operation is wrapped in an exception handler anyway. do you have an example where some individual faces may fail, and you still want to retain the rest?

if so, i'll add this right away.

cheers

jeremy

truevis commented 9 years ago

Here is an OBJ file with errors in it: https://drive.google.com/file/d/0B_UPhfVzWDkxMWJEVnMtdWN0N28/view?usp=sharing

jeremytammik commented 9 years ago

what exact exception is thrown, please? you should never add a catch-all handler if you can avoid it.

jeremytammik commented 9 years ago

i do not see the sample OBJ file you refer to. where is it?

jeremytammik commented 9 years ago

i updated the code with a catch-all exception handler. i would like to narrow it down to the specific exception thrown, though.

truevis commented 9 years ago

I think this OBJ tries to make 2-vertex faces https://drive.google.com/file/d/0B_UPhfVzWDkxMWJEVnMtdWN0N28/view?usp=sharing

jeremytammik commented 9 years ago

thx, i'll take a look.

jeremytammik commented 9 years ago

nope, if you simply look at the OBJ in a text editor, you see that all faces have four vertices. maybe some of the four vertices list the same one or two vertices twice? i'll test... you should be able to debug this also, man :-)

truevis commented 9 years ago

Even MeshLab complains about that OBJ:

jeremytammik commented 9 years ago

hi eric, thank you for the high_ball_glass.obj sample OBJ. i added the exception handler you suggest, and also added a result log in the debug console window reporting the number of faces that succeeded and failed on each shape.

jeremytammik commented 9 years ago

closed with release 2015.0.0.17.