Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
<html>
<head>
<title>Construct InfiniteLine 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,InfiniteLines">
</head>
<body>
<h1>Construct InfiniteLine Example (VBA)</h1>
<p>This example shows how to construct an InfiniteLine.</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 the DraftSight type library,
' <i>install_dir</i>\<b>bin\dsAutomation.dll</b>.
' 4. Start DraftSight and open a drawing document.
' 5. Run the macro.
'
' Postconditions: A message box pops up when an InfiniteLine is
' constructed in the drawing document.
'----------------------------------------------------------------
Option Explicit</pre>
<pre>Sub main()</pre>
<pre> Dim dsApp As DraftSight.Application
Dim dsDoc As DraftSight.Document
Dim dsModel As DraftSight.Model
Dim dsSketchManager As DraftSight.SketchManager
Dim dsInfiniteLine As DraftSight.InfiniteLine
Dim x1, y1, z1, x2, y2, z2 As Double
</pre>
<pre> 'Connect to DraftSight
Set dsApp = GetObject(, "DraftSight.Application")
'Abort any command currently running in DraftSight
'to avoid nested commands
dsApp.<b>AbortRunningCommand</b></pre>
<pre> 'Get active document
Set dsDoc = dsApp.<b>GetActiveDocument</b>()
If Not dsDoc Is Nothing Then
</pre>
<pre> 'Get model space
Set dsModel = dsDoc.<b>GetModel</b>()
</pre>
<pre> 'Get Sketch Manager
Set dsSketchManager = dsModel.<b>GetSketchManager</b>()
</pre>
<pre> 'InfiniteLine parameters
x1 = 0#
y1 = 0#
z1 = 0#
x2 = 1#
y2 = 5#
z2 = 0#
</pre>
<pre> 'Draw an InfiniteLine
Set dsInfiniteLine = dsSketchManager.<b>InsertInfiniteLine</b>(x1, y1, z1, x2, y2, z2)
</pre>
<pre> If Not dsInfiniteLine Is Nothing Then
MsgBox "InfiniteLine 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>
</body>
</html>