<p>Here is what I finally did, maybe somebody finds it useful.</p>

<p>I wrote a script with Excel VBA what does the following:</p>

<ol>
<li>gets the coordinates of n discrete points on the trajectory</li>
<li>gets k points of the circular cross-section at each n, in a horizontal plane</li>
<li>applies a rotation on these cross-sections (moves all points)</li>
<li>creates (n-1)*(k-1) facets (assigns 4 corner points to each)</li>
<li>exports the points and the facets to a vrml file</li>
</ol>

<p>The result:</p>

<p><a href="https://i.sstatic.net/GIwAu.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GIwAu.jpg" alt="enter image description here"></a></p>

<ul>
<li><p>The script might have been easier in python, but I chose Excel VBA<br>
because this way I don't have to deal with the GUI.</p></li>
<li><p>The format is vrml, because a) most software handles it b) the
definition is available (mostly) and simple</p></li>
<li><p>prepare the file by script instead of a CAD software: in my experience they can't build this surface reliably enough. The features will be super-sensitive to the input parameters, they will tend to crash after small changes</p></li>
</ul>

<p>There are a couple of issues remaining:</p>

<ul>
<li>Catia can't open the result, possibly because the vertex normals are not defined in the wrl file. This feature of the vrml is not really documented. Opening and saving it with Creo solves the issue, as it adds the normals automatically. Creo and NX are ok.</li>
<li>Can't convert the result to quilt in Creo, hence sectioning, measuring, etc is problematic</li>
</ul>

<p>Any suggestions with the issues above are most welcome.</p>

CC BY-SA 3.0
2016-09-02T10:28:15.520Z
You can not reliably work with polygon data in CAD applications. Why dont you use VBA to make the n discrete points directly in creo sketch and then sweep that? Note this is not what you asked. PS why dont you share a dummy formula and i can add instructions int the chat how to properly do this shape. PS this is not within scope of this forum.
joojaa
CC BY-SA 3.0
2016-09-02T06:01:15.033Z
2016-09-02T06:01:15.033Z
Tawhiri
<p>Well realistically your choices are either IGES or STEP. IGES is slightly simpler but you will not successfully write either format without buying the standard (which in case of step is actually so many pages that by the time you have read them a year has passed, and lots of money is wasted on paper). You could also use one of the nonstandard kernel internal formats like Parasolid as its also commonly supported. Most other formats are polygon data so not suitable.</p>

<p>I would explore an alternative option to writing your own exporter, buy a commercial or take a free CAD kernel and let the kernel (open CASCADE) do the exporting for you.</p>

