Hide Table of Contents

Create Full Symmetrical Angular Dimension Example (C#)

This example shows how to create a full symmetrical angular dimension between a centerline and a line.

//---------------------------------------------------------
// Preconditions: Verify that the specified part document template
// exists.
//
// Postconditions:
// 1. Opens a new part document.
// 2. Opens a sketch.
// 3. Creates a centerline and three lines in
//    the open sketch.
// 4. Selects the centerline and one of the lines.
// 5. Suppresses the dimension dialog.
// 6. Creates a full symmetrical angular dimension for
//    the entities selected in step 4.
// 7. Unsuppresses the dimension dialog.
// 8. Examine the graphics area to verify step 6.
//----------------------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
 
namespace AddSymmetricDimensionCSharp.csproj
{
    public partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            SketchManager swSketchMgr = default(SketchManager);
            SketchSegment swSketchSegment = default(SketchSegment);
            ModelDocExtension swModelDocExt = default(ModelDocExtension);
            DisplayDimension swDisplayDimension = default(DisplayDimension);
            bool status = false;
 
            swModel = (ModelDoc2)swApp.NewDocument("C:\\ProgramData\\SolidWorks\\SolidWorks 2015\\templates\\Part.prtdot", 0, 0, 0);
 
            //Sketch a centerline and three lines
            swSketchMgr = (SketchManager)swModel.SketchManager;
            swSketchMgr.InsertSketch(true);
            swSketchSegment = (SketchSegment)swSketchMgr.CreateCenterLine(0.0, 0.043667, 0.0, 0.0, -0.050556, 0.0);
            swSketchSegment = (SketchSegment)swSketchMgr.CreateLine(-0.102, 0.039667, 0.0, -0.086223, 0.011, 0.0);
            swSketchSegment = (SketchSegment)swSketchMgr.CreateLine(0.142445, 0.066556, 0.0, 0.100889, -0.032333, 0.0);
            swSketchSegment = (SketchSegment)swSketchMgr.CreateLine(0.085334, 0.036556, 0.0, 0.049658, -0.048341, 0.0);
 
            //Select the centerline and one of the lines
            swModelDocExt = (ModelDocExtension)swModel.Extension;
            status = swModelDocExt.SelectByID2("Line1""SKETCHSEGMENT", -0.000222223294397278, 0.0223334410869282, 0, false, 0, null, 0);
            status = swModelDocExt.SelectByID2("Line3""SKETCHSEGMENT", 0.113556103437018, -0.00144445141358242, 0, true, 0, null, 0);
            swModel.ClearSelection2(true);
 
            //Suppress the dimension dialog box
            swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swInputDimValOnCreate, false);
 
            //Create a full symmetrical angular dimension
            status = swModelDocExt.SelectByID2("Line1""SKETCHSEGMENT", -0.000222223294397278, 0.0223334410869282, 0, false, 0, null, 0);
            status = swModelDocExt.SelectByID2("Line3""SKETCHSEGMENT", 0.113556103437018, -0.00144445141358242, 0, true, 0, null, 0);
            swDisplayDimension = (DisplayDimension)swModelDocExt.AddSymmetricDimension(0.0832913738352659, 0.112403597688285, 0);
            swModel.ClearSelection2(true);
 
            //Unsuppress the dimension dialog box
            swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swInputDimValOnCreate, true);
 
            swModel.ViewZoomtofit2();
 
 
        }
 
        /// <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 Full Symmetrical Angular Dimension 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) 2016 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.