Hide Table of Contents

Set Independent Viewport for MBD 3D PDF Example (C#)

This example shows how to set a view for an independent viewport for a SOLIDWORKS MBD 3D PDF.

//--------------------------------------------------------------
// Preconditions:
// 1. Open an assembly.
// 2. Copy install_dir\data\themes\simple assembly (letter, landscape) to
//    C:\test\simple assembly (letter, landscape).
// 3. In SOLIDWORKS, click the SOLIDWORKS MBD toolbar > 3D PDF Template Editor.
//    a. Click Independent Viewport.
//    b. Click Save As.
//    c. Ensure that Theme Directory is C:\test\simple assembly (letter, landscape).
//    d. Type AllViews in Name.
//    e. Click Save.
//    f. Close the 3D PDF Template Editor.
//
// Postconditions:
// 1. Gets the MBD3DPdfData object.
// 2. Sets the path and file name for the SOLIDWORKS MBD 3D PDF.
// 3. Sets to display SOLIDWORKS MBD 3D PDF after publishing.
// 4. Sets the theme for the SOLIDWORKS MBD 3D PDF.
// 5. Sets the view to display in the independent viewport 
//    for the SOLIDWORKS MBD 3D PDF.
// 6. Creates and displays MBDPart1.PDF.
// 7. Examine MBDPart1.PDF.
//---------------------------------------------------------------
 
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);
            ModelDocExtension swModelDocExt = default(ModelDocExtension);
            MBD3DPdfData swMBDPdfData = default(MBD3DPdfData);
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
            swModelDocExt = (ModelDocExtension)swModel.Extension;
 
            //Get MBD3DPdfData object
            swMBDPdfData = (MBD3DPdfData)swModelDocExt.GetMBD3DPdfData();
 
            //Set path and file name for SOLIDWORKS MBD 3D PDF
            swMBDPdfData.FilePath = "C:\\temp\\MBDPart1.PDF";
 
            //Display SOLIDWORKS MBD 3D PDF 
            swMBDPdfData.ViewPdfAfterSaving = true;
 
            //Set SOLIDWORKS MBD 3D PDF theme
            swMBDPdfData.ThemeName = "C:\\test\\simple assembly (letter, landscape)\\AllViews\\theme.xml";
 
            //Set view for AllViews
            swMBDPdfData.SetIndependentViewPort("*Top");
 
            //Create SOLIDWORKS MBD 3D PDF
            swModelDocExt.PublishTo3DPDF(swMBDPdfData);
 
        }
 
        /// <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:   Set Independent Viewport for MBD 3D PDF 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.