Git Product home page Git Product logo

pyansys-geometry's Introduction

PyAnsys Geometry

PyAnsys Python PyPI PyPI Downloads GH-CI Codecov MIT Black pre-commit.ci

Overview

PyAnsys Geometry is a Python client library for the Ansys Geometry service, as well as other CAD Ansys products such as Ansys Discovery and Ansys SpaceClaim.

Installation

You can use pip to install PyAnsys Geometry.

pip install ansys-geometry-core

To install the latest development version, run these commands:

git clone https://github.com/ansys/pyansys-geometry
cd pyansys-geometry
pip install -e .

For more information, see Getting Started.

Basic usage

This code shows how to import PyAnsys Geometry and use some basic capabilities:

from ansys.geometry.core import launch_modeler
from ansys.geometry.core.math import Plane, Point3D, Point2D
from ansys.geometry.core.misc import UNITS, Distance
from ansys.geometry.core.sketch import Sketch

# Define a sketch
origin = Point3D([0, 0, 10])
plane = Plane(origin, direction_x=[1, 0, 0], direction_y=[0, 1, 0])

# Create a sketch
sketch = Sketch(plane)
sketch.circle(Point2D([1, 1]), 30 * UNITS.m)
sketch.plot()

# Start a modeler session
modeler = launch_modeler()

# Create a design
design = modeler.create_design("ModelingDemo")

# Create a body directly on the design by extruding the sketch
body = design.extrude_sketch(
    name="CylinderBody", sketch=sketch, distance=Distance(80, unit=UNITS.m)
)

# Plot the body
design.plot()

# Export the model to SCDOCX format
file_path = design.export_to_scdocx()

For comprehensive usage information, see Examples in the PyAnsys Geometry documentation.

Documentation and issues

Documentation for the latest stable release of PyAnsys Geometry is hosted at PyAnsys Geometry documentation.

In the upper right corner of the documentation's title bar, there is an option for switching from viewing the documentation for the latest stable release to viewing the documentation for the development version or previously released versions.

On the PyAnsys Geometry Issues page, you can create issues to report bugs and request new features. On the PyAnsys Geometry Discussions page or the Discussions page on the Ansys Developer portal, you can post questions, share ideas, and get community feedback.

To reach the project support team, email [email protected].

pyansys-geometry's People

Contributors

akaszynski avatar alejandrofernandezluces avatar b-matteo avatar banesullivan avatar chadqueen avatar chris-hawkins-usa avatar clatapie avatar dastan-ansys avatar dependabot[bot] avatar jasonwelling avatar jonahrb avatar jorgepiloto avatar klmcadams avatar kmahajan-cadfem avatar lancex2214 avatar maxjprey avatar pipkat avatar pre-commit-ci[bot] avatar pyansys-ci-bot avatar rajesh1359 avatar revathyvenugopal162 avatar rmanno91 avatar robpasmue avatar smoraisansys avatar umutsoysalansys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pyansys-geometry's Issues

Move ``ansys.discovery.core.models.geometry`` package to PyGeometry

