diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index 4b28552f6c0f4693c58c567334b9562242b63b0d..19ce09c27ab6c802196b9edd2b5697a58ec4f1bc 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -2814,6 +2814,33 @@ GMSH_API void gmsh::model::mesh::getBasisFunctionsOrientationForElements(
   return;
 }
 
+GMSH_API int gmsh::model::mesh::getNumberOfOrientations(const int elementType,
+                                     const std::string & functionSpaceType)
+{
+  if(!_isInitialized()) { throw - 1; }
+
+  int basisOrder = 0;
+  std::string fsName = "";
+  int numComponents = 0;
+  if(!_getFunctionSpaceInfo(functionSpaceType, fsName, basisOrder,
+                            numComponents)) {
+    Msg::Error("Unknown function space type '%s'", functionSpaceType.c_str());
+    throw 2;
+  }
+
+  if(fsName == "Lagrange" || fsName == "GradLagrange") { // Lagrange type
+    return 1;
+  }
+  else { // Hierarchical type
+    const int familyType = ElementType::getParentType(elementType);
+    const unsigned int numVertices = ElementType::getNumVertices(ElementType::getType(familyType, 1, false));
+    const std::size_t factorial[8] = {1, 1, 2, 6, 24, 120, 720, 5040};
+    return factorial[numVertices];
+  }
+
+  return 0;
+}
+
 GMSH_API void
 gmsh::model::mesh::preallocateBasisFunctionsOrientationForElements(
   const int elementType, std::vector<int> &basisFunctionsOrientation,
diff --git a/api/gen.py b/api/gen.py
index 4af8b57bbc8566b1d6fd0c752ec698108181d969..7bd28efa181c12656652b47c2d550c0a492ff999 100644
--- a/api/gen.py
+++ b/api/gen.py
@@ -317,6 +317,9 @@ mesh.add('getBasisFunctions', doc, None, iint('elementType'), ivectordouble('loc
 doc = '''Get the orientation index of the elements of type `elementType' in the entity of tag `tag'. The arguments have the same meaning as in `getBasisFunctions'. `basisFunctionsOrientation' is a vector giving for each element the orientation index in the values returned by `getBasisFunctions'. For Lagrange basis functions the call is superfluous as it will return a vector of zeros.'''
 mesh.add('getBasisFunctionsOrientationForElements', doc, None, iint('elementType'), istring('functionSpaceType'), ovectorint('basisFunctionsOrientation'), iint('tag','-1'), isize('task', '0'), isize('numTasks', '1'))
 
+doc = '''Get the number of possible orientations for elements of type `elementType' and function space named `functionSpaceType'.'''
+mesh.add('getNumberOfOrientations', doc, oint, iint('elementType'), istring('functionSpaceType'))
+
 doc = '''Preallocate data before calling `getBasisFunctionsOrientationForElements' with `numTasks' > 1. For C and C++ only.'''
 mesh.add_special('preallocateBasisFunctionsOrientationForElements', doc, ['onlycc++'], None, iint('elementType'), ovectorint('basisFunctionsOrientation'), iint('tag', '-1'))
 
diff --git a/api/gmsh.h b/api/gmsh.h
index 8b4855ad8b703447bcce36a531358dcc54dd31b2..8f6280453e830387b3cc7ac93259f56b84abb909 100644
--- a/api/gmsh.h
+++ b/api/gmsh.h
@@ -953,6 +953,13 @@ namespace gmsh { // Top-level functions
                                                             const std::size_t task = 0,
                                                             const std::size_t numTasks = 1);
 
+      // gmsh::model::mesh::getNumberOfOrientations
+      //
+      // Get the number of possible orientations for elements of type `elementType'
+      // and function space named `functionSpaceType'.
+      GMSH_API int getNumberOfOrientations(const int elementType,
+                                           const std::string & functionSpaceType);
+
       // gmsh::model::mesh::preallocateBasisFunctionsOrientationForElements
       //
       // Preallocate data before calling `getBasisFunctionsOrientationForElements'
diff --git a/api/gmsh.h_cwrap b/api/gmsh.h_cwrap
index 4653fec5f0f9fbc669983d1271a18cba79ef6649..d3d3887a268df9a3b9492a0d1c404e914a04ba1e 100644
--- a/api/gmsh.h_cwrap
+++ b/api/gmsh.h_cwrap
@@ -1444,6 +1444,17 @@ namespace gmsh { // Top-level functions
         basisFunctionsOrientation.assign(api_basisFunctionsOrientation_, api_basisFunctionsOrientation_ + api_basisFunctionsOrientation_n_); gmshFree(api_basisFunctionsOrientation_);
       }
 
+      // Get the number of possible orientations for elements of type `elementType'
+      // and function space named `functionSpaceType'.
+      inline int getNumberOfOrientations(const int elementType,
+                                         const std::string & functionSpaceType)
+      {
+        int ierr = 0;
+        int result_api_ = gmshModelMeshGetNumberOfOrientations(elementType, functionSpaceType.c_str(), &ierr);
+        if(ierr) throw ierr;
+        return result_api_;
+      }
+
       // Preallocate data before calling `getBasisFunctionsOrientationForElements'
       // with `numTasks' > 1. For C and C++ only.
       inline void preallocateBasisFunctionsOrientationForElements(const int elementType,
diff --git a/api/gmsh.jl b/api/gmsh.jl
index 7dc02ae0c141964febaa0f613081f59a7c659432..d18a22f961645d23bf6b0665d512b850ac6ca371 100644
--- a/api/gmsh.jl
+++ b/api/gmsh.jl
@@ -1803,6 +1803,23 @@ function getBasisFunctionsOrientationForElements(elementType, functionSpaceType,
     return basisFunctionsOrientation
 end
 
+"""
+    gmsh.model.mesh.getNumberOfOrientations(elementType, functionSpaceType)
+
+Get the number of possible orientations for elements of type `elementType` and
+function space named `functionSpaceType`.
+
+Return an integer value.
+"""
+function getNumberOfOrientations(elementType, functionSpaceType)
+    ierr = Ref{Cint}()
+    api__result__ = ccall((:gmshModelMeshGetNumberOfOrientations, gmsh.lib), Cint,
+          (Cint, Ptr{Cchar}, Ptr{Cint}),
+          elementType, functionSpaceType, ierr)
+    ierr[] != 0 && error("gmshModelMeshGetNumberOfOrientations returned non-zero error code: $(ierr[])")
+    return api__result__
+end
+
 """
     gmsh.model.mesh.getEdgeNumber(edgeNodes)
 
diff --git a/api/gmsh.py b/api/gmsh.py
index 52d33510e02ec09af7790c0327d2a437fd73b9d6..c74dcf90d0c6ab135c1f8fb9524aa5cd3690a012 100644
--- a/api/gmsh.py
+++ b/api/gmsh.py
@@ -2330,6 +2330,27 @@ class model:
                     ierr.value)
             return _ovectorint(api_basisFunctionsOrientation_, api_basisFunctionsOrientation_n_.value)
 
+        @staticmethod
+        def getNumberOfOrientations(elementType, functionSpaceType):
+            """
+            gmsh.model.mesh.getNumberOfOrientations(elementType, functionSpaceType)
+
+            Get the number of possible orientations for elements of type `elementType'
+            and function space named `functionSpaceType'.
+
+            Return an integer value.
+            """
+            ierr = c_int()
+            api__result__ = lib.gmshModelMeshGetNumberOfOrientations(
+                c_int(elementType),
+                c_char_p(functionSpaceType.encode()),
+                byref(ierr))
+            if ierr.value != 0:
+                raise ValueError(
+                    "gmshModelMeshGetNumberOfOrientations returned non-zero error code: ",
+                    ierr.value)
+            return api__result__
+
         @staticmethod
         def getEdgeNumber(edgeNodes):
             """
diff --git a/api/gmshc.cpp b/api/gmshc.cpp
index 005283731c61dddb1518419740c0cc3115957cdc..2db6cd2ee5ccd31feb9a329d934072b34c8c2aec 100644
--- a/api/gmshc.cpp
+++ b/api/gmshc.cpp
@@ -1230,6 +1230,19 @@ GMSH_API void gmshModelMeshGetBasisFunctionsOrientationForElements(const int ele
   }
 }
 
+GMSH_API int gmshModelMeshGetNumberOfOrientations(const int elementType, const char * functionSpaceType, int * ierr)
+{
+  int result_api_ = 0;
+  if(ierr) *ierr = 0;
+  try {
+    result_api_ = gmsh::model::mesh::getNumberOfOrientations(elementType, functionSpaceType);
+  }
+  catch(int api_ierr_){
+    if(ierr) *ierr = api_ierr_;
+  }
+  return result_api_;
+}
+
 GMSH_API void gmshModelMeshPreallocateBasisFunctionsOrientationForElements(const int elementType, int ** basisFunctionsOrientation, size_t * basisFunctionsOrientation_n, const int tag, int * ierr)
 {
   if(ierr) *ierr = 0;
diff --git a/api/gmshc.h b/api/gmshc.h
index 185caece3bb86752c1bae91779cc9813daf5060a..41ddb6e583927e9d1f9f3d6520124ec2bb9ddacd 100644
--- a/api/gmshc.h
+++ b/api/gmshc.h
@@ -832,6 +832,12 @@ GMSH_API void gmshModelMeshGetBasisFunctionsOrientationForElements(const int ele
                                                                    const size_t numTasks,
                                                                    int * ierr);
 
+/* Get the number of possible orientations for elements of type `elementType'
+ * and function space named `functionSpaceType'. */
+GMSH_API int gmshModelMeshGetNumberOfOrientations(const int elementType,
+                                                  const char * functionSpaceType,
+                                                  int * ierr);
+
 /* Preallocate data before calling `getBasisFunctionsOrientationForElements'
  * with `numTasks' > 1. For C and C++ only. */
 GMSH_API void gmshModelMeshPreallocateBasisFunctionsOrientationForElements(const int elementType,
diff --git a/doc/texinfo/api.texi b/doc/texinfo/api.texi
index 821a04731914fa361ede1190458225ac55e035a7..522b6729230b640276898e0ff2921f1cb6384d56 100644
--- a/doc/texinfo/api.texi
+++ b/doc/texinfo/api.texi
@@ -1464,6 +1464,19 @@ as it will return a vector of zeros.
 -
 @end table
 
+@item gmsh/model/mesh/getNumberOfOrientations
+Get the number of possible orientations for elements of type @code{elementType}
+and function space named @code{functionSpaceType}.
+
+@table @asis
+@item Input:
+@code{elementType}, @code{functionSpaceType}
+@item Output:
+-
+@item Return:
+integer value
+@end table
+
 @item gmsh/model/mesh/preallocateBasisFunctionsOrientationForElements
 Preallocate data before calling @code{getBasisFunctionsOrientationForElements}
 with @code{numTasks} > 1. For C and C++ only.