Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid OBJ file header version error report should report that the obj version is incorrect. #683

Open
wpostma opened this issue Dec 31, 2021 · 1 comment
Labels
Importer Bugs and features related to the importer

Comments

@wpostma
Copy link

wpostma commented Dec 31, 2021

If the following provided obj file which works fine in XPlane is actually invalid, a line number or some output of the content or context which was invalid would be useful.

stormwindow.obj attached (zip)

stormwindow.zip
image

UnrecoverableParseERror line 64, xplane_imp_parser.py.

if not lines or not (lines[0] in {"A", "I"} and lines[1:3] == ["800", "OBJ"]):
    logger.error(
        ".obj file must start with exactly the OBJ header. Check filetype and content"
    )
    raise UnrecoverableParserError

Wouldn't it be friendlier to raise the message instead of logging it? The logs do not show in the error report as you can see in the message. WOuld it not be better to raise InvalidHeaderError

Sometimes the files I am encountering have cr/lf quirks and have weird formatting like this

I

800

OBJ

TEXTURE miscobjects.png

POINT_COUNTS 385 0 0 960

VT -0.678609 0.351299 3.048667 -0.983369 -0.179792 -0.025709 0.275422 0.718949

VT -0.678740 0.348166 3.048664 -0.998706 0.043618 -0.026161 0.275422 0.718290

VT -0.675921 0.351276 2.946007 -0.985842 -0.164899 0.030391 0.260027 0.718944

@wpostma
Copy link
Author

wpostma commented Dec 31, 2021

The obj attached to this issue is double spaced, but these double spaced items import into xplane just fine.
May I suggest you filter empty lines, like this:

def fixme(n1,n2):
out = []
afile = open(n1,"r")
ofile = open(n2,"w")
lines = afile.readlines()
print('read '+n1)
for line in lines:
line = line.strip(' ').strip('\n').strip('\r')
if line != '':
out.append(line)
return out

@bsupnik bsupnik added the Importer Bugs and features related to the importer label Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Importer Bugs and features related to the importer
Projects
None yet
Development

No branches or pull requests

2 participants