See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: New LISP Expressions created with .NET (VB or C#)

  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 New LISP Expressions created with .NET (VB or C#)

    Hey group,

    I posted some .NET code for creating
    two new lisp expressions that display
    splash screens yesterday.

    Would you all like to learn .NET as it relates to LISP?

    We can build and share .NET applications that extend the power of LISP.

    If you all are interested, I would be interested in your suggestions for new LISP expressions.

    Suggestions? Ideas? Brainstorms?


    P=
    AutomateCAD

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Expanding of LISP is what first motivated me to teach myself .NET development.

    Now, I've only dabbled with .NET development (I feel), but am anxious to become more adept... I think this thread is a great idea, Peter.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

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

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Here is place to start.

    Currently a lisp programmer must use the command pipe to load a dotnet assembly

    (command "netload" <myassemblyfullname>)

    The code below creates a lisp expression for netloading (including in reactors)

    (netload <myassemblyfullname>)

    Compiled for AutoCAD 2010-12.

    NetloadAssembly.dll can be loaded if it is in the search path or a full path is supplied

    (command "netload" (findfile "netloadassembly.dll"))

    The netload.zip is the project.

    P=



    Code:
    ' (C) Copyright 2002-2005 by Autodesk, Inc. 
    '
    ' 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.
    '
    ' AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
    ' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
    ' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
    ' 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
    Imports System.Reflection
    Imports System.Reflection.Assembly
    Imports System.Security.Permissions
    Imports System.Threading
    
    '<Assembly: AssemblyVersion("6.12.2010.0")> 
    
    ' Lisp function for loading a .net dll
    
    Public Class vbvlClass
    
        <LispFunction("Netload")> _
        Public Function Netload(ByVal rbfNetAssemblyFile As ResultBuffer)
            Dim tpvReturn As TypedValue = New TypedValue(LispDataType.Nil, -1)
            Try
                Dim arrNetAssemblyFile As TypedValue() = rbfNetAssemblyFile.AsArray()
                If arrNetAssemblyFile.Length > 0 Then
                    Dim strFileName As String = arrNetAssemblyFile(0).Value.ToString
                    If Netload(strFileName) = Boolean.TrueString Then
                        Return New TypedValue(LispDataType.T_atom, -1)
                        tpvReturn = New TypedValue(LispDataType.T_atom, -1)
                    End If
                Else
                    Princ("; error: too few arguments")
                End If
            Catch Ex As System.Exception
                Princ("; error Loading Assembly: " & Ex.Message)
            End Try
            Return tpvReturn
        End Function
    
        ' Function to load a net assembly if a .net assembly is loaded
    
        Public Function Netload(ByVal strFileName As String) As Boolean
            Dim docThisDrawing As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim blnReturn As Boolean = Boolean.FalseString
            Try
                Dim strFullName As String = _
                         HostApplicationServices.Current.FindFile(strFileName, docThisDrawing.Database, FindFileHint.Default)
                Princ(strFullName)
                If IsNetAssemblyLoaded(strFileName) = Boolean.TrueString Then
                    Princ("; file is already loaded")
                Else
                    System.Reflection.Assembly.LoadFrom(strFullName)
                    blnReturn = Boolean.TrueString
                End If
            Catch Ex As System.Exception
                Princ("Error Loading Assembly: " + Ex.Message)
            End Try
            Return blnReturn
        End Function
    
        ' Function ResultBuffer In TypedValue Out to test if a .net assembly is loaded
    
        <LispFunction("IsNetAssemblyLoaded")> _
        Public Function IsNetAssemblyLoaded(ByVal rbfNetAssemblyFile As ResultBuffer)
            Dim tpvReturn As TypedValue = New TypedValue(LispDataType.Nil, -1)
            Dim objAssemblies() As Assembly = AppDomain.CurrentDomain.GetAssemblies
            ' Const strDelimiter As String = "Version="
            Try
                Dim arrNetAssemblyFile As TypedValue() = rbfNetAssemblyFile.AsArray()
                If arrNetAssemblyFile.Length > 0 Then
                    Dim strFileName As String = arrNetAssemblyFile(0).Value.ToString
                    If IsNetAssemblyLoaded(strFileName) = Boolean.TrueString Then
                        tpvReturn = New TypedValue(LispDataType.T_atom, -1)
                    End If
                End If
            Catch Ex As System.Exception
                Princ("Error Testing Assembly: ")
            End Try
            Return tpvReturn
        End Function
    
        ' Overload Function String In Boolean Out to test if a .net assembly is loaded
    
        Public Function IsNetAssemblyLoaded(ByVal strFileName As String) As Boolean
            'MsgBox("IsNetAssemblyLoaded")
            Dim objAssemblies() As Assembly = AppDomain.CurrentDomain.GetAssemblies
            For Each objAssembly As Assembly In objAssemblies
                If UCase(objAssembly.ManifestModule.Name.ToString) = UCase(strFileName) Then
                    Princ(objAssembly.FullName.ToString)
                    Return Boolean.TrueString
                End If
            Next
            Return Boolean.FalseString
        End Function
    
        ' Simple print to command window function
    
        Public Function Princ(ByVal strPrintString) As Boolean
            Dim docThisDrawingP As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            docThisDrawingP.Editor.WriteMessage("" & strPrintString & vbLf & "")
            Return Nothing
        End Function
    
    End Class
    Attached Files Attached Files
    AutomateCAD

  4. #4
    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 Re: New LISP Expressions created with .NET (VB or C#)

    Quote Originally Posted by RenderMan View Post
    Expanding of LISP is what first motivated me to teach myself .NET development.

    Now, I've only dabbled with .NET development (I feel), but am anxious to become more adept... I think this thread is a great idea, Peter.

    Can you post a vs2010 express autocad template for .net?

    Link to vs2010 express or later download?

    Just in case others want to start playing with this.
    AutomateCAD

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Integrated Development Environment (IDE):

    Visual Studio 2010 Express (Free, I have C++, C#, VB), or Visual Studio Professional (Paid)



    Software Development Kit (SDK):

    ObjectARX SDK for AutoCAD 2011, 2012, and 2013




    AutoCAD .NET Wizards:

    AutoCAD 2010-2012 .NET Wizard, and AutoCAD 2013 .NET Wizard, by ADN (Kean Walmsley), or AutoCAD .NET Add-in Wizard (AcadNetAddinWizard), by spiderinnet1




    Article:

    Why you should hold onto Visual Studio 2010 Express

    Here's an update regarding the article I mentioned above:

    Microsoft adds Windows 8 Desktop support to Visual Studio 2012 Express


    ... That should get you started.


    Also useful:

    AutoCAD .NET Developer Guide

    .NET Getting Started

    Autodesk My First Plug-in Training, supports AutoCAD, Inventor, and Revit (no Civil 3D)
    Last edited by RenderMan; 2012-11-02 at 02:21 PM. Reason: Added link for AutoCAD 2013 .NET Wizard
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  6. #6
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Thanks, I would also be looking at this a lot. I've started something previously, but my aim was to extent lisp through ARX instead: http://alisp-ext.wikidot.com/
    Although the more the better right?

    BTW, Anyone have similar issues with that Wizzard not wanting to install properly? Neither the DotNet Wizzard, nor the ARX Wizzard wants to install (on VS2008/10). I'm on Win7-64 bit ... perhaps due to 64? I've even tried on another PC with only VS Express 2008, and then VS-E 2010, still doesn't want to install. Anyhow, it's no biggy, I simply made a template of my own - which does most of what the wizzard would have done anyway.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Quote Originally Posted by irneb View Post
    BTW, Anyone have similar issues with that Wizzard not wanting to install properly? Neither the DotNet Wizzard, nor the ARX Wizzard wants to install (on VS2008/10). I'm on Win7-64 bit ... perhaps due to 64? I've even tried on another PC with only VS Express 2008, and then VS-E 2010, still doesn't want to install. Anyhow, it's no biggy, I simply made a template of my own - which does most of what the wizzard would have done anyway.
    Welcome, my zef slang bro

    My IT did experience an issue with the install of VSE2010 originally, until I told them to check out the instructional video included in the ZIP download. That seemed to have fixed the issue. All has been well for +/-1 year.

    I could use more templates myself, at minimum for Civil 3D & AutoCAD MEP.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  8. #8
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: New LISP Expressions created with .NET (VB or C#)

    Thanks yes, I've gone through all the tutorials. Even any others I could find using google. Unfortunately it simply will not install properly. It either gives me an error message about not being able to install some files or simply closes without any message. I've tried all sorts of tricks (re admin rights, etc. even safe mode). But still there's nothing about AutoDesk's DotNet / ARX available in VS's Create Project dialog (not in any of the categories at all).

    But as I've stated, it's not truly a big deal. A template does all those things for you. You just need to setup the template to your own desire and mapping/using to the correct assemblies. You can even get a template to do more than the wizzard does - because you can edit each file of it manually. So for me I've given up trying the wizzard and just use my template instead.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Diesel Expressions vs Field expressions in Trueview 2014
    By jayvee in forum DWG TrueView - General
    Replies: 1
    Last Post: 2018-07-13, 11:09 AM
  2. Select the last N entities created in a lisp routine.
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 7
    Last Post: 2015-06-23, 04:36 PM
  3. Replies: 17
    Last Post: 2014-02-17, 07:18 PM
  4. LISP CHALLENGE - symbols created within routine
    By bowlingbrad in forum AutoLISP
    Replies: 3
    Last Post: 2008-12-23, 07:40 PM
  5. Zero length line created when lisp is run
    By tommy.malone in forum AutoLISP
    Replies: 8
    Last Post: 2005-06-01, 05:49 AM

Posting Permissions

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