Hide Table of Contents

Insert Grid System Feature Example (C#)

This example shows how to insert a Grid System feature into a model.

//-----------------------------------------------------------------------------
// Preconditions:
// 1. Verify that the specified part template exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Opens a new part document.
// 2. Creates a sketch of a circle.
// 3. Inserts GridSystem1, which contains Surface-Extrude1, Level1, Level2,
//    and two derived sketches, in the FeatureManager design tree.
// 4. Sets the height of each level of the surface extrude to 50.0 mm.
// 5. Examine the Immediate window and graphics area.
// 6. Expand GridSystem1 in FeatureManager design tree.
//------------------------------------------------------------------------------

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Diagnostics;
namespace InsertGridFeature_CSharp.csproj
{
    
partial class SolidWorksMacro
    {

        
Feature GridFeature;
        
ModelDoc2 Part;
        
ModelView myModelView;
        
SketchSegment skSegment;
        
bool boolstatus;
        
int longstatus;

        
public void Main()
        {

            swApp.ResetUntitledCount(0, 0, 0);
            Part = (
ModelDoc2)swApp.NewDocument("C:\\ProgramData\\SOLIDWORKS\\SOLIDWORKS 2016\\templates\\Part.prtdot", 0, 0, 0);
            swApp.ActivateDoc2(
"Part1", false, ref longstatus);
            Part = (
ModelDoc2)swApp.ActiveDoc;

            myModelView = (
ModelView)Part.ActiveView;
            myModelView.FrameLeft = 0;
            myModelView.FrameTop = 0;
            myModelView.FrameState = (
int)swWindowState_e.swWindowMaximized;
            Part.ShowNamedView2(
"*Isometric", 7);

            skSegment = Part.SketchManager.CreateCircle(-0.019633, 0.076084, 0.0, -0.001997, 0.081475, 0.0);
            Part.SketchManager.InsertSketch(
true);

            boolstatus = Part.Extension.SelectByID2(
"Sketch1", "SKETCH", 0, 0, 0, false, 0, null, 0);

            
object offsetArray = null;
            
double[] heightsArray = new double[2];
            heightsArray[0] = 0.05;
            heightsArray[1] = 0.05;
            offsetArray = heightsArray;

            GridFeature = Part.FeatureManager.InsertGridFeature((offsetArray));
            
Debug.Print(GridFeature.Name + " was created.");

            Part.ViewZoomtofit();
        }

        
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 Grid System Feature 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) 2016 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.