Star Trek’s replicator technology is coming to a galaxy near you. This week, Hawthorne-based SpaceX will carry the first 3-D printer into space, where NASA hopes astronauts will one day be able to print replacement parts on long-distance missions.

“[W]e could go from having a part designed on the ground to printed in orbit within an hour to two from start to finish,” NASA’s 3-D printing project manager Niki Werkheiser said in a statement. “The on-demand capability can revolutionize the constrained supply chain model we are limited to today and will be critical for exploration missions.”

The 3-D printing process, also called “additive manufacturing,” creates objects by adding successive layers of molten materials, usually plastics or metal alloys.

The microwave-size 3-D printer — bound for the International Space Station on Friday — has been modified to function in zero-gravity environments.

The company behind the project, Made in Space, was founded by a group of 3-D design software engineers, astronauts and tech entrepreneurs working in the research park at NASA’s Ames Research Center in Northern California.

Made in Space engineers tested the printer in weightless environments created by airplanes flying in parabolic flight paths.

During the tests, the printed layers varied in thickness as the onboard lab arched in and out of weightlessness. The tests allowed Made in Space engineers to adjust the printer’s settings to perform better in a zero-gravity environment.

“Making the printer safe enough to pass NASA’s stringent safety requirements has become one of our key patented technologies,” Made in Space business development engineer Brad Kohlenberg said in an email. “It still hasn’t been made a big deal on Earth yet but all 3-D printers off-gas small amounts of toxic gases and harmful nano particles; on the space station that matters quite a bit.”

Zero-gravity also affects the way heat transfers, further complicating the printing process, which relies on melting plastics at temperatures between 435 degrees and 480 degrees Fahrenheit.

Astronauts on the space station will print objects called “test coupons” that will later be tested on Earth to see if they hold up as well as terrestrially manufactured equipment.

The company plans to send up a second printer next year that will take into account the performance of the first printer.

In the South Bay, 3-D printing is already being used in aerospace manufacturing. SpaceX has developed a 3-D printed SuperDraco engine for its manned Dragon V2 spaceship.

Engineers at NASA’s Marshall Space Flight Center in Huntsville, Ala., have also been testing 3D-printed components for rocket engines. Printing a rocket-engine injector piece reduced the cost of the $300,000 part by 80 percent, according to a report by Nature magazine.

If the Made in Space printer proves successful, the technology would allow astronauts to leave many spare parts on Earth. A supply of replacement materials would allow astronauts to print the parts as needed.

Reduced weight and greater self-reliance are key to moving towards longer distance missions to locations beyond low-Earth orbit, Ken Cooper, the principal investigator for 3-D printing at Marshall, said in a statement.

“NASA is great at planning for component failures and contingencies; however, there’s always the potential for unknown scenarios that you couldn’t possibly think of ahead of time,” Cooper said. “That’s where a 3-D printer in space can pay off.”