A sample file with 3D polylines would help provide a possible solution. It's not clear how the vertices of the 3dpoly with the correct z value correlate, if at all, with the 3dpoly with the correct x ad y values.
Here's an approach that might yield a satisfatory solution.
In the image below it is assumed that the red 3dpoly has the correct x,y values and the green 3dpoly has the correct z values The yellow plane lies n the XY plane and is present to help visualize the 3D nature of the lines.

A copy is made of the red 3dpoly and then going to the top view flatten is used to project it to the XY plane where extrude is used to make a surface prependicular to the xy plane. Using 3dforbit, a view is choosen that is deemed the best orientation for projecting the green 3dpoly onto the surfaces created from the red 3dpoly. The result will look something like this.


We want the line formed by the intersetion of the magenta surfaces with the cyan surfaces. Since there isn't a command (that I am aware of) to find the intersection of sufaces you can create thin solids for each set of surfaces by first using thicken on the surfaces with a small value and then create a single solid from all the magenta solids and then all the cyan solids. The Boolean intersect command is then used to find the intersection of the two solids. shown in white below.

From here a 3Dpoly can be created from the vertices along one edge of the white solid.
lee.minardi