Hide Table of Contents

Get and Set Loft's Pick Points Example (C#)

This example shows how to get the pick points of a loft feature.

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

// Preconditions:

// 1. Open:

// <SolidWorks_install_dir>\samples\tutorial\cosmosfloxpress\ball valve\handle.sldprt

// 2. The feature named 1 (a loft feature) is selected.

//

// Postconditions: New loft pick points set.

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

using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swconst;

using System;

using System.Diagnostics;

namespace GetPickPointsLoft_CSharp.csproj

{

    partial class SolidWorksMacro

    {

        ModelDoc2 swModel;

        SelectionMgr swSelMgr;

        Feature swFeat;

        LoftFeatureData swFeatData;

        MathPoint swMathPoint;

        MathPoint[] newMathPoint;

        double[] newTopPoint = new double[4];

        double[] pointArray;

        object[] pickPointData;

        object pointVar;

        object newTopVar;

        object[] pointData;

        long selCount;

        long chainCount;

        long pointCount;

        long numberOfChains;

        long numOfPointInEachChain;

        long newCount;

        public void Main()

        {

            swModel = (ModelDoc2)swApp.ActiveDoc;

            swSelMgr = (SelectionMgr)swModel.SelectionManager;

            selCount = swSelMgr.GetSelectedObjectCount();

            if (selCount != 1)

            {

                System.Windows.Forms.MessageBox.Show("Select a loft feature.");

            }

            swFeat = (Feature)swSelMgr.GetSelectedObject6(1, -1);

            swFeatData = (LoftFeatureData)swFeat.GetDefinition();

 

            // Get the loft's pick points

            newCount = 0;

            pickPointData = (Object[])swFeatData.PickPoints;

            numberOfChains = pickPointData.GetUpperBound(0) + 1;

            Debug.Print("No. of chains = " + numberOfChains);

            Debug.Print("");

            for (chainCount = pickPointData.GetLowerBound(0); chainCount <= pickPointData.GetUpperBound(0); chainCount++)

            {

                pointData = (Object[])pickPointData[chainCount];

                numOfPointInEachChain = pointData.GetUpperBound(0) + 1;

                Array.Resize(ref newMathPoint, (int)((numberOfChains * numOfPointInEachChain) - 1) + 1);

                Debug.Print("Chain = " + chainCount + ", Number of points = " + numOfPointInEachChain);

                for (pointCount = pointData.GetLowerBound(0); pointCount <= pointData.GetUpperBound(0); pointCount++)

                {

                    swMathPoint = (MathPoint)pointData[pointCount];

                    pointVar = swMathPoint.ArrayData;

                    newMathPoint[newCount] = swMathPoint;

                    newMathPoint[newCount].ArrayData = pointVar;

                    pointArray = (Double[])pointVar;

                    Debug.Print("X = " + (double)pointArray[0] * 1000 + " Y = " + (double)pointArray[1] * 1000 + " Z = " + (double)pointArray[2] * 1000);

                    newCount = newCount + 1;

                }

                Debug.Print("");

            }

 

            //Change the loft's pick points

            newTopPoint[0] = 0.0;

            newTopPoint[1] = 0.0;

            newTopPoint[2] = 0.2;

            newTopVar = newTopPoint;

            newMathPoint[2].ArrayData = newTopVar;

            newTopPoint[0] = 0.05;

            newTopPoint[1] = 0.0;

            newTopPoint[2] = 0.2;

            newTopVar = newTopPoint;

            newMathPoint[5].ArrayData = newTopVar;

            newTopPoint[0] = 0.05;

            newTopPoint[1] = 0.05;

            newTopPoint[2] = 0.2;

            newTopVar = newTopPoint;

            newMathPoint[8].ArrayData = newTopVar;

            newTopPoint[0] = 0.0;

            newTopPoint[1] = 0.05;

            newTopPoint[2] = 0.2;

            newTopVar = newTopPoint;

            newMathPoint[11].ArrayData = newTopVar;

 

            // Set the loft's new pick points

            Boolean status = false;

            status = swFeatData.AccessSelections(swModel, null);

            swFeatData.PickPoints = newMathPoint;

            status = swFeat.ModifyDefinition(swFeatData, swModel, null);

            Debug.Print("Loft pick points were modified: " + status);

        }

        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:   Get and Set Loft's Pick Points 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) 2010 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.