Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
<html>
<head>
<title>Insert Ray 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,Rays">
</head>
<body>
<h1>Insert Ray Example (VB.NET)</h1>
<p>This example shows how to insert a Ray in a drawing document.</p>
<pre>'--------------------------------------------------------------
' 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:
' <i>install_dir</i>\<b>APISDK\tlb\DraftSight.Interop.dsAutomation.dll</b>.
' 4. Start DraftSight and open a document.
' 5. Start debugging the project.
'
' Postconditions: A message box pops up when a Ray is
' inserted in the drawing document.
'----------------------------------------------------------------</pre>
<pre>Imports DraftSight.Interop.dsAutomation</pre>
<pre>Module Module1</pre>
<pre> Sub Main()
Dim dsApp As Application
Dim dsDoc As Document
Dim dsModel As Model
Dim dsSketchManager As SketchManager
Dim dsRay As Ray
Dim startX, startY, startZ, throughX, throughY, throughZ As Double</pre>
<pre> 'Connect to DraftSight
dsApp = GetObject(, "DraftSight.Application")
dsApp.<b>AbortRunningCommand</b>() ' abort any command currently running in DraftSight to avoid nested commands</pre>
<pre> 'Get active document
dsDoc = dsApp.GetActiveDocument()
If Not dsDoc Is Nothing Then</pre>
<pre> 'Get model space
dsModel = dsDoc.GetModel()</pre>
<pre> 'Get Sketch Manager
dsSketchManager = dsModel.GetSketchManager()</pre>
<pre> 'Ray parameters
startX = 0.0#
startY = 0.0#
startZ = 0.0#
throughX = 2.0#
throughY = 3.0#
throughZ = 0.0#</pre>
<pre> 'Add a Ray
dsRay = dsSketchManager.InsertRay(startX, startY, startZ, throughX, throughY, throughZ)</pre>
<pre> If Not dsRay Is Nothing Then
MsgBox("Ray was added to drawing.")
End If</pre>
<pre> Else</pre>
<pre> MsgBox("There are no open documents in DraftSight.")</pre>
<pre> End If</pre>
<pre> End Sub</pre>
<pre>End Module</pre>
<p> </p>
</body>
</html>