AutodeskHelp
Your one-stop shop for the latest solutions, breaking news, and behind the scenes access to the world of Autodesk support.

Think Outside the Box: Create An Ellipse Model using Fusion & Python

By: Advocate dinocoglitore | Posted ‎01-05-2017 07:57 AM , edited ‎01-06-2017 05:59 AM |

Ellipses-Fusion 360-Python-Header-400x220.pngORIGINAL INSPIRATION

In Palermo, Italy, I'm an active member of a Yoga Center. We decided to create an artistic panel to decorate one of the walls of the Center. Our tea room has many ellipse-shaped volumes.

001 - Original idea - Yoga Center.jpg

So I designed a panel with the same pattern to propose to the Yoga group using Fusion 360. This is a draft I created with the Fusion User Interface:001a - DRAFT.png

It should be made up of a certain number of ellipses that are inside one another but tangent in two points and rotating at a certain angle. They should create an illusion of a spiral!

 

The idea is to build this panel with a laser printer to carve it into wood.

I liked the idea so much that I decided to write a script to make it into a precise form. I thought I would be simple work !

 

If you look at the picture carefully, you can see some errors due to the use of the Fusion User Interface. Can you spot them?

The ellipses do not touch each other (this can generate problems during the print phase). So I tried to solve these mistakes using some solutions through the script, trying to find the exact tangent points.

 

Rotated Ellipse

The construction of the whole panel derives from the building of a set of ellipses rotated and enlarged to become internal tangents to the previous ellipse. The tilt (ALPHA) of the ellipses depends on the number of ellipses that one wants to create in a cycle of 360°.

 

Therefore the first step was to implement a function using the Cartesian equation of an ellipse whose major axis is rotated of a certain angle to the Cartesian axes. In other words, it was necessary to use the mathematical equation to obtain the information needed for the construction of an ellipse inside the Python script with the method: sketchEllipses_var.add(centerPoint, majorAxisPoint, point).002 - Rotated ellipse.jpg

 

 Such method requires the center of the ellipse, the point which represents the major axis and a generic point of the ellipse (I chose the point connected to the minor axis). The rotated ellipse is built on a new sketch. The two ellipses have been named EL1 and EL2.003 - Rotated ellipse 2.png

Almost tangent ellipse

What we want to realize now is the construction of an ellipse with the same tilt of the rotated ellipse EL2  but tangent to the previous ellipse EL1.

 

To find a solution from the mathematical point of view is rather difficult, so I tried to solve the problem using the computer graphics tools provided by the Fusion API and Python scripting.

 

As far as I know, building an ellipse concentric and tangent to EL1, starting from EL2, is not possible, because Fusion changes the direction of the axis and does not change its dimension. So it superimposes the two ellipses.004 - Tangent ellipse 1.png

 

We need to maintain the axis of the ellipse fixed and enlarge its dimension until it becomes tangent to the original ellipse. All this has been developed using the Offset method of the Sketch Object, applied to the rotated ellipse EL2: sketch_var.offset(curves, directionPoint, offset).

 

The ellipses EL1 and EL2 intersect in 4 points. With a 'for cycle' and an offset operation we can extend the ellipse EL2 until there will be no more  points of intersection with EL1. In this way we build an ellipse that is an approximation of an ellipse tangent to EL1.005 - Tangent ellipse 2.png

The problem seems to be solved! I just need to delete all the intermediate ellipses and leave only the last one and the game is done … but it is not so easy!

 

There are two more questions:

  1. The outer ellipse (that I will call SFS1), created with subsequent offsets, is not really tangent to the ellipse EL1. It can be very near to EL1 (it depends on the step of the offset that I choose), but it is not actually tangent.
  2. The curve, which looks like an ellipse and which is built with the offset operation, has the shape of an ellipse, but it is NOT a SketchEllipse: it is a SketchFittedSpline

SketchFittedSpline

The second observation, particularly, forced me to better analyze the curves that I created.

A SketchFittedSpline, which looks like an ellipse, doesn’t have the same features:

 

  • It does not have axes
  • It does not have vertices
  • I cannot make it tangent to EL1 ellipse (!!!) 

To create a curve tangent to EL1 ellipse I need to convert the SketchFittedSpline SFS1 to a SketchEllipses. This has been done extracting the main features of SFS1 so that I could use the sketchEllipses_var.add(centerPoint, majorAxisPoint, point) method.

 

In order to find the major axis vertex, I found the intersection of SFS1 with the ellipse axis. The other necessary point was found as an intersection of SPS1 with the X axis. In this way I can approximate the SFS1 with a SketchEllipse (EL3)006 - KetchFittedSpline 1.png

 