<p>On the other hand this is not hard to do inside your CAD application. Which you will need anyway to verify the result. Most CAD applications have a COM API's (don't know about NX most likely, but both creo and catia do have this) so you can edit, even do the generation from a text editor via python if you so wish. This is by far the least amount of effort (and it's usually less work to set up than using just the kernel).</p>

<p><a href="https://i.sstatic.net/ufq1l.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ufq1l.png" alt="sweep"></a></p>

<p><strong>Image 1</strong>: Swept with spine angle $60 \cos(4 t)+110$ and polar trajectory with $r = \cos(4 t)+3$ in Creo. All input from program injection.</p>

<p>So the approach depends on why you want to do what you do. And what your budget/time constraint is.</p>

<p><strong>PS</strong>: NURBS (the underlying format of CAD data) solutions are not necessarily analytic, but parametric fits to analytical solutions. Sometimes these are exact sometimes not so exact as not all functions can be fitted to rational spline (though many can). Even when they can fitting is a more general solution.</p>

CC BY-SA 3.0
2016-08-29T09:51:16.847Z
One of the reasons I want to do this outside of cad softwares is that this feature is not that simple to create with them. a) On your image above the shape of the cross-section is changing, but the plane of the sketch is perpendicular to the local trajectory. b) The surface can self-intersect, what is often a problem
Tawhiri
CC BY-SA 3.0
2016-08-29T10:05:06.743Z
@Tawhiri a) No the cross section is always the same its just oriented to the sweep path. The plane pf the sketch is not allways perpendicular it is changing with the funclion 60cos(4t)+110. b) is hard to avoid if you put arbitrary functions in place. So the function either selfintersects or does not. But yes that can be counteracted by making a rail sweep along and not thinking in terms of across.
joojaa
CC BY-SA 3.0
2016-08-29T12:27:22.437Z
@Tawhiri oh and what CAD are you using? What your proposing is actually very simple in Creo which is what i use mostly. Admittedly the tool used is not one that many users know how to use but still very easy to do.
joojaa
CC BY-SA 3.0
2016-08-29T13:06:38.953Z
Right now Catia V5R24 and Creo 2.0 is available. What is your method? I have a cuple of years experience with both, but I cant figure it out how to vary the angle of the sketch plane.
Tawhiri
CC BY-SA 3.0
2016-08-29T13:13:11.567Z
When you use sweep you  must enable variable sections then inside the sketch add a relation to your dimension. In this relation you can write a function along curve by using the variable `trajpar` which is from 0 to 1 along the swept curve. Likewise you can make curves out fo equations with the **datum (additional dropdown) -> curve -> curve from equation** command. Also if you want to adjust the top down trajectory direction then  you can define an additional curve for the sweep. Its all there but very few people ever use these tools.
joojaa
CC BY-SA 3.0
2016-08-29T13:27:29.973Z
@Tawhiri is this what your after? https://i.sstatic.net/bNJgi.png
joojaa
CC BY-SA 3.0
2016-08-29T13:54:52.177Z
Yes it is. Actually I've tried this before, but the feature keeps crashing with "design intent is unclear", so I assumed this is not the proper way to go. Probably the problem is that there is a corner with a small radius in the path. And the mathematical derivation of the second curve is quite challenging. Anyway, I will keep trying, thank you so much for the help!
Tawhiri
CC BY-SA 3.0
2016-08-29T14:04:27.227Z
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/44627/discussion-between-joojaa-and-tawhiri).
joojaa
CC BY-SA 3.0
2016-08-28T13:55:19.850Z
2017-01-03T00:14:56.387Z
2017-01-03T00:14:56.387Z
joojaa
<p>I have to create a file describing a 3d surface with the following properties:</p>

<ul>
<li>a circular arc cross section is swept along a closed 2d curve spine defined with equations</li>
<li>the normal direction of the arc is not always tangential to the spine, the direction is defined with an equation</li>
<li>the surface should be analytic (defined by equations), but a tesselated surface is also acceptable (with an external script I can derive the x,y,z coords of the vertexes for a tesselated surface)</li>
<li>the file will be modified by an external script (python), so it should be editable with text editor</li>
<li>the file should be opened by Creo(Proe), Catia and NX</li>
</ul>

<p>The question:<br>
Which is the best file format for making this feature?</p>

<p>What I tried:</p>

<ul>
<li>step: buying the ISO standard is unavoidable, as I cannot figure out on my own how the definition works</li>
<li>vrml: only tesselated seems to be feasible</li>
<li>x3d: same as vrml, as it has a sweep (extrusion) feature, but the normal direction is the same as the local spine direction, and Proe does not seem to open it</li>
</ul>

<p>The egg-shaped curve is the trajectory, the arc is the curve to be swept along it.
The plane of the arc is close to parallel to the plane "Top", but this angle varies between 0-30 degrees
<a href="https://i.sstatic.net/GJuRL.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GJuRL.jpg" alt="explanation for the feature"></a></p>

