共用方式為


3D printing (DirectX)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Support 3D printing to a 3D printer in your app built for Windows 8.1.

Overview

Printing 3D content is like printing 2D content. In fact, we have extended the IXpsOMPackageWriter and IXpsDocumentPackageTarget interfaces to enable 3D printing. To send 3D content to a printer from an app in Windows 8.1, your app must access Windows printing and provide formatted 3D content to print.

Your app must create a 3D model and add it to a document package as independent content. A 3D model is a collection of one or more physical objects in a markup format. Your app may also provide 2D XPS content. Depending on whether the package is sent to a 3D printer or a 2D printer, the 3D content or the 2D XPS content is printed. The content is sent to the printer by writing either the 3D content or the combined 3D and XPS file via a 3D package writer object (IXpsOMPackageWriter3D). For more info about Windows printing, see Printing.

Accessing Windows printing

Your app accesses Windows printing by registering for the Print contract in each view of the app from which you want users to be able to print. Registering for the Print contract means obtaining a PrintManager object, creating a PrintTask object, and handling the PrintDocument events. This section describes this process in greater detail.

Windows printing provides a preview feature to all apps that have registered for the Print contract. Your app should use the print-preview functions of Windows printing instead of showing print-preview content in the app itself. Use the IPrintDocumentSource, IPrintDocumentPageSource, and IPrintPreviewPageCollection interfaces to fully customize the print preview.

After your app has registered for the Print contract, it can use the default print UI that Windows provides, or it can customize the UI by adding or removing printing options. How to change standard options in the print preview UI and How to add custom options to the print preview UI describe how to customize the print experience in Windows.

When preparing the document for submission to the print system (via the IPrintDocumentPageSource::MakeDocument method), you include the individual settings for the user to select in a PrintTicket XML document for the 3D model. This PrintTicket markup is structured as follows

<?xml version="1.0" encoding="UTF-8" ?>
<psf:PrintTicket
    xmlns:psf="https://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1"
    xmlns:psk="https://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords"
    xmlns:psk3d="https://schemas.microsoft.com/3dmanufacturing/2013/01/pskeywords3d">

    <!-- Insert PrintTicket settings here -->

</psf:PrintTicket>

Windows Store apps that support 3D printing should check for the existence of the standard options shown in this table and add them to the print ticket as custom options if they are not present.

Option List option details Example model PrintTicket markup
Job3DQuality
  • Draft
  • Medium
  • High

<psf:Feature name="psk3d:Job3DQuality">
    <psf:Option name="psk3d:Draft" />
</psf:Feature>
Job3DDensity
  • Hollow: 0% InfillPercentage
  • Low: 10% InfillPercentage
  • Medium: 40% InfillPercentage
  • High: 70% InfillPercentage
  • Solid: 100% InfillPercentage
<psf:Feature name="psk3d:Job3DDensity">
    <psf:Option name="psk3d:Hollow">
        <psf:ScoredProperty name="psk3d:InfillPercentage">
            <psf:Value xsi:type="xs:integer">0</psf:Value>
        </psf:ScoredProperty>
    </psf:Option>
</psf:Feature>
Job3DSupports
  • SupportsIncluded
  • SupportsExcluded
<psf:Feature name="psk3d:Job3DSupports">
    <psf:Option name="psk3d:SupportsIncluded" />
</psf:Feature>
Job3DRaft
  • RaftIncluded
  • RaftExcluded
<psf:Feature name="psk3d:Job3DRaft">
    <psf:Option name="psk3d:RaftIncluded" />
</psf:Feature>

 

Using the 3D printing API

3D printing in Windows involves creating a 3D content and passing it through the pipeline of Windows spooler and driver filters to the 3D manufacturing device, such as a 3D printer.

The 3D printing APIs have these characteristics:

  • They support submitting a 3D content in Open Packaging Conventions format for printing.
  • They support submitting an XPS content for 2D printing, in addition to the 3D content.
  • The 3D content is limited to one 3D model part linking zero or more texture parts and zero or one print ticket parts.
  • The 3D model and texture data are considered an opaque stream by the API, and there is no validation or parsing of any kind.

Two interfaces—IXpsDocumentPackageTarget3D and IXpsOMPackageWriter3D—are included in the 3D manufacturing API. IXpsDocumentPackageTarget3D represents a print queue and job details. IXpsOMPackageWriter3D provides methods for sending content into the Windows print pipeline. This interface passes 3D content as opaque streams through spooler and driver filters to the 3D manufacturing device.

Open Packaging Conventions

3D print jobs are submitted to the Windows spooler as an OPC (Open Packaging Conventions) package. The OPC package format is a logical data structure that consists of typed sets of binary data, called parts, and named and typed links, called relationships. It contains everything needed for the 3D print job to travel through the print pipeline. The OPC package that contains the 3D content may also contain XPS content for 2D printing. Here is a diagram of an OPC package format. In the diagram, Thumbnail is a part, with relationship types 3D model, 3D texture, and print ticket.

The 3D content contains a 3D model part. This part contains XML markup describing the object or objects to be created. The 3D content has a root relationship to the 3D model part. The 3D model part has relationships to its model PrintTicket and all of the texture images for the model to create a highly-detailed color 3D object. Not every model requires texture files because the 3D manufacturing format also supports solid color volumes. All data needed for each page rendering is embedded in the package.

The 3D Manufacturing Format is an OPC-based format that describes the content and appearance of a 3D model, plus ancillary package features and print instructions, collectively called a 3MF document. It also includes the common package features of the OPC specification that support digital signatures, thumbnails, and core properties.

3D model

The 3D model part contains XML markup that has two primary components:

  • Resources: Defines a set of textures, colors, materials, and objects.
  • Build instructions: Specifies the object resources to manufacture.

Resources may be dependent upon other resources for their full definition. An object resource can be defined either as a triangular mesh or as a set of polygonal slices. An object may also include one or more other object resources to construct a more complex shape from reusable, simpler parts. Here is an example of a 3D model. The image depicts a simple cube with (x, y, z) coordinates.

Throughout the 3D model markup, the app may include additional metadata about the model or its various components. For more information, see the Microsoft 3D Printing Resources page.

Go to Quickstart: 3D printing to learn how to add 3D printing to your app.

See also

For more info about printing from Windows Store apps using C++, see Printing (Windows Store apps using C#/VB/C++ and XAML).

XPS Document API

Microsoft 3D Printing Resources

Quickstart: 3D printing

IXpsDocumentPackageTarget3D

IXpsOMPackageWriter3D