In the right parallelopiped $ABCDA^{\prime}B^{\prime}C^{\prime}D^{\prime}$, with $AB=12\sqrt{3}$ cm and $AA^{\prime}=18$ cm, we consider the points $P\in AA^{\prime}$ and $N\in A^{\prime}B^{\prime}$ such that $A^{\prime}N=3B^{\prime}N$. Determine the length of the line segment $AP$ such that for any position of the point $M\in BC$, the triangle $MNP$ is right angled at $N$.
1. **Coordinate System Setup**:
   - Place the parallelepiped in a 3D coordinate system with \( A' \) at the origin \((0,0,0)\).
   - Let \( \overrightarrow{A'B'} \) point in the \( +x \) direction, \( \overrightarrow{A'D'} \) point in the \( +y \) direction, and \( \overrightarrow{A'A} \) point in the \( +z \) direction.
   - Given \( AB = 12\sqrt{3} \) cm and \( AA' = 18 \) cm.

2. **Coordinates of Points**:
   - \( M \) is any point on \( BC \), so \( M \) can be represented as \( (12\sqrt{3}, y, 18) \).
   - \( N \) is on \( A'B' \) such that \( A'N = 3B'N \). Since \( A'B' = 12\sqrt{3} \), we have \( A'N = 9\sqrt{3} \) and \( B'N = 3\sqrt{3} \). Thus, \( N \) is at \( (9\sqrt{3}, 0, 0) \).
   - \( P \) is on \( AA' \), so \( P \) can be represented as \( (0, 0, z) \).

3. **Vectors Calculation**:
   - Vector \( \overrightarrow{MN} \):
     \[
     \overrightarrow{MN} = (12\sqrt{3} - 9\sqrt{3})\vec{i} + y\vec{j} + (18 - 0)\vec{k} = 3\sqrt{3}\vec{i} + y\vec{j} + 18\vec{k}
     \]
   - Vector \( \overrightarrow{NP} \):
     \[
     \overrightarrow{NP} = (0 - 9\sqrt{3})\vec{i} + (0 - 0)\vec{j} + (z - 0)\vec{k} = -9\sqrt{3}\vec{i} + z\vec{k}
     \]

4. **Dot Product Condition**:
   - For \( \triangle MNP \) to be right-angled at \( N \), the dot product \( \overrightarrow{MN} \cdot \overrightarrow{NP} \) must be zero:
     \[
     \overrightarrow{MN} \cdot \overrightarrow{NP} = (3\sqrt{3}\vec{i} + y\vec{j} + 18\vec{k}) \cdot (-9\sqrt{3}\vec{i} + z\vec{k}) = 0
     \]
   - Calculate the dot product:
     \[
     (3\sqrt{3})(-9\sqrt{3}) + (y)(0) + (18)(z) = 0
     \]
     \[
     -81 + 18z = 0
     \]
     \[
     18z = 81
     \]
     \[
     z = \frac{81}{18} = \frac{27}{2}
     \]

The final answer is \(\boxed{\frac{27}{2}}\).