Get Fixed Face of Flatten-Bends Feature Example (C#)
This example shows how to get the fixed face of a flatten-bends feature.
//------------------------------------------------------------------
// Preconditions:
// 1. Open a sheet metal part.
// 2. Select a flatten-bends feature in the FeatureManager design
// tree.
//
// Postconditions:
// 1. The macro rolls the FeatureManager design tree back to the feature
// that contains the fixed face of the flatten-bends feature.
// 2. The macro pauses and selects the fixed face of the
// flatten-bends feature.
// 3. Press F5 to roll the FeatureManager design tree forward
// and run the macro to completion.
//-------------------------------------------------------
using
Microsoft.VisualBasic;
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Data;
using
System.Diagnostics;
using
SolidWorks.Interop.sldworks;
using
SolidWorks.Interop.swconst;
using
System.Runtime.InteropServices;
namespace
GetFixedFace_CSharp.csproj
{
partial
class
SolidWorksMacro
{
public
void Main()
{
ModelDoc2
swModel = default(ModelDoc2);
SelectionMgr
swSelMgr = default(SelectionMgr);
Feature
swFeat = default(Feature);
BendsFeatureData
swBends = default(BendsFeatureData);
Face2
swFace = default(Face2);
Entity
swEntity = default(Entity);
bool
bRet = false;
swModel = (ModelDoc2)swApp.ActiveDoc;
swSelMgr = (SelectionMgr)swModel.SelectionManager;
swFeat = (Feature)swSelMgr.GetSelectedObject6(1,
-1);
swBends = (BendsFeatureData)swFeat.GetDefinition();
// Roll back to access the
flatten-bends feature data
bRet =
swBends.AccessSelections(swModel, null);
swFace = (Face2)swBends.GetFixedFace();
swEntity = (Entity)swFace;
bRet = swEntity.Select4(false,
null);
System.Diagnostics.Debugger.Break();
//
The fixed face is selected in the graphics area
//
Cancel any changes made
swBends.ReleaseSelectionAccess();
}
public
SldWorks
swApp;
}
}