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

<head>
<title>Insert Ray 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,Rays">
</head>


<body>
<h1>Insert Ray Example (VBA)</h1>
<p>This example shows how to insert a Ray in a drawing document.</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 a Ray is
' inserted 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 dsRay As DraftSight.Ray
    Dim startX, startY, startZ, throughX, throughY, throughZ As Double    </pre>
<pre>    'Connect to DraftSight
    Set dsApp = GetObject(, &quot;DraftSight.Application&quot;)
    '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>()

        'Ray parameters
        startX = 0#
        startY = 0#
        startZ = 0#
        throughX = 2#
        throughY = 3#
        throughZ = 0#        </pre>
<pre>        'Add a Ray
        Set dsRay = dsSketchManager.<b>InsertRay</b>(startX, startY, startZ, throughX, throughY, throughZ)        </pre>
<pre>        If Not dsRay Is Nothing Then
            MsgBox &quot;Ray was added to drawing.&quot;
        End If        </pre>
<pre>    Else        </pre>
<pre>        MsgBox &quot;There are no open documents in DraftSight.&quot;        </pre>
<pre>    End If</pre>
<pre>End Sub</pre>

</body>

</html>