Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
draftsight
/
opt
/
dassault-systemes
/
DraftSight
/
APISDK
/
Construct_2D_PolyLine_Example_VBNET.htm
|
|---|
<html>
<head>
<title>Construct 2D PolyLine 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,PolyLines">
<meta name=MS-HKWD content="VB.NET examples,2D PolyLines">
</head>
<body>
<h1>Construct 2D PolyLine Example (VB.NET)</h1>
<p>This example shows how to construct a 2D PolyLine 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 2D PolyLine is
' constructed in the drawing document.
'----------------------------------------------------------------
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 dsPolyline As PolyLine
Dim coordinates(0 To 7) As Double
Dim closed As Boolean</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.<b>GetActiveDocument</b>()
If Not dsDoc Is Nothing Then</pre>
<pre> 'Get model space
dsModel = dsDoc.<b>GetModel</b>()</pre>
<pre> 'Get Sketch Manager
dsSketchManager = dsModel.<b>GetSketchManager</b>()</pre>
<pre> '2D PolyLine parameters
coordinates(0) = 0 : coordinates(1) = 2
coordinates(2) = 0 : coordinates(3) = 0
coordinates(4) = 6 : coordinates(5) = 0
coordinates(6) = 6 : coordinates(7) = 2
closed = True</pre>
<pre> 'Construct a 2D PolyLine
dsPolyline = dsSketchManager.<b>InsertPolyline2D</b>(coordinates, closed)</pre>
<pre> If Not dsPolyline Is Nothing Then
MsgBox("2D PolyLine 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>