Auto-arrange Dimensions (C#)
This example shows how to auto-arrange the selected dimensions.
//------------------------------------------
//
// Preconidtions:
// 1. Open:
// <SolidWorks_install_dir>\samples\tutorial\advdrawings\foodprocessor.slddrw.
// 2. Box-select the dimensions in Drawing View1.
//
// Postconditions: The selected dimensions are auto-arranged.
//
// NOTE: Because the model is used elsewhere,
// do not save changes when closing it.
//
//------------------------------------------
using
SolidWorks.Interop.sldworks;
using
SolidWorks.Interop.swconst;
using System;
namespace
AlignDimensionsCSharp.csproj
{
partial
class
SolidWorksMacro
{
public
void Main()
{
ModelDoc2 swModel = default(ModelDoc2);
ModelDocExtension swModelDocExt = default(ModelDocExtension);
DrawingDoc swDrawingDoc = default(DrawingDoc);
bool status =
false;
swModel = (ModelDoc2)swApp.ActiveDoc;
swModelDocExt = (ModelDocExtension)swModel.Extension;
swDrawingDoc = (DrawingDoc)swModel;
status = swModelDocExt.AlignDimensions((int)swAlignDimensionType_e.swAlignDimensionType_AutoArrange,
0.001);
}
///
<summary>
///
The SldWorks swApp variable is pre-assigned for you.
///
</summary>
public
SldWorks swApp;
}
}