Hide Table of Contents

Render Annotations to Separate Image File Example (C#)

This example shows how to render annotations and dimensions visible in a model to a separate image file.

//--------------------------------------------------------------
// Preconditions:
// 1. Open a model document.
// 2. Add a note to the model.
// 3. Right-click Annotations in the FeatureManager design tree
//    and click Show Feature Dimensions, if dimensions
//    are not visible in the model.
// 4. Verify that:
//    * PhotoView 360 add-in is loaded.
//    * c:\temp exists.
//
// Preconditions:
// 1. Sets the options to include and render annotations and dimensions  
//    visible in a model to a separate image file.
// 2. If prompted to add camera or perspective, click Continue
//    without Camera or Perspective.
// 3. Renders:
//    * model to c:\temp\annotations.png
//    * note and dimensions to c:\temp\annotations_1.png
// 4. Open both files to verify the previous step.
//--------------------------------------------------------------
 
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
 
namespace Macro1CSharp.csproj
{
    public partial class SolidWorksMacro
    {
 
 
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            RayTraceRenderer swRayTraceRenderer = default(RayTraceRenderer);
            RayTraceRendererOptions swRayTraceRenderOptions = default(RayTraceRendererOptions);
            bool status = false;
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
 
            //Access PhotoView 360
            swRayTraceRenderer = (RayTraceRenderer)swApp.GetRayTraceRenderer((int)swRayTraceRenderType_e.swPhotoView);
 
            //Set options to include and render annotations and dimensions  
            //visible in a model to a separate image file
            swRayTraceRenderOptions = (RayTraceRendererOptions)swRayTraceRenderer.RayTraceRendererOptions;
            swRayTraceRenderOptions.IncludeAnnotationsInRendering = true;
            swRayTraceRenderOptions.RenderAnnotationsToSeparateImage = true;
            status = swRayTraceRenderer.RenderToFile("c:\\temp\\annotations.png", 0, 0);
            status = swRayTraceRenderer.CloseFinalRenderWindow();
 
        }
 
        /// <summary>
        ///  The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
        public SldWorks swApp;
    }
}


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Render Annotations to Separate Image File Example (C#)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2018 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.