Hide Table of Contents

Insert Weld Bead Example (C#)

This example shows how to create a weld bead by programmatically selecting the top, stop, and contact faces and passing those faces as arrays to

IAssemblyDoc::InsertWeld2.

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

// Preconditions: Open an assembly document

//                in which you want to insert a

//                weld bead.

//

// Postconditions: Weld bead created using the

//                 specified top, stop, and contact

//                 faces. Weld bead appears in the

//                 FeatureManager design tree as a

//                 feature and now exists as a SolidWorks

//                 part document in c:\temp\bead2.sldprt.

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

using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swconst;

using System;

namespace InsertWeld2AssemblyDoc_CSharp.csproj

{

    partial class SolidWorksMacro

    {

        public void Main()

        {

            ModelDoc2 swModel = default(ModelDoc2);

            ModelDocExtension swModelDocExt = default(ModelDocExtension);

            SelectionMgr swSelectionMgr = default(SelectionMgr);

            Face2 selFace = default(Face2);

            Face2[] topFaces = new Face2[2];

            object t = null;

            Face2[] stopFaces = new Face2[4];

            object s = null;

            Face2[] contactFaces = new Face2[4];

            object c = null;

            AssemblyDoc swAssembly = default(AssemblyDoc);

            bool boolstatus = false;

            swModel = (ModelDoc2)swApp.ActiveDoc;

            swModelDocExt = swModel.Extension;

            swSelectionMgr = (SelectionMgr)swModel.SelectionManager;

            // Select top faces

            // Substitute your selections for the weld bead's top faces

            boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.01559163546833, 0.02520890274226, 0.02853818512551, true, 0, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(1, -1);

            topFaces[0] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01969239735822, 0.03064046036471, 0.01000498670771, true, 0, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(2, -1);

            topFaces[1] = selFace;

            t = topFaces;

            swModel.ClearSelection2(true);

            // Select stop faces

            // Substitute your selections for the weld bead's stop faces

            boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.01445017029672, 0.01448327651559, 0.07619999999997, true, 0, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(1, -1);

            stopFaces[0] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01773464730298, 0.01977465429431, 0.0432803149497, true, 0, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(2, -1);

            stopFaces[1] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.0195767596401, 0.02039971255846, -0.03291968505005, true, 4, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(3, -1);

            stopFaces[2] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.0218293117176, 0.01005028977147, 0, true, 4, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(4, -1);

            stopFaces[3] = selFace;

            s = stopFaces;

            swModel.ClearSelection2(true);

            // Select contact faces

            // Substitute your selections for the weld bead's contact faces

            boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.00139666394648, 0.0163969139561, 0.05736881478452, true, 2, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(1, -1);

            contactFaces[0] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0, 0.009181832977731, 0.05743695965685, true, 2, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(2, -1);

            contactFaces[1] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01087386157639, 0.009644726364513, -0.02560526716087, true, 2, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(3, -1);

            contactFaces[2] = selFace;

            boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.006349999999941, 0.02091223363979, -0.01486524507766, true, 2, null, 0);

            selFace = (Face2)swSelectionMgr.GetSelectedObject6(4, -1);

            contactFaces[3] = selFace;

            c = contactFaces;

            swModel.ClearSelection2(true);

            // Insert a weld bead

            swAssembly = (AssemblyDoc)swModel;

            swAssembly.InsertWeld2("BACK", "CNV", 0.009525, 0.009525, 0.0381, "C:\\temp\\bead2.sldprt", t, s, c);

        }

        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:   Insert Weld Bead 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.