Hide Table of Contents

Create Local Curve-Driven Pattern Example (C#)

This example shows how to create a local curve-driven pattern feature.

//------------------------------------------------------------------------------
// Preconditions:
// 1. Specified assembly document to open exists.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Opens specified assembly document.
// 2. Selects the component and edge for the
//    local curve-driven pattern feature.
// 3. Creates a local curve-driven pattern feature.
// 4. Prints to the Immediate window values and settings
//    of the local curve-driven pattern feature.
// 5. Examine the Immediate window.
//
// NOTE: Because this assembly is used elsewhere, do not save
// changes.
//------------------------------------------------------------------------------
 
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
 
namespace FeatureLocalCurveDrivenCSharp.csproj
{
    public partial class SolidWorksMacro
    {
 
 
        public void Main()
        {
         ModelDoc2 swModel = default(ModelDoc2);
	ModelDocExtension swModelDocExt = default(ModelDocExtension);
	FeatureManager swFeatMgr = default(FeatureManager);
	Feature swFeat = default(Feature);
	LocalCurvePatternFeatureData swLocalCurvePatternFeat = default(LocalCurvePatternFeatureData);
	string fileName = null;
	bool status = false;
	int errors = 0;
	int warnings = 0;

	//Open assembly document
	fileName = "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\samples\\tutorial\\api\\assem20.sldasm";
	swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, ""ref errors, ref warnings);

	//Select a component and an edge
	//for the local curve-driven pattern
	swModelDocExt = (ModelDocExtension)swModel.Extension;
	status = swModelDocExt.SelectByID2("block20-1@assem20""COMPONENT", 0, 0, 0, false, 1, null, 0);
	status = swModelDocExt.SelectByID2("""EDGE", 0.131144367102934, 0.0844607238593085, -0.124705856534547, true, 2, null, 0);

	//Create local curve-driven pattern feature
	swFeatMgr = (FeatureManager)swModel.FeatureManager;

	//Set EqualSpacing1 to False
	swFeat = (Feature)swFeatMgr.FeatureLocalCurveDrivenPattern(false, 3, false, 0.15, (int)swLocalCurvePatternReferencePoint_e.swLocalCurvePatternBoundingBoxCenter, (int)swLocalCurvePatternCurveMethod_e.swLocalCurvePatternOffsetCurve, (int)swLocalCurvePatternAlignment_e.swLocalCurvePatternAlignToSeed, falsefalse, 0,
	false, 0, false);

	//Set EqualSpacing1 to True
	//Set swFeat = swFeatMgr.FeatureLocalCurveDrivenPattern(False, 3, True, 0.5, (int)swLocalCurvePatternReferencePoint_e.swLocalCurvePatternBoundingBoxCenter, (int)swLocalCurvePatternCurveMethod_e.swLocalCurvePatternOffsetCurve, (int)swLocalCurvePatternAlignment_e.swLocalCurvePatternAlignToSeed, False, False, 0, False, 0, False)        

	//Get local curve-driven pattern feature data
	swLocalCurvePatternFeat = (LocalCurvePatternFeatureData)swFeat.GetDefinition();
	Debug.Print("Local curve-driven pattern properties: ");
	Debug.Print("  Number of components: " + swLocalCurvePatternFeat.GetPatternComponentCount());
	Debug.Print("  Number of skipped items: " + swLocalCurvePatternFeat.GetSkippedItemCount());
	Debug.Print("  Direction 1: ");
	Debug.Print("     Number of pattern instances: " + swLocalCurvePatternFeat.D1InstanceCount);
	Debug.Print("     Is direction flipped: " + swLocalCurvePatternFeat.D1ReverseDirection);
	Debug.Print("     Pattern instances equal spaced: " + swLocalCurvePatternFeat.D1IsEqualSpaced);
	Debug.Print("     Spacing for pattern instances: " + swLocalCurvePatternFeat.D1Spacing);
	Debug.Print("     Curve method: " + swLocalCurvePatternFeat.D1CurveMethod);
	Debug.Print("     Alignment method: " + swLocalCurvePatternFeat.D1AlignmentMethod);
	Debug.Print("  Direction 2:");
	Debug.Print("     Is Direction 2 specified: " + swLocalCurvePatternFeat.Dir2Specified);
        }
 
        /// <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 Local Curve-Driven Pattern 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) 2015 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.