Results 1 to 6 of 6

Thread: Netload Example

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Chelan WA
    Posts
    1,043
    Login to Give a bone
    0

    Default Netload Example

    This was compiled with AutoCAD2010 and would need to be re-compiled for 2013 and 2014 (or 2009 and before)

    It also makes a good template.


    Code:
    '
    ' Permission to use, copy, modify, and distribute this software in
    ' object code form for any purpose and without fee is hereby granted, 
    ' provided that the above copyright notice appears in all copies and 
    ' that both that copyright notice and the limited warranty and
    ' restricted rights notice below appear in all supporting 
    ' documentation.
    '
    ' WE PROVIDE THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
    ' WE SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
    ' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. 
    ' DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
    ' UNINTERRUPTED OR ERROR FREE.
    '
    ' Use, duplication, or disclosure by the U.S. Government is subject to 
    ' restrictions set forth in FAR 52.227-19 (Commercial Computer
    ' Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
    ' (Rights in Technical Data and Computer Software), as applicable.
    '
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.Runtime
    'Imports objACADApplication = Autodesk.AutoCAD.ApplicationServices.Application
    
    Imports System.Reflection
    
    
    Public Class NetloadClass
    
    
        ''' <summary>
        '''  Lisp function for loading a .net dll
        ''' LISP Syntax: (netload "mynetassembly.dll")
        ''' </summary>
    
        <LispFunction("Netload")> _
        Public Function Netload(ByVal rbfNetAssemblyFile As ResultBuffer)
            Try
                Dim arrNetAssemblyFile As TypedValue() = rbfNetAssemblyFile.AsArray()
                If arrNetAssemblyFile.Length > 0 Then
                    Dim strFileName As String = arrNetAssemblyFile(0).Value.ToString
                    If Netload(strFileName) Then
                        Return New TypedValue(LispDataType.T_atom, -1)
                    End If
                End If
            Catch Ex As System.Exception
                WriteMessage("; error Loading Assembly: " & Ex.Message & vbLf)
            End Try
            Return New TypedValue(LispDataType.Nil, -1)
        End Function
    
    
        ''' <summary>
        '''  Function to load a net assembly (over load of lisp version for .net)
        ''' </summary>
    
        Public Function Netload(ByVal strFileName As String) As Boolean
            Dim docThisDrawing As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Try
                Dim strFullName As String = _
                         HostApplicationServices.Current.FindFile(strFileName, docThisDrawing.Database, FindFileHint.Default)
                WriteMessage(strFullName & vbLf)
                System.Reflection.Assembly.LoadFrom(strFullName)
                Return True
            Catch Ex As System.Exception
                WriteMessage("Error Loading Assembly: " & Ex.Message & vbLf)
            End Try
            Return False
        End Function
    
    
        ''' <summary>
        ''' Simple print to command window function
        ''' </summary>
    
        Public Function WriteMessage(ByVal strPrintString) As Boolean
            On Error GoTo OnError
            Dim docThisDrawingP As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            docThisDrawingP.Editor.WriteMessage("" & strPrintString & vbLf & "")
            Return True
    OnError: Return False
        End Function
    
    End Class
    Attached Files Attached Files
    Last edited by peter; 2014-01-04 at 08:45 AM.
    AutomateCAD

Similar Threads

  1. Error on Netload (DLL on network)
    By Dubweisertm in forum Dot Net API
    Replies: 2
    Last Post: 2011-09-22, 09:49 PM
  2. NETLOAD in AutoCAD 2012
    By LogoKevn in forum AutoCAD General
    Replies: 1
    Last Post: 2011-08-15, 06:54 PM
  3. Netload command not recognized
    By michael.hooker in forum Dot Net API
    Replies: 0
    Last Post: 2008-12-04, 09:29 PM
  4. VB.Net Netload DLL and Windows forms (EXE)
    By KevinBarnett in forum Dot Net API
    Replies: 2
    Last Post: 2005-12-15, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •