CadQuery / cadquery

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

Manipulate a step file (project the 3D object to 2D object) #1299

Open mim201820 opened 1 year ago

mim201820 commented 1 year ago

Hello Im working on a project where I need to get information about the different views of a 3D object

and for that, I want to get just the different projections of the 3D object but I couldn't find how to do this, can someone help

how can we project a compound to XY plan?

jmwright commented 1 year ago

It depends on what output you want, but the SVG exporter allows you to set a projection direction.

https://cadquery.readthedocs.io/en/latest/importexport.html#exporting-svg

You will only get 2D line drawings when exporting to SVG though.

mim201820 commented 1 year ago

I want to get information from it like lengths

I tested the SVG exporter and when I used (0, 0, 1) as project direction I got what I want but now I want to manipulate that 2D object. How can I do that?

adam-urbanczyk commented 1 year ago

Is maybecq.Face.project what you are looking for? SVG manipulation is not a use case for CQ.

mim201820 commented 1 year ago

can you please elaborate on how to use cq.Face.project

I have shape as input and I would like to project it to the plan (1, 0, 0)

adam-urbanczyk commented 1 year ago
  1. Crate a face to project onto (cq.Face.makePlane)
  2. Iterate over all faces of your object (for f in obj.Faces():) and call project (f.project(...))