Hide Table of Contents

Set Display Mode of View Example (C#)

This example shows how to set the display mode of a drawing view.

// -------------------------------------

// Preconditions:

// 1. Open a drawing and select a drawing view.

// 2. Open the Immediate window.

//

// Postconditions:

// 1. Gets the selected view's current display mode.

// 2. Resets the display mode.

// 3. Gets the new display mode.

// 4. Examine the Immediate window and graphics area.

// --------------------------------------

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Globalization;

using System.IO;

using System.Linq;

using System.Reflection;

using System.Runtime.CompilerServices;

using System.Security;

using System.Text;

using System.Threading.Tasks;

using Microsoft.VisualBasic;

using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swconst;

using System.Runtime.InteropServices;

 

 

namespace SetDisplayMode_CSharp

{

    public partial class SolidWorksMacro

    {

        public void Main()

        {

                ModelDoc2 swModel;

                DrawingDoc swDraw;

                Sheet swSheet;

                View swView;

                SelectionMgr swSelectionMgr;

 

                swModel = (ModelDoc2)swApp.ActiveDoc;

                swDraw = (DrawingDoc)swModel;

                swSheet = (Sheet)swDraw.GetCurrentSheet();

                swSelectionMgr = (SelectionMgr)swModel.SelectionManager;

 

                swView = (View)swSelectionMgr.GetSelectedObject6(1, -1);

 

                Debug.Print("=====Current Display Mode======");

                Debug.Print("");

 

                bool UseParentProp;

                UseParentProp = swView.GetUseParentDisplayMode();

                Debug.Print("Using parent view mode?  " + UseParentProp);

 

                long displayMode;

                displayMode = swView.GetDisplayMode2();

                Debug.Print("Current display mode as defined by swDisplayMode_e:  " + displayMode);

 

                bool Facetted;

                Facetted = swView.GetFacettedHlrDisplay();

                Debug.Print("Faceted (draft quality)?:  " + Facetted);

 

                bool EdgesMode;

                EdgesMode = swView.GetDisplayEdgesInShadedMode();

                Debug.Print("Display edges when the view is in shaded mode?  " + EdgesMode);

 

 

                bool cThreadQuality;

                cThreadQuality = swView.GetCThreadQuality();

                Debug.Print("Precision cosmetic thread dislay quality? " + cThreadQuality);

 

                // Reset display mode: Do not use parent view's display mode, shaded mode, draft quality, no edges displayed, precision cosmetic threads

                swView.SetDisplayMode4(false, 3, true, false, true);

 

                Debug.Print("");

                Debug.Print("=====After Setting Display Mode======");

                Debug.Print("");

                Debug.Print("Using parent view mode?  " + swView.GetUseParentDisplayMode());

                Debug.Print("Current display mode as defined by swDisplayMode_e:  " + swView.GetDisplayMode2());

                Debug.Print("Faceted (draft quality)?  " + swView.GetFacettedHlrDisplay());

                Debug.Print("Display edges when view is in shaded mode?  " + swView.GetDisplayEdgesInShadedMode());

                Debug.Print("Precision cosmetic thread dislay quality? " + swView.GetCThreadQuality());

            }

          

 

    // The SldWorks swApp variable is pre-assigned for you.

    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 Display Mode of View 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) 2021 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.