Hide Table of Contents

Insert Explode Line Sketch and Route Line Example (C#)

This example shows how to insert a route line in an explode line sketch.

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

// Preconditions: Open

//   <SolidWorks_install_dir>\samples\tutorial\cosmosfloxpress\ball valve\ball_valve.sldasm

//

// Postconditions:

// 1. An exploded view of the assembly is created.

// 2. A route line, which is a type of explode line, is added.

// 3. 3DExplode1, the explode line sketch, is located on the

//    ConfigurationManager tab. Click the ConfigurationManager

//    tab and expand default and ExplView1.

//

// NOTE: Because this assembly is used in a SolidWorks

//       online tutorial, do not save any changes when

//       you close the document.

// --------------------------------------------------------------------------using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swconst;

using System;

using System.Diagnostics;

namespace InsertRouteLine_CSharp.csproj

{

    partial class SolidWorksMacro

    {

        ModelDoc2 swModel;

        AssemblyDoc swAssembly;

        ModelDocExtension swModelDocExt;

        SelectionMgr swSelMgr;

        Sketch swSketch;

        SketchManager swSketchMgr;

        Edge swEdge;

        Edge[] edgesIn = new Edge[2];

        Boolean[] itemsReverse = new Boolean[2];

        Boolean[] itemsPath = new Boolean[2];

        Boolean[] alongXYZ = new Boolean[2];

        bool boolstatus;

        public void Main()

        {

            swModel = (ModelDoc2)swApp.ActiveDoc;

            swAssembly = (AssemblyDoc)swModel;

            swSelMgr = (SelectionMgr)swModel.SelectionManager;

            swModelDocExt = swModel.Extension;

            swSketchMgr = swModel.SketchManager;

            // Explode the assembly

            swAssembly.AutoExplode();

            swModel.EditRebuild3();

            swModel.ViewZoomtofit2();

            // Insert an explode line sketch

            swSketchMgr.InsertExplodeLineSketch();

            // Select two edges for the route line

            boolstatus = swModelDocExt.SelectByID2("", "EDGE", -0.006286592037611, 0.01346036693855, 0.001030754120677, false, 0, null, 0);

            swEdge = (Edge)swSelMgr.GetSelectedObject6(1, -1);

            edgesIn[0] = swEdge;

            swModel.ClearSelection2(true);

            boolstatus = swModelDocExt.SelectByID2("", "EDGE", 0.005570973324609, 0.01354160258214, 0.1620508231301, false, 0, null, 0);

            swEdge = (Edge)swSelMgr.GetSelectedObject6(1, -1);

            edgesIn[1] = swEdge;

            swModel.ClearSelection2(true);

            itemsReverse[0] = false;

            itemsReverse[1] = false;

            itemsPath[0] = true;

            itemsPath[1] = false;

            alongXYZ[0] = true;

            alongXYZ[1] = false;

 

            // Insert the route line in the explode line sketch

            swSketch = (Sketch)swModel.GetActiveSketch2();

            Debug.Print("Route line inserted in explode line sketch? " + swSketch.InsertRouteLine(edgesIn, itemsReverse, itemsPath, alongXYZ));

            // Close the explode line sketch

            swSketchMgr.InsertExplodeLineSketch();

        }

        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:   Insert Explode Line Sketch and Route Line 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) 2013 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.