Tangent Ellipse

Now it's possible to make EL3 (defined with the variable real_ellipse in the script) perfectly tangent to the EL1 ellipse. To do so,first  I need to constrain EL3 to be concentric to EL1 with sketch2.geometricConstraints.addConcentric(real_ellipse, ellipse1) method, second I need to fix EL1  with ellipse1.isFixed = True and last I need to make EL3 tangent to EL1 with sketch2.geometricConstraints.addTangent(real_ellipse, ellipse1) method .

 

In the following picture, the constraints used to constrain EL3 to be concentric and tangent to EL1 are visible:007 - Tangent Ellipse.png

Panel Construction

The basic work is completed. Now I need to repeat the whole process in a loop so that the ellipse EL3 will become the new EL1, starting point for the next step. At the end I will have as many sketches as the created ellipses.008 - Panel construction.png

 

In each sketch there are two ellipses: the copy of the original ellipse (EL1), green colored because it is fixed, and the tangent ellipse EL3, built to the i-th step.009 - Panel construction 2.png

Selection and Extrusion

What is left is to create the panel selecting the profiles that I am interested in. I chose to select the external profiles for each ellipse, skipping one every other step.010 - Selection-extrusion1.png

 

The very last step is the extrusion of all the profiles with the desired thickness so that I can obtain the final result.011 - Selection-extrusion2.pngI can act on the number of ellipses to obtain a denser or more transparent panel. The final effect is to obtain a couple of more or less detailed spirals. The spirals  that I have obtained are of a logarithm type.

 

I chose to create only one 360° cycle, but I could  implement the algorithm with more cycles obtaining more complex spirals.

 

Another choice has been to relate the major axis with the minor axis through the golden number 0.618. I can avoid using this relation making the first ellipse more distorted and elongated and unbalancing the relationship between the major and the minor axes. In this way I obtain a panel more elongated in a direction.012 - Selection-extrusion3.png

One of the examples has been rendered attributing the Mahogany-Glossy material:013 - Rendered mahogany.png

3D Projection

At the moment, the model has only a small third dimension (almost 1 cm) because the panel has only a 2D pattern.

I also tried to project it in a 3D space to see other effects and here are a couple of examples.014combo.pngThis last phase was not implemented inside the script since the original main goal was to create a decorative panel.

 

For the construction of the 3D models you can refer to the article I authored where you can see the extrusion and intersection with a solid of revolution created with a revolve operation applied to the geometry of a vertical sketch:

http://forums.autodesk.com/t5/autodeskhelp/using-fusion-360-with-python-how-to-create-the-seventh-ch... 

 

These are the sketches with which I built the previous examples.015a - Sketch1.png

 


015b - Sketch2.png

  

 

ABOUT ME
Dario-bio.png

My name is Dino Coglitore. I am a teacher of ICT at a secondary technical school in Palermo (Sicily-Italy) - ITI Vittorio Emanuele III

I started working with Fusion some months ago. With the help of Dario Passariello of  Digital3D (Autodesk Academic Partner e Certified Instructor, Autodesk Expert Elite). I did the work of solid modelling. My passion for programming and graphics convinced me to use Python and the Fusion API to try and express my creativity.

 

Special Thanks

I want to thank @ekinsb and @yqliu who let me better understand the difference between SketchEllipse and SketchFittedSpline objects. One more thank you to @ekinsb who helped me to use the API to find the ellipses intersections.

 A special thank you goes out to Claudia Di Stefano who is my 'translation advisor'. Thank you Claudia.

 

IMPORTANT: Access to Python Script

If you have questions or any doubt about the script development, please do not hesitate to contact me here on Autodesk Community ( @dinocoglitore )

I would be glad if my experience could be of any use for the community. 

 

I would really appreciate any suggestions, criticisms, comments and proposals for further improvements. 
The Python code and the proposed 3D models are available to anyone who might be interested. Please post a comment below and I will send the link to access the Python script code. You may also reach out to me directly. 

 

All the best from Palermo. I look forward to your thoughts and comments!

Dino Coglitore 

 

About dinocoglitore
dinocoglitore

I'm a ITC teacher in a Technical Institute in Palermo (Sicily-Italy). I followed a course on Fusion 360 on june 2016 and I was thrilled of the possibilities of this kind of software. So I started to apply the 3D modeling on a project in driving a mechanical arm of which I developed the 3D model. My interest is also in programming so I started to study also scripting in Python.

View Full Profile
Idea Guidelines

Please review our Idea guidelines and best practices before posting a new idea, or voting on an existing one!