Comments (12)
@gonuke I think I've now understood what you wanted to do: extrude a 2D shape in the workplane normal direction but define the workplane from a normal vector.
Can you please confirm?
If so, I've managed to achieve this with minimal changes to the code.
In red below is the rotated_solid with extrusion direction (1, 1, 1).
Code:
import paramak
from cadquery import Plane
points = [
(0, 0),
(1, 0),
(1, 1),
(0, 1)
]
shape_1 = paramak.ExtrudeStraightShape(points=points, distance=1)
normal_vec = (1, 1, 1)
shape_2 = paramak.ExtrudeStraightShape(
points=points, distance=1,
workplane=Plane(origin=(0, 0, 0), xDir=(-1, 1, 0), normal=normal_vec),
rotation_axis=[(0, 0, 0), normal_vec])
shape_1.export_stl('non_rotated.stl')
shape_2.export_stl('rotated.stl')
from paramak.
Hi @gonuke thanks for the suggestion. It makes a lot of sense and would be a nice upgrade.
This is not exactly what you asked for but perhaps of interest
sweep shapes allow a list of coordinates to specified and will sweep a cross section between the coordinates.
https://paramak.readthedocs.io/en/main/paramak.parametric_shapes.html#swept-shapes
If there are only two points in the path_points then it is effectively an extrude.
import paramak
test_shape = paramak.SweepStraightShape(
points=[(-10, 10), (10, 10), (10, -10), (-10, -10)],
path_points=[(50, 0), (50, 150)]
)
test_shape.show()
I'm going to dig into the CadQuery documentation a bit and see what can be done to enhance the extrude shapes and see if how to go about accepting a unit vector
from paramak.
This seems to do the job.
I shall integrate it asap in a new PR.
from paramak import ExtrudeMixedShape, Shape
from paramak.utils import calculate_wedge_cut
from cadquery import Vector, Solid
class ExtrudeMixedShapeBis(ExtrudeMixedShape):
def __init__(self, extrusion_vector='ortho', **kwargs):
super().__init__(**kwargs)
self.extrusion_vector = extrusion_vector
def create_solid(self):
"""Creates an extruded 3d solid using points connected with straight
and spline edges.
Returns:
A CadQuery solid: A 3D solid volume
"""
workplane = Shape.create_solid(self)
if not self.extrude_both:
extrusion_distance = -self.distance
else:
extrusion_distance = -self.distance / 2.0
wire = workplane.close()
self.wire = wire
if type(self.extrusion_vector) is str and self.extrusion_vector == 'ortho':
solid = wire.extrude(
distance=extrusion_distance,
both=self.extrude_both)
else:
wireSets = [list(wire.ctx.pendingWires)]
solid = Solid.extrudeLinear(
outerWire=wireSets[0][0],
innerWires=[],
vecNormal=self.extrusion_vector,
taper=0
)
# filleting rectangular port cutter edges
# must be done before azimuthal placement
if hasattr(self, "add_fillet"):
solid = self.add_fillet(solid)
solid = self.rotate_solid(solid)
cutting_wedge = calculate_wedge_cut(self)
solid = self.perform_boolean_operations(solid, wedge_cut=cutting_wedge)
self.solid = solid
return solid
points = [
(0, 0, "straight"),
(1, 0, "straight"),
(1, 1, "straight"),
(0, 1, "straight"),
]
my_shape = ExtrudeMixedShapeBis(points=points, distance=1, extrusion_vector=Vector((1, 1, 1))) #
my_shape.export_stl('out.stl')
from paramak.
Will the working plane of the shape be rotated to be normal to this path?
from paramak.
Unfortunately not.
from paramak.
I think I would need to add some new args based on the cadquery vector class https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Vector
I've used that before but it looks like the right direction to go in.
from paramak.
That may be one approach, but someone on my team was already doing some rotation math to work around thus by calculating the rotation operations to convert from one of those convenient forms to the rotation system already supported
from paramak.
Interesting, @RemDelaporteMathurin will be interested in that, he made a point rotation function and recently raised an issue requested rotation methods
from paramak.
@shimwell @gonuke this is indeed a feature that - i think - is not yet implemented in the Paramak.
Do we agree that this is the expected behaviour? (apologies, my drawing skills are obviously a bit rusty)
With v the unit vector of the extrusion?
I think this behaviour could be obtained with sweep shapes but that's maybe using a sledgehammer to beat a fly.
Cadquery natively provides a method to achieve this.
The class ExtrudeMixedShape
(and in particular its create_solid
method) would need to be extended a bit but that seem feasible to me.
from paramak.
As far as I can tell, the extruded shapes are all derived from
Shape
and extruded in a direction normal to theworkplane
and then rotated according to the definition of therotation_axis
and theazimuth_placement_angle
.
Not exactly. The parametric shapes are either extruded or rotated. The first step is to give a bunch of points describing a 2D shape (eg the black square I draw above). This 2D shape is then extruded or rotated around a rotation axis (according to rotation_angle
).
The azimuth_placemen_angle
can be seen as the position of the 2D shape before rotating it.
from paramak.
@gonuke pytransform3d may help. Check pytransform3d's documentation. As mentioned in it's README.md, you can easily extract the relevant code for your purpose.
from paramak.
solved in PR #84
from paramak.
Related Issues (20)
- Test Paramak compatibility with Shift HOT 4
- Cannot import paramak after conda install HOT 6
- rotate_solid method wrong documentation HOT 1
- dagmc model not working for thin surfaces HOT 1
- Exporting non overlapping STL files
- update jupyter-cadquery to 3.1.0
- skip tests depending on package import
- example reactor render animation with text HOT 1
- error with DishedVacuumVessel
- more concise tests with pytest.raises
- Installation on conda not working properly HOT 3
- docs are missing plus signs for exspanding
- Supported python version outdated in the documentation. HOT 4
- CircularPort documentation tweaks
- RotateCircularShape documentation issue
- Solid cutting issue with some shapes
- [Feature Request] Ability to have multi layer first walls HOT 1
- Issue with DAGMC export in OpenMC (lost particles) HOT 4
- Dagmc export of shapes producted from the EU DEMO example HOT 5
- [Feature request] output of settings.xml neutron source
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paramak.