@Revathyvenugopal162 and @MaxJPRey did a really good work implementing the general Python abstract objects we conceived from PyDiscovery. And most of that work is reusable. Let's take it to this repo!

  • Migrate the base GRPCWrapper class (and change name to BaseObject
  • Migrate the geometry subpackage
  • Remove all gRPC pydiscovery-specific implementations (i.e. the _update_message/_from_message implementations)
  • Structure it as proposed in the first meeting we had (see image below)
  • Include testing
  • Add classes to the documentation

image

Start the ``units`` subpackage

An important aspect of CAD libraries are the units. It is expected that, behind the scenes, all objects work in SI units, but users should be able to provide their values in different units. Let's get this module started!

  • Implement the units module
  • Create a `Quantity`` (enum) class handling the units accepted
  • Create a Conversion class which will contain a Quantity (enum) value and a conversion factor
  • Implement units inside the datamodel.objects package
  • All units inside the objects must be stored in SI, but users will be able to provide different Quantity values. Conversions should be handled in construction and representation. Inside operations and operations between objects will always take place in SI
  • Add testing (must be intensive, this is a critical module)
  • Add documentation

See the following picture for having an idea of the location of the units subpackage
image

Add `Polygon` curve

The Polygon class is one of the basic classes we need to be able to create. Basic constructor for DBU is exposed in #13.

Consider using their constructor and storing those properties as instance attributes.

Implement logger

We need to implement a logger. Follow approach from PyDiscovery and PyMAPDL. This module may be easily migrated from these repositories.

Add primitive 3D Plane model

Minimum constructor:

Point3D origin, Direction dirX, Direction dirY

Can include Plane concept within Sketch class as well since a Sketch acts against a single plane workspace

Increase robustness of ``Line``

During our meeting with the DBU we realized that when building a LineSketch object we are not double checking that (for example):

  • The points are not the same
  • The units of the points should be checked (if they are different, fall back to PyGeometry's default units)
  • ...

Differentiate between ``BoundedCurves`` and ``UnboundedCurves``

One of the suggestions of the DBU team is the concept of bounded/unbounded curves. Sketch-related objects should be bounded (i.e. they should have a beginning and an end) whereas unbounded objects (Line(infinite/semi-infinite), circle, ellipse...) should be more like primitives.

Furthermore, all these objects could be used elsewhere. So we should try to remove the "Sketch" concept from these curves and add the concept of Bounded/Unbounded. In fact, Bounded curves could easily extend Unbounded ones, since they would only be specifying starting and end points.

Send over a Sketch to the server

Now that we have a client in place (#36) we are able to pull up a server and connect to it. We should be able to go through the different shapes implemented, add them to the Sketch and send them over to the server. Then, parse the response and validate that the Sketch build has been done adequately.

  • Figure out how to send the sketch.
  • Wrap the gRPC stubs to send the information in an orderly manner.
  • Validate that the different sketch elements are created consistently on the server side.

Create ``Frame`` class

The Frame will allow us to set our reference system in space. As exposed in #13 it is one of the basic objects the DBU needs. This task should be handled prior to #32.

  • Consider using the DBU constructor - its inputs should be stored as instance attributes.
  • Consider other potential constructors (if any)
  • Consider migrating PyDiscovery implementation for ease of task (there is already a Frame class there)

API documentation is not linking correctly

It looks like we may have an issue... Sphinx does not link correctly to our package classes amongst themselves.

For example:
image

Here, Point3D should be clickable. Let's try and solve this.

Create ``Arc`` curve

The Arc is one of the basic curves we need to be able to create. Basic constructor for DBU is exposed in #13.

  • The arc should extend from a Circle if possible since it is basically a subset of points
  • Allowing to create an arc from three points as @MaxJPRey suggested in #13 is also a possibility. Consider creating this @classmethod as well.

Add sphere 3D geometry primitive

SpaceClaim constructors for reference:

Sphere(Point3D origin, Direction dirX, Direction dirY, double radius)
Sphere(Point3D origin, double radius)

PyGeometry first draft

Let's get a first version of the Geometry client out!

Related tasks:

  • Create a base repository + docs repos for getting things started
  • Implement basic entity objects. Linked to #13
  • Implement units handling using pint. Linked to #2
  • Create a plotting module for visualizing the entity objects. Linked to #3
  • Create a math/algebra module for operations with entity objects. Linked to #13
  • Conceive a simple client to connect to a gRPC server. Linked to #36
  • Add tests
  • Add documentation: API reference automatically generated + basic PyAnsys sections. Linked to #5
  • Add examples. Linked to #4

Implement ``plotting`` subpackage

Another important point is the visualization of the different objects inside the datamodel. We should consider using PyVista for this task. Points to be taken into account for this task:

  • Implement the plotting subpackage
  • Consider the creation of a ScenePlotter or similar (please don't use my name suggestion ๐Ÿ˜„): users will be able to pass in several objects and plot them all together
  • All datamodel objects should implement a plot() function. This function should be defined as abstract in the BaseObject class and implemented downstream in each object
  • Create a PyGeometry plotting theme so that we do not use the default PyVista theme
  • Add documentation
  • Add testing

Please consider the following location for the plotting subpackage:
image

Add connection module exposing grpc server implementation

As a developer, I would like an encapsulated abstraction providing:

gRPC abstraction layer

  • Stateless pass-through wrapper layer to grpc stubs with method signatures derived from ansys.geometry.core model entities

Server connection management

  • Management of existing connections
  • Reconnect management
  • Establish connection to specific endpoint

Implement the Spline object

We are definitely not going to implement the Spline logic on our own. We should look into other libraries to see who has it implemented and wrap around it.

Add ``Box`` shape to ``ansys.geometry.core.shapes`` subpackage

Maybe all of this is contained client side but would be nice to move server side in either this first implementation or future refactors.

Accept in the required inputs to create a box in a method on the Component class. The call to the server should return a Body that will be nested under the Component in context.

Example client script is within BoardCreationCommonHelper for reference.

Implement ``transformations`` module

Following @jorgepiloto's suggestion, it may be interesting to add a transformations.py module once the Matrix class is available, so that we have the capability of creating:

  • Scale matrices
  • Translation matrices
  • Rotation matrices

And their operations. All these computations can occur on the client side. Thanks for the suggestion @jorgepiloto!

Add Torus Geometry 3D primitive

3D primitive object

constructor options within spaceclaim
Point3D origin, Direction dirX, Direction dirY, double majorRadius, double minorRadius
Point3D origin, Direction dirZ, double majorRadius, double minorRadius

Add method to find angle between 2 vectors.

Add a function in vector module to find the angle between 2 vectors. Which will useful to for transformations, arc and geometric functionality of perpendicular, parallel lines

Add Accuracy class for equivalency evaluations

Should handle comparisons with default and defined tolerances like:

Accuracy.length_is_zero(length: float)
Accuracy.length_is_zero(length: float, tolerance: float)

Pull default tolerances from SpaceClaim, such as:

float length_accuracy = 1e-8;

Overload ``VectorXD`` operators

As per DBU request, we should allow to overload operators for VectorXD operations

  • Dot product: a * b
  • Cross product: a @ b, or a ^ b, or a % b

Adapt Sketch to use 2D objects when drawing/sketching

From conversations with DBU, we should implement the Sketch class to work with 2D points rather than 3D when sketching.

This is also a resulting task from #96

This task should follow after:

Some of the tasks to be performed are:

  • Ensure that all shapes (i.e. 2D objects) are generated from purely 2D elements (i.e. Point2D, Vector2D...).
  • Ensure that the Sketch class is adapted to the new shape constructors.
  • Ensure that when requesting the 3D points, these are generated properly (for plotting, sending over to the server...).
  • Ensure that the examples are properly adapted, as well as the documentation.
  • We should delegate the generation of plotting points to PyVista. And only handle on our side those points that are important for the Shape itself (i.e. box == 4 corner points)

Classes to prototype

Basic Math Capabilities

  • Point #16
  • Vector3D #18
  • VectorUV #18
  • Direction (Unit Vector) #16
  • Matrix #40

2D Geometry

3D Geometry

Misc

  • BBox #21 (NOT A PRIORITY)
  • Interval #22 (NOT A PRIORITY)
  • Frame #51
  • Accuracy (operation tolerance (e.g. Point3D == Point3D or Point3d.is_equal(<other point, tol=1E-5) #35

Units

  • Metric
  • Imperial
  • pint

Additional requirements

  • Null state (e.g. initialized with Point3D())

Create a three point builder for arc shape.

We should also have a three point builder. Basic trigonometry as well. But we may want to leave that for a different PR? Do you see it could be feasible to implement it in this one?

It should be something like:

@classmethod
def from_three_points(start, mid, end):
    ...

Originally posted by @RobPasMue in #81 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.