Hide Table of Contents

Get Weld Bead Symbol Data Example (C#)

This example shows how to get weld bead symbol data in a drawing.

//----------------------------------------------------------------------------
// Preconditions:
// 1. Open a drawing that contains at least one view with a weld bead
//    annotation.
// 2. Open an Immediate window.
//
// Postconditions: Inspect the Immediate window.
//----------------------------------------------------------------------------
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 WeldBead_CSharp.csproj
{
    partial class SolidWorksMacro
    {
 
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            DrawingDoc swDraw = default(DrawingDoc);
            Sheet swSheet = default(Sheet);
            View swView = default(View);
            WeldBead swWBead = default(WeldBead);
            DisplayData swDispData = default(DisplayData);
            string strFilled = null;
            int lineCount = 0;
            double[] vLine = null;
            int lineColor = 0;
            int lineLineType = 0;
            int lineStyle = 0;
            int lineWeight = 0;
            double lineX = 0;
            double lineY = 0;
            double lineZ = 0;
            int polygonCount = 0;
            double[] vPolygon = null;
            int polyColor = 0;
            int polyLineType = 0;
            int polyNumPts = 0;
            double polyX = 0;
            double polyY = 0;
            double polyZ = 0;
            int index = 0;
            int index2 = 0;
            int arrayIndex = 0;
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
            swDraw = (DrawingDoc)swModel;
            swSheet = (Sheet)swDraw.GetCurrentSheet();
            swView = (View)swDraw.GetFirstView();
 
 
            while ((swView != null))
            {
                Debug.Print(swView.Name);
                swWBead = swView.GetFirstWeldBead();
 
 
                while ((swWBead != null))
                {
                    Debug.Print("  Weld Bead...");
                    if ((swWBead.SolidFill == false))
                    {
                        strFilled = "open";
                    }
                    else
                    {
                        strFilled = "solid filled";
                    }
 
                    swDispData = (DisplayData)swWBead.GetAnnotation().GetDisplayData();
                    lineCount = swDispData.GetLineCount();
                    Debug.Print("    Line count = " + lineCount);
 
                    for (index = 0; index <= lineCount - 1; index++)
                    {
                        vLine = (double[])swDispData.GetLineAtIndex3(index);
                        if ((vLine != null))
                        {
                            lineColor = (int)vLine[0];
                            lineLineType = (int)vLine[1];
                            lineStyle = (int)vLine[2];
                            lineWeight = (int)vLine[3];
                            Debug.Print("      Color = " + lineColor + ", line type = " + lineLineType + ", line style = " + lineStyle + ", line weight = " + lineWeight);


                            arrayIndex = 4;
                            for (index2 = 0; index2 <= 1; index2++)
                            {
                                lineX = (double)vLine[arrayIndex];
                                lineY = (double)vLine[arrayIndex + 1];
                                lineZ = (double)vLine[arrayIndex + 2];
                                Debug.Print("       " + index2 + " (" + lineX + ", " + lineY + ", " + lineZ + ")");
                                arrayIndex = arrayIndex + 3;
                            }
                        }
                    }
 
                    Debug.Print("    Polyline count = " + swDispData.GetPolyLineCount());
                    Debug.Print("    Arc count = " + swDispData.GetArcCount());
                    polygonCount = swDispData.GetPolygonCount();
                    Debug.Print("    Polygon count = " + polygonCount);
 
                    for (index = 0; index <= polygonCount - 1; index++)
                    {
                        vPolygon = (double[])swDispData.GetPolygonAtIndex(index);
                        if ((vPolygon != null))
                        {
                            polyColor = (int)vPolygon[0];
                            polyLineType = (int)vPolygon[1];
                            polyNumPts = (int)vPolygon[4];
                            Debug.Print("      Color = " + polyColor + ", line type = " + polyLineType + ", point count = " + polyNumPts + ", " + strFilled);
                            arrayIndex = 5;
 
                            for (index2 = 0; index2 <= polyNumPts - 1; index2++)
                            {
                                polyX = (double)vPolygon[arrayIndex];
                                polyY = (double)vPolygon[arrayIndex + 1];
                                polyZ = (double)vPolygon[arrayIndex + 2];
                                Debug.Print("       " + index2 + " (" + polyX + ", " + polyY + ", " + polyZ + ")");
                                arrayIndex = arrayIndex + 3;
                            }
                        }
                    }
                    swWBead = swWBead.GetNext();
                }
                swView = (View)swView.GetNextView();
            }
 
        }
 
 
        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 Weld Bead Symbol 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) 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.