CC BY-SA 3.0
2016-08-26T12:17:13.977Z
"the normal direction of the arc is not always tangential to the spine". I'm not quite sure what this means in 3d. Is it equivalent to "the plane in which the arc lies is not always perpendicular to the closed curve"?
trichoplax is on Codidact now
CC BY-SA 3.0
2016-08-26T12:20:01.677Z
Is "spine" a specific term here, or should this say "[spline](https://en.wikipedia.org/wiki/Spline_(mathematics))"?
trichoplax is on Codidact now
CC BY-SA 3.0
2016-08-27T19:22:42.767Z
Indeed, it is equivalent. The "spine" is not necessarily a spline, it can be an array of points connected with straight lines. Some software calls the spine curve trajectory.
Tawhiri
CC BY-SA 3.0
2016-08-29T16:27:33.680Z
Even tough i have explained how to do this in comments does not mean that this is a forum for telling you how to operate your CAD application.
joojaa
CC BY-SA 3.0
2016-08-30T04:05:03.443Z
Obviously not. I guess I got the answer, though not the one I was hoping for. Again, thanks for the help.
Tawhiri
CC BY-SA 3.0
2016-08-31T07:30:34.683Z
Tawhiri well your really trying to substitute a somewhat easy CAD problem with a horribly complicated programming problem. So we are talking 10 hours of getting intimate with advanced CAD components versus 1000 hours of calculus, programming and model fitting experience! I could do this for you but i doubt you can afford my services. Polygons are easy by comparasion.
joojaa
<3d><computational-geometry>
File format for swept profile with changing normal
Tawhiri
# File format for swept profile with changing normal

(Asked by: username_0 on 2016-08-26)

I have to create a file describing a 3d surface with the following properties:

* a circular arc cross section is swept along a closed 2d curve spine defined with equations
* the normal direction of the arc is not always tangential to the spine, the direction is defined with an equation
* the surface should be analytic (defined by equations), but a tesselated surface is also acceptable (with an external script I can derive the x,y,z coords of the vertexes for a tesselated surface)
* the file will be modified by an external script (python), so it should be editable with text editor
* the file should be opened by Creo(Proe), Catia and NX

The question:  
Which is the best file format for making this feature?

What I tried:

* step: buying the ISO standard is unavoidable, as I cannot figure out on my own how the definition works
* vrml: only tesselated seems to be feasible
* x3d: same as vrml, as it has a sweep (extrusion) feature, but the normal direction is the same as the local spine direction, and Proe does not seem to open it

