Hide Table of Contents

Create Mathematical Circular Arcs Example (VB.NET)

This example shows how to create mathematical circular Arcs.

'--------------------------------------------------------------
' Preconditions:
' 1. Create a VB.NET Windows console project.
' 2. Copy and paste this example into the VB.NET IDE.
' 3. Add a reference to:
'    install_dir\APISDK\tlb\DraftSight.Interop.dsAutomation.dll.
' 4. Add a reference to System.Windows.Forms.
' 5. Start DraftSight.
' 6. Press F5.
'
' Postconditions: 
' 1. Connects to DraftSight.
' 2. Gets the active document.
' 3. Creates a mathematical circular Arc.
' 4. Gets the point on the mathematical circular Arc
'    closest to a mathematical point. Click OK to close
'    the message box.
' 5. Sets the radius for the mathematical circular Arc.
' 6. Creates a mathematical circular Arc.
' 7. Sets the radius for the mathematical circular Arc.
'----------------------------------------------------------------
 
Imports System
Imports DraftSight.Interop.dsAutomation
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
 
Module Module1
 
    Sub Main()
        Dim dsApp As DraftSight.Interop.dsAutomation.Application
 
        'Connects to DraftSight application
        dsApp = DirectCast(Marshal.GetActiveObject("DraftSight.Application"), DraftSight.Interop.dsAutomation.Application)
 
        If dsApp Is Nothing Then
            Return
        End If
 
        'Aborts any command currently running in DraftSight
        'to avoid nested commands
        dsApp.AbortRunningCommand()
 
        'Gets active document
        Dim dsDoc As Document = dsApp.GetActiveDocument()
        If dsDoc Is Nothing Then
            MessageBox.Show("There are no open documents in DraftSight.")
            Return
        End If
 
        Dim dsMathUtility As MathUtility = dsApp.GetMathUtility()
 
        'Creates mathematical circular Arc
        Dim dsCenter As MathPoint = dsMathUtility.CreatePoint(3.0, 7.0, 0.0)
        Dim dsNormal As MathVector = dsMathUtility.CreateVector(1.0, 0.0, 0.0)
        Dim dsRadius As Double = 2
        Dim RefVector As MathVector = dsMathUtility.CreateVector(1.0, 0.0, 0.0)
        Dim dsMathCircArc As MathCircArc = dsMathUtility.CreateCircArc(dsCenter, dsNormal, RefVector, dsRadius, 20, 45)
 
        'Gets point on mathematical circular Arc
        'closest to this point
        Dim point As MathPoint = dsMathUtility.CreatePoint(3.0, 7.0, 0.0)
        Dim closestPoint As MathPoint = dsMathCircArc.GetClosestPointTo(point)
        Dim X As Double, Y As Double, Z As Double
        closestPoint.GetPosition(X, Y, Z)
        MessageBox.Show("Closest point of (3, 7, 0) is (" + CType(X, String) + ", " + CType(Y, String) + ", " + CType(Z, String) + ")")
        'Sets radius of mathematical circular Arc
        dsMathCircArc.Radius = 6.4
 
        'Creates mathematical circular Arc defining a Circle
        'using the specified center, normal, and radius 
        Dim center As MathPoint = dsMathUtility.CreatePoint(2.0, 3.1, 0.0)
        Dim normal As MathVector = dsMathUtility.CreateVector(1.0, 0.0, 0.0)
        Dim radius As Double = 3.0
        Dim circle As MathCircArc = dsMathUtility.CreateCircle(center, normal, radius)
 
    End Sub
End Module


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 Mathematical Circular Arcs Example (VB.NET)
*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) 2023 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.