AutoLISP Extended (ALx) Functions

AutoLISP Extended (ALx) Functions

CodeDing
Advisor Advisor
4,548 Views
23 Replies
Message 1 of 24

AutoLISP Extended (ALx) Functions

CodeDing
Advisor
Advisor

Hello All,

 

If you've stumbled across this post, it's probably because you utilize the AutoLISP language to some extent, either beginner or expert. And I don't know about you but I thoroughly enjoy AutoLISP and the capabilities it brings to the AutoCAD program.

 

Ever since I picked up this functional language, I've never wanted to go back, but at some points I reach a wall. These walls are just hurdles and obstacles that the vanilla AutoLISP language cannot overcome, and sometimes Visual Lisp can't either.

 

I'll save you some back-story but once I discovered that we can create AutoLISP functions via the .NET API, this opened a whole new world of ideas about what can be accomplished via AutoLISP. So, that's when I decided to do something about it.

 

ALx Functions are my answer to doing my part for expanding AutoLISP. Let me be clear that these functions are NOT intended to replace Visual Lisp. But there is a gap that can be filled with these functions, and I want others to hear and know about them to promote the expansion and implementation of the .NET API for creating AutoLISP functions.

 

Let's get to the details:

 

Attached you will find a zip folder with only a single .dll file ("ALX.dll") inside. Feel free to open and review at your leisure (don't judge my C# code too harshly, I'm still learning). Also, be sure that the .dll is Unlocked by Right-clicking the .dll > Properties > General tab > Check the Unblock box.

 

I will post an image below of the current ALx Functions available. There are only a handful at the moment, but I want to grow this collection as much as possible to get the benefits of .NET abilities to my AutoLISP users.

 

You can load the file via the NETLOAD command. Once loaded, you can use the following function to open the help file which lists all of the available functions:

(alx-help)

 

If anybody would like to contribute, please don't hesitate to reach out to me and I will gladly answer questions to the best of my abilities and consider newly recommended functions. I am working on getting a website up and running to store all of this information and track revisions / downloads / functions. But until then, I will post any updates here.

 

Hope this helps.

 

Best,

Denon Deterding

denon@alxfunctions.com

 

image.png

4,549 Views
23 Replies
Replies (23)
Message 2 of 24

JBerns
Advisor
Advisor

Thank you for sharing, @CodeDing.

I look forward to reviewing the functions.

With which version of AutoCAD is this compatible?

 

Regards,

Jerry 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 3 of 24

CodeDing
Advisor
Advisor

@JBerns ,

 

I'm not 100% on how to test reverse compatibility. I'm open to learning if somebody is willing to teach.

 

But it seems reasonable to assume that it would currently work with R14 - Current. On windows. On all AutoCAD verticals.

 

Best,

~DD

0 Likes
Message 4 of 24

JBerns
Advisor
Advisor

@CodeDing,

 

I first tested the command, (alx-help), in AutoCAD 2019, but nothing appeared.

I tried with AutoCAD 2021, but same result.

Thus my compatibility inquiry.

The only file in the ZIP file was the DLL. Is that correct?

 

Here are my testing steps:

  1. Download zip
  2. Extract single DLL file inside
  3. File Properties to Unblock
  4. AutoCAD NETLOAD to load DLL
  5. At Command prompt, type (alx-help)

The Command prompt returned with nothing appearing that I coud see.

 

Once unblocked and NETLOADed, does it have to be in an AutoCAD Support path?

 

Please advise.

 

 

Regards,

Jerry

 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 5 of 24

JBerns
Advisor
Advisor

@CodeDing,

Disregard please.

Once I placed the DLL in a support path, the Help command worked. 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 6 of 24

doaiena
Collaborator
Collaborator

Be sure to take great care when working with database objects. .NET has the ability to crash AutoCAD if the objects aren't handled properly. Some crashes can occur quite some time after a function has been used, which makes tracing the source of the crash very hard.

 

I use the .NET api from time to time for the same reason - AutoLisp doesn't provide what i am looking for. I myself am still a novice in every meaning of the word, but i would like to point your attention to:

- Transactions - when and how to use them

- Disposing of objects

- Geometry and DatabaseServices classes - how to make geometric calculations and create database entities from geometry

 

Excuse me if you already know all of this. I wrote it because you said you were still learning and i wanted to point you to some of the challenges i myself met.

 

 

As for the "ALx" functions, my suggestion would be to keep user interaction out of these functions as much as possible. Keep them as a black box (data comes in -> data comes out). Lisp should be responsible for gathering the user data where possible.

