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

Add examples with MasterBodies and templates #546

Open
RobPasMue opened this issue May 30, 2023 · 3 comments
Open

Add examples with MasterBodies and templates #546

RobPasMue opened this issue May 30, 2023 · 3 comments

Comments

@RobPasMue
Copy link
Member

@jonahrb we should include your car example inside the documentation examples. Do you have your script somewhere? If so, just paste it inside the issue - I can handle the reformatting.

@jonahrb
Copy link
Contributor

jonahrb commented May 30, 2023

Here's a script that makes the 2 cars.

m = Modeler(port="50051")
design = m.create_design("design1")

# Create a car
car1 = design.add_component("Car1")
top_comp = car1.add_component("A").add_component("Top")
comp2 = car1.add_component("B")
wheel1 = comp2.add_component("Wheel1")

# Create car base frame
sketch = Sketch().box(Point2D([5, 10]), 10, 20)
comp2.add_component("Base").extrude_sketch("BaseBody", sketch, 5)

# Create first wheel
sketch = Sketch(Plane(direction_x=Vector3D([0, 1, 0]), direction_y=Vector3D([0, 0, 1])))
sketch.circle(Point2D([0, 0]), 5)
wheel_body = wheel1.extrude_sketch("WheelBody", sketch, -5)

# Create 3 other wheels and move them into position
rotation_origin = Point3D([0, 0, 0])
rotation_direction = UnitVector3D([0, 0, 1])

wheel2 = comp2.add_component("Wheel2", wheel1)
wheel2.modify_placement(Vector3D([0, 20, 0]))

wheel3 = comp2.add_component("Wheel3", wheel1)
wheel3.modify_placement(Vector3D([10, 0, 0]), rotation_origin, rotation_direction, np.pi)

wheel4 = comp2.add_component("Wheel4", wheel1)
wheel4.modify_placement(Vector3D([10, 20, 0]), rotation_origin, rotation_direction, np.pi)

# Create 2nd car
car2 = design.add_component("Car2", car1)
car2.modify_placement(Vector3D([30, 0, 0]))

# Create top of car - applies to BOTH cars
sketch = Sketch(Plane(Point3D([0, 5, 5]))).box(Point2D([5, 2.5]), 10, 5)
top_comp.extrude_sketch("TopBody", sketch, 5)
design.download("D:\\Work\\Projects\\PyGeometry\\car.scdocx", DesignFileFormat.SCDOCX)
design.plot()

@RobPasMue
Copy link
Member Author

Assigning to @dastan-ansys ... just in case you have time =)

@RobPasMue
Copy link
Member Author

@jonahrb @dastan-ansys - do you think you could be able to provide some examples for this? Based on the above script it should be fairly straightforward

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

4 participants