The egg-shaped curve is the trajectory, the arc is the curve to be swept along it.
The plane of the arc is close to parallel to the plane "Top", but this angle varies between 0-30 degrees
[![explanation for the feature](https://i.sstatic.net/GJuRL.jpg)](https://i.sstatic.net/GJuRL.jpg)

**Tags:** 3d, computational-geometry

> **Comments:**
> **username_1**: "the normal direction of the arc is not always tangential to the spine". I'm not quite sure what this means in 3d. Is it equivalent to "the plane in which the arc lies is not always perpendicular to the closed curve"?  
> **username_1**: Is "spine" a specific term here, or should this say "[spline](https://en.wikipedia.org/wiki/Spline_(mathematics))"?  
> **username_0**: Indeed, it is equivalent. The "spine" is not necessarily a spline, it can be an array of points connected with straight lines. Some software calls the spine curve trajectory.  
> **username_2**: Even tough i have explained how to do this in comments does not mean that this is a forum for telling you how to operate your CAD application.  
> **username_0**: Obviously not. I guess I got the answer, though not the one I was hoping for. Again, thanks for the help.  
> **username_2**: username_0 well your really trying to substitute a somewhat easy CAD problem with a horribly complicated programming problem. So we are talking 10 hours of getting intimate with advanced CAD components versus 1000 hours of calculus, programming and model fitting experience! I could do this for you but i doubt you can afford my services. Polygons are easy by comparasion.  

---

## 2 answers

### Answer by username_0 on 2016-09-02. Score: -1 | Accepted answer

Here is what I finally did, maybe somebody finds it useful.

I wrote a script with Excel VBA what does the following:

1. gets the coordinates of n discrete points on the trajectory
2. gets k points of the circular cross-section at each n, in a horizontal plane
3. applies a rotation on these cross-sections (moves all points)
4. creates (n-1)\*(k-1) facets (assigns 4 corner points to each)
5. exports the points and the facets to a vrml file

The result:

[![enter image description here](https://i.sstatic.net/GIwAu.jpg)](https://i.sstatic.net/GIwAu.jpg)

* The script might have been easier in python, but I chose Excel VBA  
  because this way I don't have to deal with the GUI.
* The format is vrml, because a) most software handles it b) the
  definition is available (mostly) and simple
* prepare the file by script instead of a CAD software: in my experience they can't build this surface reliably enough. The features will be super-sensitive to the input parameters, they will tend to crash after small changes

There are a couple of issues remaining:

* Catia can't open the result, possibly because the vertex normals are not defined in the wrl file. This feature of the vrml is not really documented. Opening and saving it with Creo solves the issue, as it adds the normals automatically. Creo and NX are ok.
* Can't convert the result to quilt in Creo, hence sectioning, measuring, etc is problematic

Any suggestions with the issues above are most welcome.

> **Comments:**
> **username_2**: You can not reliably work with polygon data in CAD applications. Why dont you use VBA to make the n discrete points directly in creo sketch and then sweep that? Note this is not what you asked. PS why dont you share a dummy formula and i can add instructions int the chat how to properly do this shape. PS this is not within scope of this forum.  

---

### Answer by username_2 on 2016-08-28. Score: 3

Well realistically your choices are either IGES or STEP. IGES is slightly simpler but you will not successfully write either format without buying the standard (which in case of step is actually so many pages that by the time you have read them a year has passed, and lots of money is wasted on paper). You could also use one of the nonstandard kernel internal formats like Parasolid as its also commonly supported. Most other formats are polygon data so not suitable.

I would explore an alternative option to writing your own exporter, buy a commercial or take a free CAD kernel and let the kernel (open CASCADE) do the exporting for you.

On the other hand this is not hard to do inside your CAD application. Which you will need anyway to verify the result. Most CAD applications have a COM API's (don't know about NX most likely, but both creo and catia do have this) so you can edit, even do the generation from a text editor via python if you so wish. This is by far the least amount of effort (and it's usually less work to set up than using just the kernel).

[![sweep](https://i.sstatic.net/ufq1l.png)](https://i.sstatic.net/ufq1l.png)

**Image 1**: Swept with spine angle $60 \cos(4 t)+110$ and polar trajectory with $r = \cos(4 t)+3$ in Creo. All input from program injection.

So the approach depends on why you want to do what you do. And what your budget/time constraint is.

**PS**: NURBS (the underlying format of CAD data) solutions are not necessarily analytic, but parametric fits to analytical solutions. Sometimes these are exact sometimes not so exact as not all functions can be fitted to rational spline (though many can). Even when they can fitting is a more general solution.

> **Comments:**
> **username_0**: One of the reasons I want to do this outside of cad softwares is that this feature is not that simple to create with them. a) On your image above the shape of the cross-section is changing, but the plane of the sketch is perpendicular to the local trajectory. b) The surface can self-intersect, what is often a problem  
> **username_2**: @username_0 a) No the cross section is always the same its just oriented to the sweep path. The plane pf the sketch is not allways perpendicular it is changing with the funclion 60cos(4t)+110. b) is hard to avoid if you put arbitrary functions in place. So the function either selfintersects or does not. But yes that can be counteracted by making a rail sweep along and not thinking in terms of across.  
> **username_2**: @username_0 oh and what CAD are you using? What your proposing is actually very simple in Creo which is what i use mostly. Admittedly the tool used is not one that many users know how to use but still very easy to do.  
> **username_0**: Right now Catia V5R24 and Creo 2.0 is available. What is your method? I have a cuple of years experience with both, but I cant figure it out how to vary the angle of the sketch plane.  
> **username_2**: When you use sweep you  must enable variable sections then inside the sketch add a relation to your dimension. In this relation you can write a function along curve by using the variable `trajpar` which is from 0 to 1 along the swept curve. Likewise you can make curves out fo equations with the **datum (additional dropdown) -> curve -> curve from equation** command. Also if you want to adjust the top down trajectory direction then  you can define an additional curve for the sweep. Its all there but very few people ever use these tools.  
> **username_2**: @username_0 is this what your after? https://i.sstatic.net/bNJgi.png  
> **username_0**: Yes it is. Actually I've tried this before, but the feature keeps crashing with "design intent is unclear", so I assumed this is not the proper way to go. Probably the problem is that there is a corner with a small radius in the path. And the mathematical derivation of the second curve is quite challenging. Anyway, I will keep trying, thank you so much for the help!  
> **username_2**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/44627/discussion-between-username_2-and-username_0).  

---