Message 7 of 24

CodeDing
Advisor
Advisor

@doaiena ,

 

I am definitely a novice in the .NET atmosphere. I have always wanted to learn more and get deeper into it but never been able to make the jump. What better way than using it to further improve the language I keep resorting back to.

 

Thank you for the helpful insight with your comment. It will be on my mind progressing forward. 

 

Best,

~DD

0 Likes
Message 8 of 24

Sea-Haven
Mentor
Mentor

I can see a use for some of the deep functions a couple that have been requested recently.

 

Mtext columns get and put properties not easily exposed.

 

Dynamic array get & put columns and rows, again these are exposed 3 entgets deep. 

 

 

 

 

0 Likes
Message 9 of 24

doaiena
Collaborator
Collaborator

I'm sorry for the double post, i can no longer edit my first one.

 

PS:

Don't waste your time on simple functions. While very powerfull, .NET functions have a huge overhead. Moving data back and forth between Lisp and NET is slow.

Example:

(reverse (cdr (reverse someList))) would be >10x faster than a "RemoveLast" function written in .NET.

I mainly use .NET for selection sets. Once the initial communication overhead between Lisp and NET has passed, .NET functions are lightning fast. The summary of my post is - Use .NET only where it makes sense.

Message 10 of 24

CodeDing
Advisor
Advisor

@Sea-Haven ,

 

The 2 examples you mention can easily be set / get with the (getpropertyvalue ...) & (setpropertyvalue ...) functions.

 

While I understand that those 2 functions are exclusive to AutoCAD, as are currently ALx Functions.

 

MText Columns:

(setpropertyvalue (car (entsel "\nSelect MText: ")) "ColumnType" 0)

 

Array Rows / Columns:

(getpropertyvalue (car (entsel "\nSelect Array: ")) "RowsWithExpression");Rows
(getpropertyvalue (car (entsel "\nSelect Array: ")) "Items");Columns

 

Best,

~DD

0 Likes
Message 11 of 24

Sea-Haven
Mentor
Mentor

Thanks a simple answer sometimes, spent some time trying to go down the normal path entget & vla-get. I maybe need to use getpropertyvalue more.

0 Likes
Message 12 of 24

CodeDing
Advisor
Advisor

Hey All,

 

Got a new ALx Functions update. Still no website up yet, working on it.

This round was heavily focused on Excel interaction. In addition, a new parsing function and a couple block functions were added also.

 

New Functions:
- alxa-block-list
- alxa-block-list-byname
- alx-excel-range-get
- alx-excel-range-set
- alx-excel-wb-close
- alx-excel-wb-get
- alx-excel-wb-name
- alx-excel-wb-save
- alx-excel-wb-set
- alx-excel-ws-add
- alx-excel-ws-get
- alx-excel-ws-list
- alx-excel-ws-remove
- alx-excel-ws-set
- alx-parse-xml2lisp

 

image.png

 

Best,
~DD

Message 13 of 24

john.uhden
Mentor
Mentor

Can .NET create an alx-getboundingpoly function?

It doesn't have to have bulges.  Just enough chords to represent a complex outline better than the stupid rectangular boundingbox.  A point list, either 2D flat or grouped, is sufficient.

It would be better if AutoCAD provided the capability, especially for background fills.  I could but don't want to create a wipeout under the mtext and associate them with a reactor to update the wipeout.  Mainly because the associativity would be lost if one didn't have the reactor functions installed.

Now maybe I should care only that my own office has the reactors, but sharing drawings with other consultants would drive them nuts if they move the mtext and the wipeout is hiding other things and frames are turned off so they don't see them.

John F. Uhden

0 Likes
Message 14 of 24

Sea-Haven
Mentor
Mentor

Hi John the CIV3D lineworkshrinkwrap is part of the way their, like Lee-mac's convex hull. There is a commercial product out there that does has some pretty big claims going by their web page, there is a cost for the product but it sounds like what your after, will try to find again. Understand doing boundary of civil type stuff is often a pain and have to resort to keyhole type plines to get correct answer.

0 Likes
Message 15 of 24

Sea-Haven
Mentor
Mentor

I am interested in the xecel stuff used getexcel in past but found the open could be not what shoudl happen so started on making my own. 

 

Anyway

Command: NETLOAD
Cannot load assembly. Error details: System.IO.FileLoadException: Could not load file or assembly 'file:///D:\Alan\LISP\ALX.dll' blah blah 4 lines long.

 

