Hide Table of Contents

SOLIDWORKS API Help

Create Ground Plane Example (C#)

This example shows how to create a ground plane.

//------------------------------------------------------------------------------
// Preconditions: Ensure that the specified model exists.
//
// Postconditions: Creates Ground Plane1 in the Grond Planes folder of the
// FeatureManager design tree And modifies it.
//
// NOTE: Because the model is used elsewhere, do not save any changes to it.
//------------------------------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
 
namespace CreateGroundPlane_CSharp
{
    partial class SolidWorksMacro
    {
 
 
        private FeatureManager featmgr;
        private GroundPlaneFeatureData swGPData;
        private GroundPlaneFeatureData featdata;
        private Face2 ent;
        private Feature feat;
        private ModelDoc2 Part;
        private AssemblyDoc swAssembly;
        private bool boolstatus;
        private int longstatus = 0;
        private int longwarnings = 0;
 
 
        public void Main()
        {
 
            Part = swApp.OpenDoc6("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2019\\samples\\tutorial\\api\\assem2.sldasm", 2, 0, "", longstatus, longwarnings);
 
            swAssembly = (AssemblyDoc)Part;
            swApp.ActivateDoc2("assem2.sldasm"false, longstatus);
            Part = (ModelDoc2)swApp.ActiveDoc;
            featmgr = Part.FeatureManager;
 
            boolstatus = Part.Extension.SelectByRay(-0.124913770805165, 0.118854842937424, 0.0702747343940473, -0.620586476260429, -0.617739368127351, -0.482980846978724, 0.00309726603088958, 2, true, 0, 0);
 
            ent = (Face2)((SelectionMgr)(Part.SelectionManager)).GetSelectedObject6(1, -1);
            swGPData = (GroundPlaneFeatureData)featmgr.CreateDefinition((int)swFeatureNameID_e.swFmGroundPlane);
            swGPData.PlanarEntity = ent;
 
            feat = featmgr.CreateFeature(swGPData);
            Part.ClearSelection2(true);
            featdata = (GroundPlaneFeatureData)feat.GetDefinition();
            boolstatus = Part.Extension.SelectByRay(0.119119826446138, 0.00516103810082313, 0.183494239718641, -0.620586476260429, -0.617739368127351, -0.482980846978724, 0.00309726603088958, 2, false, 0, 0);
            ent = (Face2)((SelectionMgr)(Part.SelectionManager)).GetSelectedObject6(1, -1);
            featdata.AccessSelections(Part, null);
            featdata.PlanarEntity = ent;
            feat.ModifyDefinition(featdata, Part, null);
 
 
 
        }
 
        /// <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:   Create Ground Plane 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) 2019 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.