Orientation of the Magnetic Fields in Interplanetary Flux Ropes and Solar Filaments