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

<head>
<title>Create Rectangular Viewport 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, Viewports">


</head>


<body>
<h1>Create Rectangular Viewport Example (VBA)</h1>

<p>This example shows how to create a rectangular Viewport.</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.
' 5  Open the Immediate window.
' 6. Run the macro.
'
' Postconditions:
' 1. A Viewport is created on Sheet2.
' 2. Examine the drawing and output printed
'    to the Immediate window.
'----------------------------------------------------------------</pre>
<pre>Option Explicit</pre>
<pre>Sub main()
    Dim dsApp As DraftSight.Application
    Dim dsDoc As DraftSight.Document
    Dim SheetName as String
    Dim dsSheets As Variant
    Dim dsSheet As DraftSight.Sheet
    Dim index As Long
    Dim dsViewport As DraftSight.Viewport
    Dim dsMathUtility As DraftSight.MathUtility
    Dim startCorner As DraftSight.MathPoint
    Dim oppositeCorner As DraftSight.MathPoint
    Dim isClipped As Boolean    </pre>
<pre>    'Connect to DraftSight
    Set dsApp = GetObject(, &quot;DraftSight.Application&quot;)    </pre>
<pre>    '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>        'Switch to Sheet space and activate Sheet2
        dsSheets = dsDoc.<b>GetSheets</b>
        If IsArray(dsSheets) Then
            For index = LBound(dsSheets) To UBound(dsSheets)
                Set dsSheet = dsSheets(index)
                'Get sheet name
                SheetName = dsSheet.<b>Name</b>
                'Change sheet name, if it is not a model
                If SheetName &lt;&gt; &quot;Model&quot; Then
                    'Activate sheet
                    dsSheet.<b>Activate</b>
                End If
            Next
        End If       </pre>
<pre>        ' Set the corners for the Viewport
        Set dsMathUtility = dsApp.<b>GetMathUtility</b>
        Set startCorner = dsMathUtility.<b>CreatePoint</b>(0, 0, 0)
        Set oppositeCorner = dsMathUtility.<b>CreatePoint</b>(3, 3, 0)        </pre>
<pre>        'Create a rectangular Viewport
        Set dsViewport = dsSheet.<b>InsertRectangularViewport</b>(dsStandardViewports_1, False, startCorner, oppositeCorner)        </pre>
<pre>        ' Activate and access the rectangular Viewport
        dsViewport.<b>Active</b> = True        </pre>
<pre>        Debug.Print (SheetName &amp; &quot;:&quot;)
        Debug.Print &quot;  Viewport:&quot;
        dsViewport.<b>GetIsClipped</b> (isClipped)
        Debug.Print &quot;    Clipped by an entity?       &quot; &amp; isClipped
        Debug.Print &quot;    Height:                     &quot; &amp; dsViewport.<b>Height</b>
        Debug.Print &quot;    Width:                      &quot; &amp; dsViewport.<b>Width</b>
        Debug.Print &quot;    Locked in model workspace?  &quot; &amp; dsViewport.<b>DisplayLocked</b>
        Debug.Print &quot;    Displayed in graphics area? &quot; &amp; dsViewport.<b>IsOn</b>
        Debug.Print &quot;    Visible?                    &quot; &amp; dsViewport.<b>Visible</b>                </pre>
<pre>    Else

        Debug.Print &quot;There are no open documents in DraftSight.&quot;        </pre>
<pre>    End If
End Sub</pre>

</body>

</html>