Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
draftsight / opt / dassault-systemes / DraftSight / APISDK / Create_Angular_Dimensions_Example_VBNET.htm
Size: Mime:
<html>

<head>
<title>Create Angular Dimensions Example (VB.NET)</title>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="ApiHelp.css">
<meta name=MS-HKWD content="VB.NET examples">
<meta name=MS-HKWD content="VB.NET examples,angular Dimensions">
<meta name=MS-HKWD content="VB.NET examples,Dimensions">
<meta name=MS-HKWD content="Dimension, angular">
<meta name=MS-HKWD content="Angular Dimension">
<meta name=MS-HKWD content="Dimension">
<meta name=MS-HKWD content="Dimension, general">
</head>


<body>
<h1>Create Angular Dimensions Example (VB.NET)</h1>
<p>
This example shows how to create angular Dimensions using 3 points, 2 lines, and 
an arc.</p>

<pre>'-------------------------------------------------------------
' Preconditions:
' 1. Create a VB.NET Windows console project.
' 2. Copy and paste this project into the VB.NET IDE.
' 3. Add a reference to:
'    <i>install_dir</i>\<b>APISDK\tlb\DraftSight.Interop.dsAutomation</b>
' 4. Set a breakpoint at:
'    dsApp.Zoom(dsZoomRange_e.dsZoomRange_Fit, Nothing, Nothing)
' 5. Start DraftSight and open a document.
' 6. <font SIZE="2">Click Start Debugging</font>.
'
' Postconditions: 
' 1. Angular Dimensions using 3 points, 2 lines, and an arc are created. 
' 2. Examine the Output or Immediate window.
' 3. Click Continue.
' 4. Examine the drawing.
'------------------------------------------------------------
Imports System.IO
Imports DraftSight.Interop.dsAutomation</pre>
<pre>Module Module1</pre>
<pre>    Dim dsApp As Application</pre>
<pre>    Sub Main()</pre>
<pre>        'Connect to the DraftSight application
        dsApp = GetObject(, &quot;DraftSight.Application&quot;)
	dsApp.<b>AbortRunningCommand</b>() ' abort any command currently running in DraftSight to avoid nested commands</pre>
<pre>        'Get the active document
        Dim dsDoc As Document = dsApp.<b>GetActiveDocument</b>()
        If dsDoc Is Nothing Then
            MsgBox(&quot;There are no open documents in DraftSight.&quot;)
            Return
        End If</pre>
<pre>        'Get the model space
        Dim dsModel As Model = dsDoc.<b>GetModel</b>()</pre>
<pre>        'Get the sketch manager
        Dim dsSketchMgr As SketchManager = dsModel.<b>GetSketchManager</b>()</pre>
<pre>        'Add an angular Dimension using three points
        Dim dsAngular3PointDim As AngularDimension = AddAngularDimensionUsing3Points(dsSketchMgr)</pre>
<pre>        'Print the angular Dimension's properties
        PrintAngularDimProperties(dsAngular3PointDim)</pre>
<pre>        'Add the angular Dimension using two lines
        Dim dsAngular2LinesDim As AngularDimension = AddAngularDimensionUsing2Lines(dsSketchMgr)</pre>
<pre>        'Print the angular Dimension's properties
        PrintAngularDimProperties(dsAngular2LinesDim)</pre>
<pre>        'Add an angular Dimension for the arc
        Dim dsAngularArcDim As AngularDimension = AddAngularDimensionForArc(dsSketchMgr)</pre>
<pre>        'Print the angular Dimension's properties
        PrintAngularDimProperties(dsAngularArcDim)</pre>
<pre>        'Zoom to fit
        dsApp.<b>Zoom</b>(dsZoomRange_e.dsZoomRange_Fit, Nothing, Nothing)
    End Sub</pre>
<pre>    Private Function AddAngularDimensionForArc(ByVal dsSketchMgr As SketchManager) As AngularDimension
        'Draw an arc
        Dim centerX As Double = 18, centerY As Double = 2, centerZ As Double = 0
        Dim radius As Double = 3
        Dim startAngle As Double = 0.0, endAngle As Double = Math.PI / 2
        Dim dsArc As CircleArc = dsSketchMgr.<b>InsertArc</b>(centerX, centerY, centerZ, radius, startAngle, endAngle)</pre>
<pre>        'Angular Dimension's position
        Dim dimPosition As Double() = New Double() {20, 5, 0}</pre>
<pre>        'Text override
        Dim dimTextOverride As String = &quot;AngularDimArc&quot;</pre>
<pre>        Dim dsAngularDim As AngularDimension = dsSketchMgr.<b>InsertAngularDimensionArc</b>(dsArc, dimPosition, dimTextOverride)</pre>
<pre>        Debug.Print(Environment.NewLine + &quot;An angular Dimension for an arc was added.&quot;)</pre>
<pre>        Return dsAngularDim
    End Function</pre>
