Seeking helix example for draw test harness

mmiscool

Looking around for some CAD
Hello,
I found this code here but don't quite understand how to change it to match my use case.

Code:
#
# make helix curve in OpenCASCADE.
# Shing Liu(eryar@163.com)
#2015-07-08 22:00
#

upload MODELING VISUALIZATION

cylinder a cylinder 6

line aLine2d 0  0  1  1
trim aSegment aLine2d 0  2 * pi

mkedge aHelixEdge aSegment aCylinder 0  6 * pi

vdisplay aHelixEdge


It seems to successfully create a helix but I don't quite know how to modify it.

I am trying to make a helix wire and need to specify the radius, pitch and total height. Goal is to use the helix as the path for a sweep to produce thread geometry.
6df47bd1-59a1-47fa-b380-71e3e53f5eec_helix.jpg

Any help would be appreciated
 
Last edited:

Quaoar

Administrator
Staff member
I made a test command in Analysis Situs to play around with this code:

Code:
int MISC_Helix(const Handle(asiTcl_Interp)& interp,
              int                          argc,
              const char**                 argv)
{
  const double radius = Atof(argv[1]);

  Handle(Geom_CylindricalSurface)
    cylinder = new Geom_CylindricalSurface( gp::XOY(), radius );

  double k  = Atof(argv[3]);
  double dx = 1.;
  double dy = k*dx;
  gp_Dir2d pitchDir(dx, dy);

  gp_Lin2d line2d( gp::Origin2d(), pitchDir );

  Handle(Geom2d_TrimmedCurve)
    segment = GCE2d_MakeSegment(line2d, 0.0, M_PI*2.0);

  TopoDS_Edge helixEdge = BRepBuilderAPI_MakeEdge(segment, cylinder, 0.0, Atof(argv[2]) * M_PI).Edge();

  /* ==========
   *  Finalize.
   * ========== */

  // Update Data Model.
  cmdMisc::model->OpenCommand();
  {
    asiEngine_Part(cmdMisc::model).Update(helixEdge);
  }
  cmdMisc::model->CommitCommand();

  // Actualize.
  if ( cmdMisc::cf->ViewerPart )
    cmdMisc::cf->ViewerPart->PrsMgr()->Actualize( cmdMisc::model->GetPartNode() );

  return TCL_OK;
}

The pitch parameter is controlled with the 3-rd argument which specifies the tangent of the parametric direction (I think it's mentioned in the blog you refer to).

Pitch factor 0.1:

1684160506628.png

Pitch factor 0.2:

1684160540355.png

Pitch factor 0.02:

1684160563329.png

The first parameter is the diameter of the cylinder. The second parameter affects the edge length.
 

mmiscool

Looking around for some CAD
Thanks for the reply. Unfortunately this still leaves me in the same position.

I am trying to understand how to specify the radius, total height and the pitch.

What exactly is the 10 doing in "helix 5 10 0.2"
Is there an easy way to understand how to calculate the second parameter based on the total target height of the spiral? Right now you said "the second parameter affects the edge length."
 
Top