Hide Table of Contents

Get Broken-Out Section Feature Data Example (C#)

This example shows how to get broken-out section feature data from a drawing view.

//----------------------------------------------------------------------------
// Preconditions: Open a drawing that contains a view with a broken-out
// section feature.
//
// Postconditions:
// 1. Inspect the Immediate window.
// 2. The radius of the broken-out section is increased.
// ---------------------------------------------------------------------------
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;
namespace GetBrokenOutSections_CSharp.csproj
{
    
partial class SolidWorksMacro
    {
        
ModelDoc2 swDoc;
        
DrawingDoc swDDoc;
        
View swView;
        
object[] varSheet;
        
object[] varViews;
        
int I;
        
int J;
        
int K;
        
Feature swFeat;
        
BrokenOutSectionFeatureData swFeatData;
        
Entity swDepthRef;
        
object[] varBS;
        
bool doRelease;
        
object[] varskSeg;
        
int segCtr;
        
int segType;

        
public void Main()
        {
            swDoc = (
ModelDoc2)swApp.ActiveDoc;
            swDDoc = (
DrawingDoc)swDoc;
            swDoc.ClearSelection2(
true);
            varSheet = (
object[])swDDoc.GetViews();
            
for (I = varSheet.GetLowerBound(0); I <= varSheet.GetUpperBound(0); I++)
            {
                varViews = (
object[])varSheet[I];
                
// skip the sheet view
                for (J = 1; J <= varViews.GetUpperBound(0); J++)
                {
                    
View swView = default(View);
                    swView = (
View)varViews[J];
                    
Debug.Print("View: " + swView.Name);
                    
Debug.Print("  Number of broken-out sections in this view: " + swView.GetBreakOutSectionCount());
                    varBS = (
object[])swView.GetBreakOutSections();
                    
if ((!((varBS == null))))
                    {
                        
for (K = varBS.GetLowerBound(0); K <= varBS.GetUpperBound(0); K++)
                        {
                            swFeat = (
Feature)varBS[K];
                            EditFeature(swFeat);
                            swFeatData = (
BrokenOutSectionFeatureData)swFeat.GetDefinition();
                            swFeatData.AccessSelections(swDoc,
null);
                            swDepthRef = swFeatData.DepthReference;
                            
// get and select depth reference, if set
                            if ((swDepthRef == null))
                            {
                                
Debug.Print("              Depth of exposure in meters: " + swFeatData.Depth);
                            }
                            
else
                            {
                                swDepthRef.Select(
true);
                            }
                            swFeatData.ReleaseSelectionAccess();
                            swFeatData =
null;
                        }
                    }
                }
            }
        }
        
public void GetExistingValue()
        {
            swFeatData.EditSketch =
true;
            varskSeg = (
object[])swFeatData.SketchSegment;
            
if ((!((varskSeg == null))))
            {
                
Debug.Print("              Number of sketch segments: " + swFeatData.GetSketchSegmentCount());
            }
        }
        
public void EditFeature(Feature inFeat)
        {
            
Debug.Print("      Iterating on broken-out section: " + inFeat.Name);

            swFeatData = (
BrokenOutSectionFeatureData)inFeat.GetDefinition();
            swFeatData.AccessSelections(swDoc,
null);

            GetExistingValue();

            
if ((doRelease == false))
            {
                
if ((!((varskSeg == null))))
                {
                    
for (segCtr = varskSeg.GetLowerBound(0); segCtr <= varskSeg.GetUpperBound(0); segCtr++)
                    {
                        
SketchSegment swSeg = default(SketchSegment);
                        swSeg = (
SketchSegment)varskSeg[segCtr];
                        segType = swSeg.GetType();
                        
switch (segType)
                        {
                            
case (int)swSketchSegments_e.swSketchLINE:
                                
SketchLine swSegLine = default(SketchLine);
                                swSegLine = (
SketchLine)swSeg;
                                
Debug.Print("                  Segment type: Line");
                                swSegLine =
null;
                                
break;
                            
case (int)swSketchSegments_e.swSketchARC:
                                
SketchArc swSegArc = default(SketchArc);
                                swSegArc = (
SketchArc)swSeg;
                                
Debug.Print("                  Segment type: Arc");
                                
Debug.Print("                      Old radius: " + swSegArc.GetRadius());
                                
double newRad = 0;
                                newRad = swSegArc.GetRadius() + 0.005;
                                
Debug.Print("                      New radius: " + newRad);
                                swSegArc.SetRadius(newRad);
                                swSegArc =
null;
                                
break;
                            
default:
                                
Debug.Print("                  Segment type: Unknown");
                                
break;
                        }
                    }
                }
                inFeat.ModifyDefinition(swFeatData, swDoc,
null);
                swDoc.ClearSelection();
            }
            
else
            {
                swFeatData.ReleaseSelectionAccess();
            }
            varskSeg =
null;
            swFeatData =
null;
        }



        
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 Broken-Out Section Feature Data 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.