<pre>    Private Function AddAngularDimensionUsing2Lines(ByVal dsSketchMgr As SketchManager) As AngularDimension
        'Draw two lines for an angular Dimension
        Dim dsFirstLine As Line = dsSketchMgr.<b>InsertLine</b>(7, 0, 0, 10, 3, 0)
        Dim dsSecondLine As Line = dsSketchMgr.<b>InsertLine</b>(12, 0, 0, 15, 2, 0)</pre>
<pre>        'Angular Dimension position
        Dim dimPosition As Double() = New Double() {13, 4, 0}</pre>
<pre>        'No text override - empty string
        Dim dimTextOverride As String = String.Empty</pre>
<pre>        Dim dsAngularDim As AngularDimension = dsSketchMgr.<b>InsertAngularDimension2Line</b>(dsFirstLine, dsSecondLine, dimPosition, dimTextOverride)</pre>
<pre>        Debug.Print(Environment.NewLine + &quot;An angular Dimension using two lines was added.&quot;)</pre>
<pre>        Return dsAngularDim
    End Function</pre>
<pre>    Private Function AddAngularDimensionUsing3Points(ByVal dsSketchMgr As SketchManager) As AngularDimension
        'Angular Dimension parameters
        Dim centerPoint As Double() = New Double() {0, 0, 0}
        Dim angleStartPoint As Double() = New Double() {2, 2, 0}
        Dim angleEndPoint As Double() = New Double() {2, 4, 0}
        Dim dimPosition As Double() = New Double() {5, 5, 0}</pre>
<pre>        'No text override - empty string
        Dim dimTextOverride As String = String.Empty</pre>
<pre>        Dim dsAngular3PointDim As AngularDimension = dsSketchMgr.<b>InsertAngularDimension3Point</b>(centerPoint, angleStartPoint, angleEndPoint, dimPosition, dimTextOverride)</pre>
<pre>        Debug.Print(Environment.NewLine + &quot;An angular Dimension using three points was added.&quot;)</pre>
<pre>        Return dsAngular3PointDim
    End Function</pre>
<pre>    Private Sub PrintAngularDimProperties(ByVal dsAngularDim As AngularDimension)
        Debug.Print(&quot;  Angular Dimension parameters...&quot;)</pre>
<pre>        Debug.Print(&quot;    Type = &quot; + dsAngularDim.<b>Type</b>.ToString())</pre>
<pre>        'Get general Dimension object, which contains common Dimension properties
        Dim dsGeneralDim As GeneralDimension = dsAngularDim.<b>GetGeneralDimension</b>()</pre>
<pre>        Debug.Print(&quot;    Dimension style = &quot; + dsGeneralDim.<b>DimensionStyle</b>)
        Debug.Print(&quot;    Handle = &quot; + dsGeneralDim.<b>Handle</b>)
        Debug.Print(&quot;    Measurement (in radians) = &quot; + dsGeneralDim.<b>Measurement</b>.ToString())
        Debug.Print(&quot;    Related = &quot; + dsGeneralDim.<b>Related</b>.ToString())
        Debug.Print(&quot;    Text override = &quot; + dsGeneralDim.<b>TextOverride</b>)
        Debug.Print(&quot;    Text rotation = &quot; + dsGeneralDim.<b>TextRotation</b>.ToString)</pre>
<pre>        'Get text position
        Dim x As Double, y As Double
        dsGeneralDim.<b>GetTextPosition</b>(x, y)
        Debug.Print(&quot;    Text position (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;)&quot;)</pre>
<pre>        'Print specific parameters for angular Dimension
        Dim z As Double
        'Get center point
        dsAngularDim.<b>GetCenterPoint</b>(x, y, z)
        Debug.Print(&quot;    Center point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)</pre>
<pre>        'Get arc point
        dsAngularDim.<b>GetArcPoint</b>(x, y, z)
        Debug.Print(&quot;    Arc point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)</pre>
<pre>        'Get first line's start point
        dsAngularDim.<b>GetLine1Point</b>(x, y, z)
        Debug.Print(&quot;    Line1's start point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)</pre>
<pre>        'Get first line end point
        dsAngularDim.<b>GetLine1EndPoint</b>(x, y, z)
        Debug.Print(&quot;    Line1's end point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)</pre>
<pre>        'Get second line start point
        dsAngularDim.<b>GetLine2Point</b>(x, y, z)
        Debug.Print(&quot;    Line2's start point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)</pre>
<pre>        'Get second line end point
        dsAngularDim.<b>GetLine2EndPoint</b>(x, y, z)
        Debug.Print(&quot;    Line2's end point (&quot; + x.ToString + &quot;,&quot; + y.ToString + &quot;,&quot; + z.ToString + &quot;)&quot;)
    End Sub</pre>
<pre>
End Module</pre>

</body>

</html>