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

<head>
<title>Insert Picture 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,images">
<meta name=MS-HKWD content="VB.NET examples,pictures">
<meta name=MS-HKWD content="VB.NET examples,Referenced images">
</head>


<body>
<h1>Insert Picture Example (VB.NET)</h1>
<p>This example shows how to insert a picture 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. Change the path and file name of the picture file to insert.
'    <b>NOTE</b>: The picture must be a PNG file.
' 5. Start DraftSight and open a drawing.
' 6. Start debugging the project.
'
' Postconditions: A message box pops up when the specified picture 
' is inserted in the drawing document.
'----------------------------------------------------------------
Imports DraftSight.Interop.dsAutomation</pre>
<pre>Module Module1</pre>
<pre>    Sub Main()</pre>
<pre>        Dim dsApp As Application
        Dim dsDoc As Document
        Dim dsModel As Model
        Dim dsSketchManager As SketchManager
        Dim dsPicture As ReferenceImage
        Dim imageFileName As String</pre>
<pre>        'Connect to DraftSight
        dsApp = GetObject(, &quot;DraftSight.Application&quot;)
	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
            'Get model space
            dsModel = dsDoc.<b>GetModel</b>()
            'Get Sketch Manager
            dsSketchManager = dsModel.<b>GetSketchManager</b>()
            'Replace picture's path and file
            'name with yours
            imageFileName = &quot;c:\test\note.png&quot;
            'Insert picture
            dsPicture = dsSketchManager.<b>InsertPicture</b>(imageFileName, 0.0#, 0.0#, 0.0#, 1.0#, 0.0#)
            If dsPicture Is Nothing Then
                MsgBox(imageFileName &amp; &quot; file was not found.&quot;)
            Else
                MsgBox(&quot;A picture was inserted in the drawing.&quot;)
            End If
        Else
            MsgBox(&quot;There are no open documents in DraftSight.&quot;)
        End If
    End Sub</pre>
<pre>End Module</pre>
<p>&nbsp;</p>

</body>

</html>