Hide Table of Contents

Create Revolve Features Example (C#)

This example shows how to create revolve features.

//----------------------------------------------------------------------------
// Preconditions:
// 1. Open a new part document.
// 2. Rename the namespace to match your C# project.
//
// Postconditions: Two revolve features and one cut-revolve feature are created.
//----------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
namespace FeatureRevolves_CSharp.csproj
{
    
partial class SolidWorksMacro
    {
        
ModelDoc2 swModel;
        
ModelDocExtension swModelDocExt;
        
FeatureManager swFeatMgr;
        
SelectionMgr swSelMgr;

        
bool boolstatus;

        
public void Main()
        {
            swModel = (
ModelDoc2)swApp.ActiveDoc;
            swModelDocExt = swModel.Extension;
            swSelMgr = (
SelectionMgr)swModel.SelectionManager;

            
// Create an axis
            boolstatus = swModelDocExt.SelectByID2("Right Plane", "PLANE", 0, 0, 0, true, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            boolstatus = swModelDocExt.SelectByID2(
"Top Plane", "PLANE", 0, 0, 0, true, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            swModel.InsertAxis2(
true);

            
// Create a rectangle
            boolstatus = swModelDocExt.SelectByID2("Top Plane", "PLANE", -0.08954836342753, 0.0004336873289503, 0.006720765739942, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            swModel.InsertSketch2(
true);
            swModel.ClearSelection2(
true);
            swModel.SketchRectangle(-0.05668466821757, -0.02198379306525, 0, -0.01330857427717, 0.03972855876814, 0,
true);

            
// Create the first revolve feature
            swModel.InsertSketch2(true);
            swModel.ShowNamedView2(
"*Trimetric", 8);
          
            boolstatus = swModelDocExt.SelectByID2(
"Sketch1", "SKETCH", 0, 0, 0, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            boolstatus = swModelDocExt.SelectByID2(
"Axis1", "AXIS", 0, 0, 0, true, 16, null, (int)swSelectOption_e.swSelectOptionDefault);
            swFeatMgr = swModel.FeatureManager;
          
            swFeatMgr.FeatureRevolve2(
true, true, false, false, false, false, 0, 0, 6.28318530718, 0, false,
            
false, 0.01, 0.01, 0, 0, 0, true, true, true);

            
// Create a cut-revolve feature using a face on the revolve feature
            swSelMgr.EnableContourSelection = false;
            boolstatus = swModelDocExt.SelectByID2(
"", "FACE", -0.03095803920934, 0.01509536510872, 0.02198379306526, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            swModel.InsertSketch2(
true);
            swModel.ClearSelection2(
true);
            swModel.SketchRectangle(-0.04194874421597, 0.01774859621099, 0, -0.01883036471929, -0.01265654504095, 0,
true);
            swModel.InsertSketch2(
true);
          
            boolstatus = swModelDocExt.SelectByID2(
"Sketch2", "SKETCH", 0, 0, 0, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            boolstatus = swModelDocExt.SelectByID2(
"Line4@Sketch2", "EXTSKETCHSEGMENT", -0.01883036471929, 0.003802500010693, 0, true, 4, null, (int)swSelectOption_e.swSelectOptionDefault);
            swFeatMgr.FeatureRevolveCut(6.26573201466,
false, 0, 0, 0, true, true);

            
// Create the second revolve feature using a face on the first revolve feature
            swSelMgr.EnableContourSelection = false;
            boolstatus = swModelDocExt.SelectByID2(
"", "FACE", -0.02333512246603, 0.03472018719853, 0.0219837930652, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            swModel.InsertSketch2(
true);
            swModel.ClearSelection2(
true);
            swModel.CreateCircle2(-0.02232361399104, 0.03354683337932, 0, -0.01445073476016, 0.02795861773112, 0);
            swModel.InsertSketch2(
true);
          
            boolstatus = swModelDocExt.SelectByID2(
"Sketch3", "SKETCH", 0, 0, 0, false, 0, null, (int)swSelectOption_e.swSelectOptionDefault);
            boolstatus = swModelDocExt.SelectByID2(
"", "EDGE", -0.02437300231541, 0.01770755773555, 0.02200276940169, true, 4, null, (int)swSelectOption_e.swSelectOptionDefault);
            swFeatMgr.FeatureRevolve2(
true, true, false, false, false, false, 0, 0, 6.28318530718, 0, false,
            
false, 0.01, 0.01, 0, 0, 0, true, true, true);
            swSelMgr.EnableContourSelection =
false;

        }

        
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:   Create Revolve Features 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) 2017 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.