Bricscad version ? They have a SDK as well.

0 Likes
Message 16 of 24

CodeDing
Advisor
Advisor

@Sea-Haven ,

 

Hey so pertaining to the issue you described, you need to unlock the file. Please see my text in bold in my original post at the top of this thread. That should explain how to unlock the dll for use.

 

Best,

~DD

0 Likes
Message 17 of 24

CodeDing
Advisor
Advisor

@john.uhden ,

 

I agree with sea.haven's approach to try to use LINEWORKSHRINKWRAP. Lee Mac also has an OUTLINE command.

 

A getboundingpoly function would essentially have to turn into something similar to the OUTLINE command because you wouldn't be able to skip recessed areas of entities.. Because everybody would have a different definition of what areas get skipped or captured. I mean, I guess something could be done, but it would definitely be a hefty amount of work.

 

Best,

~DD

0 Likes
Message 18 of 24

Sea-Haven
Mentor
Mentor

Working now was looking at wrong part of Properties.

 

In getexel is a function row,column say 5 6 = E6 as range would be a handy one to add. 5 6 & 20 23 = E6:T23 maybe 5,6 or 5,6,20,23 as lisp is more numbers not alpha's

 

In another post was add sheets, have not tested does it add at start or finish ? As not visible not sure, looks like after which is good, maybe a sort order another option.

 

Is Visible or Not, whilst it opened the excel did not know if it was actually open need a message at least. One of the reasons to do my own was the situation "excel is open and the workbook exists but may not be current". Need this for a client. They have to check against excel rules it has extensive look up tables and formulas. Not sure "Sets a worksheet with the provided name in the current workbook as the active worksheet, or creates the worksheet if it does not already exist. " Is this situation handled  when you have multiple workbooks open ?

 

I am still very interested, just how to handle various scenarios. 

 

Great "HELP" that is a lot of work.

 

Looks very good trying some of the commands, well done.

 

screenshot356.png

0 Likes
Message 19 of 24

CodeDing
Advisor
Advisor

@Sea-Haven wrote:

In getexel is a function row,column say 5 6 = E6 as range would be a handy one to add. 5 6 & 20 23 = E6:T23 maybe 5,6 or 5,6,20,23 as lisp is more numbers not alpha's


Yeah, that makes sense. Definitely something to consider. I figured people would be more familiar with the text approach. It also allows for named ranges which I like. Maybe I can eventually give the user an option of one or another.

 


@Sea-Haven wrote:

In another post was add sheets, have not tested does it add at start or finish ? As not visible not sure, looks like after which is good, maybe a sort order another option.


Yes, new sheets are added at the end. A sort option of some sort might be nice.

 


@Sea-Haven wrote:

Is Visible or Not, whilst it opened the excel did not know if it was actually open need a message at least. 


So, the "confirmation" is actually whether the (alx-excel-wb-set ...) function returns a string or not. If the string is returned then the workbook was successfully opened. Otherwise nil will be returned. It allows you to essentially just use it in an if statement like you already do with most functions in lisp (if (alx-excel-wb-set ...) ...)

 


@Sea-Haven wrote:

One of the reasons to do my own was the situation "excel is open and the workbook exists but may not be current". Need this for a client. They have to check against excel rules it has extensive look up tables and formulas. Not sure "Sets a worksheet with the provided name in the current workbook as the active worksheet, or creates the worksheet if it does not already exist. " Is this situation handled  when you have multiple workbooks open ?


These functions create their own (non-visible) instance of Excel. So, any currently-open Excel app is sort-of irrelevant. And since only one workbook can be active within the newly instantiated Excel App, then "multiple workbooks" is not a factor. One thing that I have not FULLY tested is whether the workbook being 'opened' is currently open in another application. So I do need some more testing there.

 


@Sea-Haven wrote:

I am still very interested, just how to handle various scenarios. 


Just reach out whenever you have questions. I provided an email in the help file.

 


@Sea-Haven wrote:

Great "HELP" that is a lot of work.


Thank you, yes it is. It's been a pain in my butt recently, but I'm glad it's working on your end and helping. I was nervous that it might not deploy correctly or something.

 


@Sea-Haven wrote:

Looks very good trying some of the commands, well done.


Thank you.

 

Best,

~DD

0 Likes
Message 20 of 24

john.uhden
Mentor
Mentor
Ooh. lineworkshrinkwrap sounds delicious. I will check it out.

John F. Uhden

0 Likes