Giter Site home page Giter Site logo

Comments (15)

wwmayer avatar wwmayer commented on May 29, 2024 1

You can drop the test code because there isn't really anything to check.

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

Can you provide an example file, please?

from freecad.

jwueller avatar jwueller commented on May 29, 2024

I'll try to get a minimal reproduction extracted from my current project.

from freecad.

jwueller avatar jwueller commented on May 29, 2024

@wwmayer OpenSCAD-Radius2-bug.FCStd.zip

from freecad.

jwueller avatar jwueller commented on May 29, 2024

The PR fixes this by doing what OpenSCAD itself does: If only one radius exists, it's used for both ends of the cylinder.

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

Thanks for the file but it's fairly complex and thus not suitable for a unit test. Do you know a simple way (e.g. a code snippet) to trigger the bug?

from freecad.

jwueller avatar jwueller commented on May 29, 2024

I'll see if I can get it isolated.

from freecad.

jwueller avatar jwueller commented on May 29, 2024

This might be a more fundamental problem. I imported extruder-adaptor-mm.csg.zip, which produced an invalid shape of some kind. I then deleted the offending cylinder024. After a save and load cycle, it then threw the radius error above. So maybe something else got corrupted earlier on during the import process?

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

OK, I found a way to reproduce the error message. The point is to create a document with a Frustum object. Then the document must be saved, closed and restored.

The error message is triggered when restoring the Frustum. Right after restoring the property Radius1 the onChanged() method is triggered but at this point Radius2 is not yet restored.

However, only some error messages are printed but when executing the Python code no exception is raised. This makes it bit more difficult to write some testable code.

import OpenSCADFeatures
doc = App.newDocument()
mycyl=doc.addObject("Part::FeaturePython",'frustum')
r1=2
r2=3
h=4
n=6
OpenSCADFeatures.Frustum(mycyl,r1,r2,n,h)
mycyl.ViewObject.Proxy = 0
doc.recompute()
doc.saveAs("/tmp/openscad.FCStd")
App.closeDocument(doc.Name)
doc = App.openDocument("/tmp/openscad.FCStd")

from freecad.

jwueller avatar jwueller commented on May 29, 2024

I see, in that case my current PR is only dealing with a symptom, and isn't a proper fix. I'm not sure what the underlying problem is, but if you point me towards what has to be fixed I'll attempt it. If you'd rather fix it yourself I'll just close the PR.

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

The main problem is that the class Frustum recreates its geometry directly inside onChanged(). This is considered bad practise and should be avoided. createGeometry() should only be called inside execute().

from freecad.

jwueller avatar jwueller commented on May 29, 2024

I see that this is present in quite a few of those classes. So it's sufficient to just remove onChanged for all of them, essentially?

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

This might be a more fundamental problem. I imported extruder-adaptor-mm.csg.zip, which produced an invalid shape of some kind.

Hmm, I have tried your file and it looks good to me -- independent if I apply your PR or not. I loaded the file into OpenSCAD and there it looks quite the same. In OpenSCAD I exported an STL file, loaded it into FreeCAD and did a visual inspection of the mesh (as actual) and the shape (as nominal) and the highest deviation is less than 0.1 mm.
So, I would say that the loaded object is correct.

Now if you get a broken shape then it's very likely related to something else -- maybe the OCC CAD kernel has some problems with boolean operations.

from freecad.

wwmayer avatar wwmayer commented on May 29, 2024

I see that this is present in quite a few of those classes. So it's sufficient to just remove onChanged for all of them, essentially?

Yes, that's what I would suggest. This will also fix the error messages when loading the FCStd file.

from freecad.

jwueller avatar jwueller commented on May 29, 2024

Now if you get a broken shape then it's very likely related to something else -- maybe the OCC CAD kernel has some problems with boolean operations.

Yeah, possibly. I fixed those issues manually in my case, since I was only planning on using the OpenSCAD model as a starting point for further modifications. So it seems that the error this issue is about wasn't caused about an import problem, but entirely by how the model is loaded in instead.

I've removed the onChanged stuff, and added your test. However, I'm not entirely sure what my options are to validate the result, since it doesn't seem to throw in a way I can intercept, as you already noted. Maybe there is a way to read the report view output after loading?

Edit: I pushed those changes to #13559 if you want to take a look. Currently doesn't include the test though.

from freecad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.