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_Mathematical_Circular_Arcs_Example_VBA.htm
Size: Mime:
<html>

<head>
<title>Create Mathematical Circular Arcs Example (VBA)</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="VBA examples">
<meta name=MS-HKWD content="VBA examples,math circular Arcs ">


</head>


<body>
<h1>Create Mathematical Circular Arcs Example (VBA)</h1>

<p>This example shows how to create mathematical circular Arcs.</p>
<pre>'-------------------------------------------------------------
' Preconditions:
' 1. Create a VBA macro in a software product in which VBA is
'    embedded.
' 2. Copy and paste this example into the Visual Basic IDE.
' 3. Add a reference to:
'    <i>install_dir</i><b>\bin\dsAutomation.dll.</b>
' 4. Start DraftSight.
' 5. 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.
'----------------------------------------------------------------
Option Explicit</pre>
<pre>Sub main()</pre>
<pre>    Dim dsApp As DraftSight.Application    </pre>
<pre>    'Connects to DraftSight application
    Set dsApp = GetObject(, &quot;DraftSight.Application&quot;)    </pre>
<pre>    'Aborts any command currently running in DraftSight
    'to avoid nested commands
    dsApp.<b>AbortRunningCommand</b>    </pre>
<pre>    'Gets active document
    Dim dsDoc As DraftSight.Document
    Set dsDoc = dsApp.<b>GetActiveDocument</b>()
    If dsDoc Is Nothing Then
        MsgBox (&quot;There are no open documents in DraftSight.&quot;)
        Return
    End If    </pre>
<pre>    Dim dsMathUtility As DraftSight.MathUtility
    Set dsMathUtility = dsApp.<b>GetMathUtility</b>()    </pre>
<pre>    'Creates mathematical circular Arc
    Dim dsCenter As DraftSight.MathPoint
    Set dsCenter = dsMathUtility.<b>CreatePoint</b>(3#, 7#, 0#)
    Dim dsNormal As DraftSight.MathVector
    Set dsNormal = dsMathUtility.<b>CreateVector</b>(1#, 0#, 0#)
    Dim dsRadius As Double
    dsRadius = 2
    Dim RefVector As DraftSight.MathVector
    Set RefVector = dsMathUtility.<b>CreateVector</b>(1#, 0#, 0#)
    Dim dsMathCircArc As DraftSight.MathCircArc
    Set dsMathCircArc = dsMathUtility.<b>CreateCircArc</b>(dsCenter, dsNormal, RefVector, dsRadius, 20, 45)
    </pre>
<pre>    'Gets point on mathematical circular Arc
    'closest to this point
    Dim point As DraftSight.MathPoint
    Set point = dsMathUtility.<b>CreatePoint</b>(3#, 7#, 0#)
    Dim closestPoint As DraftSight.MathPoint
    Set closestPoint = dsMathCircArc.<b>GetClosestPointTo</b>(point)
    Dim X As Double
    Dim Y As Double
    Dim Z As Double
    closestPoint.<b>GetPosition</b> X, Y, Z
    MsgBox (&quot;Closest point of (3, 7, 0) is (&quot; &amp; X &amp; &quot;, &quot; &amp; Y &amp; &quot;, &quot; &amp; Z &amp; &quot;)&quot;)
    'Sets radius of mathematical circular Arc
    dsMathCircArc.<b>radius</b> = 6.4
    </pre>
<pre>    'Creates mathematical circular Arc defining a Circle
    'using the specified center, normal, and radius
    Dim center As DraftSight.MathPoint
    Set center = dsMathUtility.<b>CreatePoint</b>(2#, 3.1, 0#)
    Dim normal As DraftSight.MathVector
    Set normal = dsMathUtility.<b>CreateVector</b>(1#, 0#, 0#)
    Dim radius As Double
    radius = 3#
    Dim dsCircle As DraftSight.MathCircArc
    Set dsCircle = dsMathUtility.<b>CreateCircle</b>(center, normal, radius)
    </pre>
<pre>End Sub</pre>

</body>

</html>