CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
2.94k stars 276 forks source link

VRML Export #476

Closed sethhillbrand closed 3 years ago

sethhillbrand commented 3 years ago

It would be nice if CQ could expose the OpenCascade VRML export functions. This would greatly help integration with KiCad and Blender.

jmwright commented 3 years ago

@sethhillbrand This link is to a PR in the OCP repo. OCP is our own set of Python bindings for the OCCT CAD kernel. https://github.com/CadQuery/OCP/pull/28

adam-urbanczyk commented 3 years ago

@sethhillbrand are you after assemblies or "regular" solids exporting?

sethhillbrand commented 3 years ago

@adam-urbanczyk I'm not quite sure what you mean when referring to VRML assemblies. I'm looking for solids that we can apply the extra specular characteristics to. There shouldn't be any external references in the VRML files (if that is what you mean)

adam-urbanczyk commented 3 years ago

I meant: do you intend to use CQ assemblies (cq.Assembly) and export them or just export regular (i.e. cq.Workplane or cq.Solid) objects?

sethhillbrand commented 3 years ago

Ah! Got it, thanks!

We are slowly migrating our generators (https://gitlab.com/kicad/libraries/kicad-packages3D-generator) from FreeCAD+CadQuery 0.3 to CadQuery 2.0. In the old paradigm, we always did a union operation in FreeCAD before exporting the file, so I think we'll be working with cq.Solid for now.

Are there additional considerations that we should be thinking of when looking at cq.Assembly?

jmwright commented 3 years ago

@sethhillbrand I know it's a lot of work, but I'm glad to see your project updating to CQ 2.x.

If I remember right, you guys were generating a lot of ICs with a casing and pins. You could create the casing and pins separately and then put them together using an assembly. If you don't need the case and pins treated as separate entities, I'm wondering if it's worth the extra work on your side and the exporter side though.

adam-urbanczyk commented 3 years ago

It should be possible to support VRML export of assemblies without too much effort it seems. The advantage now would be the ability to specify colors and in the future to specify materials. Not sure though how relevant the latter is for your use case @sethhillbrand .

sethhillbrand commented 3 years ago

@adam-urbanczyk Thanks! We'll take a look when this is merged in. I think that VRML specular properties need to be given during export in OCCT. I don't know of a way offhand of specifying these qualities in the internal BREP models or their faces.

adam-urbanczyk commented 3 years ago

Please take a look at #482 and check if it works for you. Latest OCP build from our conda channel is required. I could not make the assembly export use colors so far (in theory it should just work with TDocStd_Document) so leaving it out for now.

sethhillbrand commented 3 years ago

Thanks, I'll test it out.

adam-urbanczyk commented 3 years ago

Any news @sethhillbrand ? Shall we work on merging #482 ?

sethhillbrand commented 3 years ago

@adam-urbanczyk Yes, works nicely. Thanks!