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

How to export sphere to stp file #33

Open
happydpc opened this issue Sep 4, 2022 · 3 comments
Open

How to export sphere to stp file #33

happydpc opened this issue Sep 4, 2022 · 3 comments

Comments

@happydpc
Copy link

happydpc commented Sep 4, 2022

According to the code, there are two ways to create a sphere:

let uhcircle = NURBSCurve::new(BSplineCurve::new(knot_vec, control_points));
    let sphere = RevolutedCurve::by_revolution(
        uhcircle, Point3::origin(), Vector3::unit_x(),
    );
let sphere = Sphere::new(center, radius);

but they all don't impl the ModelShape trait, how to export sphere to step file ?

@ytanimura
Copy link
Contributor

Sorry for the late reply, STEP must always be spit out with the topology included, not just the geometry. I have made a sample code, but there seems to be an internal bug going on, so please wait a little longer.

@happydpc
Copy link
Author

Good job on this work, Thanks.

@ytanimura
Copy link
Contributor

I am very sorry for the delay. One can output the sphere step by the following code and it displays properly in FreeCAD for example.

use std::f64::consts::PI;
use truck_modeling::*;
use truck_stepio::out;

fn main() {
    let vertex = builder::vertex(Point3::new(0.0, 0.0, 1.0));
    let wire = builder::rsweep(&vertex, Point3::origin(), Vector3::unit_y(), Rad(PI));
    let shell = builder::rsweep(&wire, Point3::origin(), Vector3::unit_z(), Rad(PI * 2.0));
    let step_string =
        out::CompleteStepDisplay::new(out::StepModel::new(&shell.compress()), Default::default())
            .to_string();
    std::fs::write("output.stp", &step_string).unwrap();
}

However, in truck it is a bit abuse and does not close spherical as topological data. We would like to fix this, but we need to take care of a problem at the same time before we can officially support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants