Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
draftsight
/
opt
/
dassault-systemes
/
DraftSight
/
APISDK
/
Create_Mathematical_Circular_Arcs_Example_VBNET.htm
|
|---|
<html>
<head>
<title>Create Mathematical Circular Arcs 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,math circular Arcs">
</head>
<body>
<h1>Create Mathematical Circular Arcs Example (VB.NET)</h1>
<p>This example shows how to create mathematical circular Arcs.</p>
<pre style="font-family: Consolas; font-size: 13; color: black; background: white"><span style="color: green">'--------------------------------------------------------------</span>
<span style="color: green">' Preconditions:</span>
<span style="color: green">' 1. Create a VB.NET Windows console project.</span>
<span style="color: green">' 2. Copy and paste this example into the VB.NET IDE.</span>
<span style="color: green">' 3. Add a reference to:</span>
<span style="color: green">' <i>install_dir</i>\<b>APISDK\tlb\DraftSight.Interop.dsAutomation.dll</b>.</span>
<span style="color: green">' 4. Add a reference to <b>System.Windows.Forms</b>.</span>
<span style="color: green">' 5. Start DraftSight.</span>
<span style="color: green">' 6. Press F5.</span>
<span style="color: green">'</span>
<span style="color: green">' Postconditions: </span>
<span style="color: green">' 1. Connects to DraftSight.</span>
<span style="color: green">' 2. Gets the active document.</span>
<span style="color: green">' 3. Creates a mathematical circular Arc.</span>
<span style="color: green">' 4. Gets the point on the mathematical circular Arc</span>
<span style="color: green">' closest to a mathematical point. Click OK to close
' the message box.</span>
<span style="color: green">' 5. Sets the radius for the mathematical circular Arc.</span>
<span style="color: green">' 6. Creates a mathematical circular Arc.</span>
<span style="color: green">' 7. Sets the radius for the mathematical circular Arc.</span>
<span style="color: green">'----------------------------------------------------------------</span>
<span style="color: blue">Imports</span> System
<span style="color: blue">Imports</span> DraftSight.Interop.dsAutomation
<span style="color: blue">Imports</span> System.Runtime.InteropServices
<span style="color: blue">Imports</span> System.Windows.Forms
<span style="color: blue">Module</span> <span style="color: #2b91af">Module1</span>
<span style="color: blue">Sub</span> Main()
<span style="color: blue">Dim</span> dsApp <span style="color: blue">As</span> DraftSight.Interop.dsAutomation.<span style="color: #2b91af">Application</span>
<span style="color: green">'Connects to DraftSight application</span>
dsApp = <span style="color: blue">DirectCast</span>(<span style="color: #2b91af">Marshal</span>.GetActiveObject(<span style="color: #a31515">"DraftSight.Application"</span>), DraftSight.Interop.dsAutomation.<span style="color: #2b91af">Application</span>)
<span style="color: blue">If</span> dsApp <span style="color: blue">Is</span> <span style="color: blue">Nothing</span> <span style="color: blue">Then</span>
<span style="color: blue">Return</span>
<span style="color: blue">End</span> <span style="color: blue">If</span>
<span style="color: green">'Aborts any command currently running in DraftSight</span>
<span style="color: green">'to avoid nested commands</span>
dsApp.<b>AbortRunningCommand</b>()
<span style="color: green">'Gets active document</span>
<span style="color: blue">Dim</span> dsDoc <span style="color: blue">As</span> <span style="color: #2b91af">Document</span> = dsApp.<b>GetActiveDocument</b>()
<span style="color: blue">If</span> dsDoc <span style="color: blue">Is</span> <span style="color: blue">Nothing</span> <span style="color: blue">Then</span>
<span style="color: #2b91af">MessageBox</span>.Show(<span style="color: #a31515">"There are no open documents in DraftSight."</span>)
<span style="color: blue">Return</span>
<span style="color: blue">End</span> <span style="color: blue">If</span>
<span style="color: blue">Dim</span> dsMathUtility <span style="color: blue">As</span> <span style="color: #2b91af">MathUtility</span> = dsApp.<b>GetMathUtility</b>()
<span style="color: green">'Creates mathematical circular Arc</span>
<span style="color: blue">Dim</span> dsCenter <span style="color: blue">As</span> <span style="color: #2b91af">MathPoint</span> = dsMathUtility.<b>CreatePoint</b>(3.0, 7.0, 0.0)
<span style="color: blue">Dim</span> dsNormal <span style="color: blue">As</span> <span style="color: #2b91af">MathVector</span> = dsMathUtility.<b>CreateVector</b>(1.0, 0.0, 0.0)
<span style="color: blue">Dim</span> dsRadius <span style="color: blue">As</span> <span style="color: blue">Double</span> = 2
<span style="color: blue">Dim</span> RefVector <span style="color: blue">As</span> <span style="color: #2b91af">MathVector</span> = dsMathUtility.<b>CreateVector</b>(1.0, 0.0, 0.0)
<span style="color: blue">Dim</span> dsMathCircArc <span style="color: blue">As</span> <span style="color: #2b91af">MathCircArc</span> = dsMathUtility.<b>CreateCircArc</b>(dsCenter, dsNormal, RefVector, dsRadius, 20, 45)
<span style="color: green">'Gets point on mathematical circular Arc</span>
<span style="color: green">'closest to this point</span>
<span style="color: blue">Dim</span> point <span style="color: blue">As</span> <span style="color: #2b91af">MathPoint</span> = dsMathUtility.<b>CreatePoint</b>(3.0, 7.0, 0.0)
<span style="color: blue">Dim</span> closestPoint <span style="color: blue">As</span> <span style="color: #2b91af">MathPoint</span> = dsMathCircArc.<b>GetClosestPointTo</b>(point)
<span style="color: blue">Dim</span> X <span style="color: blue">As</span> <span style="color: blue">Double</span>, Y <span style="color: blue">As</span> <span style="color: blue">Double</span>, Z <span style="color: blue">As</span> <span style="color: blue">Double</span>
closestPoint.<b>GetPosition</b>(X, Y, Z)
<span style="color: #2b91af">MessageBox</span>.Show(<span style="color: #a31515">"Closest point of (3, 7, 0) is ("</span> + <span style="color: blue">CType</span>(X, <span style="color: blue">String</span>) + <span style="color: #a31515">", "</span> + <span style="color: blue">CType</span>(Y, <span style="color: blue">String</span>) + <span style="color: #a31515">", "</span> + <span style="color: blue">CType</span>(Z, <span style="color: blue">String</span>) + <span style="color: #a31515">")"</span>)
<span style="color: green">'Sets radius of mathematical circular Arc</span>
dsMathCircArc.<b>Radius</b> = 6.4
<span style="color: green">'Creates mathematical circular Arc defining a Circle</span>
<span style="color: green">'using the specified center, normal, and radius </span>
<span style="color: blue">Dim</span> center <span style="color: blue">As</span> <span style="color: #2b91af">MathPoint</span> = dsMathUtility.<b>CreatePoint</b>(2.0, 3.1, 0.0)
<span style="color: blue">Dim</span> normal <span style="color: blue">As</span> <span style="color: #2b91af">MathVector</span> = dsMathUtility.<b>CreateVector</b>(1.0, 0.0, 0.0)
<span style="color: blue">Dim</span> radius <span style="color: blue">As</span> <span style="color: blue">Double</span> = 3.0
<span style="color: blue">Dim</span> circle <span style="color: blue">As</span> <span style="color: #2b91af">MathCircArc</span> = dsMathUtility.<b>CreateCircle</b>(center, normal, radius)
<span style="color: blue">End</span> <span style="color: blue">Sub</span>
<span style="color: blue">End</span> <span style="color: blue">Module</span>
</pre>
</body>
</html>