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

<head>
<title>Load and Activate LineStyles 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,LineStyles">
<meta name=MS-HKWD content="VBA examples,LineStyle Manager">
<meta name=MS-HKWD content="VBA examples,Lines">


</head>


<body>
<h1>Load and Activate LineStyles Example (VBA)</h1>

<p>This example shows how to load and activate LineStyles.</p>
<pre>'--------------------------------------------------------------
'&nbsp;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>.
'&nbsp;4.&nbsp;Start&nbsp;DraftSight&nbsp;and&nbsp;open&nbsp;a&nbsp;document.
'&nbsp;5.&nbsp;Start&nbsp;debugging&nbsp;the&nbsp;project.
'
'&nbsp;Postconditions:&nbsp;
'&nbsp;1.&nbsp;Gets&nbsp;the&nbsp;active&nbsp;document.
'&nbsp;2.&nbsp;Gets&nbsp;the&nbsp;LineStyle&nbsp;Manager.
'&nbsp;3.&nbsp;Loads&nbsp;the&nbsp;BATTING&nbsp;and&nbsp;ZIGAG&nbsp;LineStyles.
'&nbsp;4.&nbsp;Activates&nbsp;and&nbsp;draws&nbsp;a&nbsp;Line&nbsp;for&nbsp;each&nbsp;LineStyle&nbsp;
'&nbsp;&nbsp;&nbsp;&nbsp;loaded&nbsp;in&nbsp;Step&nbsp;3.
'----------------------------------------------------------------
Option Explicit</pre>
<pre>   Sub main()</pre>
<pre>        Dim dsApp As DraftSight.Application</pre>
<pre>        'Connect&nbsp;to&nbsp;DraftSight&nbsp;application
        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>        If dsApp Is Nothing Then
            Return
        End If</pre>
<pre>        'Get&nbsp;active&nbsp;document
        Dim dsDoc As DraftSight.Document
        Set dsDoc = dsApp.<b>GetActiveDocument</b>()
        If dsDoc Is Nothing Then
            MsgBox (&quot;There are no open documents in DraftSight.&quot;)
            Return
        End If        </pre>
<pre>        'Get&nbsp;LineStyle&nbsp;manager
        Dim dsLineStyleMgr As DraftSight.LineStyleManager
        Set dsLineStyleMgr = dsDoc.<b>GetLineStyleManager</b>()        </pre>
<pre>        'Load&nbsp;LineStyles
        Dim lineStyleFile As String
        lineStyleFile = &quot;c:\Program Files\Dassault Systemes\DraftSight\Default Files\Linestyles\MM.LIN&quot;       
        Dim dsLineStyle As DraftSight.LineStyle
        dsLineStyleMgr.<b>LoadLineStyle</b> &quot;BATTING&quot;, lineStyleFile, dsLineStyle
        dsLineStyleMgr.<b>LoadLineStyle</b> &quot;ZIGZAG&quot;, lineStyleFile, dsLineStyle        </pre>
<pre>        'Get&nbsp;Sketch&nbsp;manager
        Dim dsSketchMgr As DraftSight.SketchManager
        Set dsSketchMgr = dsDoc.<b>GetModel</b>().<b>GetSketchManager</b>()        </pre>
<pre>        'Activate&nbsp;BATTING&nbsp;LineStyle and insert Line
        Set dsLineStyle = dsLineStyleMgr.<b>GetLineStyle</b>(&quot;BATTING&quot;)
        dsLineStyle.<b>Activate</b>
        dsSketchMgr.<b>InsertLine</b> 0, 0, 0, 100, 100, 0</pre>
<pre>        'Activate&nbsp;ZIGZAG&nbsp;LineStyle and insert Line
        Set dsLineStyle = dsLineStyleMgr.<b>GetLineStyle</b>(&quot;ZIGZAG&quot;)
        dsLineStyle.<b>Activate</b>
        dsSketchMgr.<b>InsertLine</b> 100, 0, 0, 200, 100, 0
        </pre>
<pre>   End Sub</pre>

</body>

</html>