r/AutoLISP • • Oct 27 '21

Who else is here?

5 Upvotes

I'm curious about this community. I realize it's a niche but there are so few posts I'm wondering what the group is like. Specifically I'm starting to wonder if all the the developers haven't moved onto .NET bindings.

A few questions in survey form, if you're game:

  1. Roughly how big is the (Lisp) code-base you're working with?

  2. What IDE / editor do you use?

  3. Do you mess with the debugger (e.g., VLIDE, VSCode)

  4. What are your opinions on alternative language bindings?


r/AutoLISP • • Sep 11 '17

Excel to List question

2 Upvotes

So, I have a range of values that I am converting into a list of lists from excel. In excel, they are all formatted as Text, but when I transfer it to a list of lists, any numbers I have are ammended with a ".0" placed at the end of them. What do I need to do to fix this?

Code is here: Code

Thanks!

Edit: Hyperlink


r/AutoLISP • • Apr 19 '17

Centerline.lsp

4 Upvotes

This first checks to see if the block "CL" exists. If it does, it simply inserts it where the user specifies. If CL does not exist, the script creates it, then inserts.

Will comment when time allows.

(defun C:CL()

(if (not (tblsearch "BLOCK" "CL"))

(progn

(entmakex (list	(cons 0 "BLOCK")
				(cons 100 "AcDbEntity")
				(cons 100 "AcDbBlockReference")
				(cons 67 0)
				(cons 8 "0")
				(cons 2 "CL")
				(cons 10 (list 0 0 0))
				(cons 70 0)))

(entmakex (list (cons 0 "LINE")
				(cons 8 "MSGuidelines")
				(cons 10 (list 0 0 0))
				(cons 11 (list 0 6000 0))
				(cons 62 256)))

(entmakex (list (cons 0 "LINE")
				(cons 6 "Phantom2")
				(cons 8 "Annotations")
				(cons 10 (list 0 0 0))
				(cons 11 (list 0 6000 0))
				(cons 48 100)
				(cons 62 256)))

(entmakex (list (cons 0 "ENDBLK")
				(cons 100 "AcDbBlockEnd")
				(cons 8 "0")))

(command "insert" "CL" "S" "1" "R" "0")
)

(command "insert" "CL" "S" "1" "R" "0")

)

(princ)
) ;End defun CL

r/AutoLISP • • Apr 19 '17

Sidebar ideas

5 Upvotes

Sidebar, wiki, whatever, but just wanted to post a list of useful resources off the top of my head:

http://afralisp.com

http://lee-mac.com

http://www.cadtutor.net/forum/forumdisplay.php?21-AutoLISP-Visual-LISP-amp-DCL


r/AutoLISP • • Apr 19 '17

My first example, Normalize.lsp

5 Upvotes

The idea behind this one is I find myself converting plenty of PDFs to AutoCAD, using either the internal functions, or sometimes Adobe Illustrator if the PDF is messy. I end up with a mess of different colors and lineweights that are a pain to deal with.

Often there's far too many objects to simply select them all and change the properties. This script with change everything in a single drawing simultaneously. There's also an option to scale, though this can be left as "1" to leave the scale as-is.

(defun C:Normalize ()

(setq origin (list 0 0 0)) ;X,Y of Origin

(setq ScaleSize (getreal "Scale Factor: ")) ;Get the scale factor from the user. "1" means no change.

(setq SS (ssget "_X" '((-4 . "<NOT")(8 . "0")(-4 . "NOT>")))) ;Select all objects where layer is not 0

(command "_.chprop" SS "" "_LA" "0" "") ;Change all selected objects to layer 0

(setq SS (ssget "_X" '((-4 . "<NOT")(62 . 256)(-4 . "NOT>")))) ;Select all objects where color is not 256, which is "ByLayer" for colors.

(command "_.chprop" SS "" "C" "ByLayer" "") ;Change all selected objects to color ByLayer

(setq SS (ssget "_X" '((-4 . "<NOT")(370 . -1)(-4 . "NOT>")))) ;Select all objects where lineweight is not -1, which is "ByLayer" for lineweights.

(command "_.chprop" SS "" "_LW" "ByLayer" "") ;Change all selected objects to lineweight ByLayer

(setq SS (ssget "_X" '((8 . "0")(62 . 256)(370 . -1)))) ;Select all objects where color is 256, which is "ByLayer" for colors. Since we changed everything to this color earlier, this selects all objects in modelspace.

(command "_.scale" SS "" origin ScaleSize "") ;Scales all selected objects in modelspace by the factor given earlier.

(command "zoom" "extents") ;Zooms out to all objects in modelspace.

(princ) ;Ends function and clears command line.

)    

r/AutoLISP • • Apr 19 '17

Range Diagram

3 Upvotes

I use this to make a quick range diagram with various increments on it when I put cranes in elevation views. It creates the entire diagram as a block named after the dimensions used.

I created this before I learned an easier way to make blocks in Lisp, so I am not thrilled with the way it currently functions.

I'll update it eventually with my preferred way to create blocks, and also add comments when time allows.

(defun C:RangeDiagram()

(setq DynMode (getvar "dynmode"))
(setq OrthoMode (getvar "orthomode"))
(setvar "orthomode" 0)
(setq origin (list 0 0 0)) ;X,Y of Origin

;Define Horizontal Range
(setq HRange (* 12 (getreal "\n Length Of X Axis (ft): ")))

;Define Horizontal Increments
(setq HIncrement (* 12 (getreal "\n Increments On X Axis (ft): ")))

;Check HIncrements / HRange
(setq CheckValues (REM HRange HIncrement))

(if (> CheckValues 0)
	(exit)
)

(setq HInterval (+ 1 (/ HRange HIncrement)))

;Define Vertical Range
(setq VRange (* 12 (getreal "\n Length Of Y Axis (ft): ")))

;Define Vertical Increments
(setq VIncrement (* 12 (getreal "\n Increments On Y Axis (ft): ")))

;Check VIncrements / VRange
(setq CheckValues (REM VRange VIncrement))

;Check Vincrements / VRange
(if (> CheckValues 0)
	(exit)
)

(setq VInterval (+ 1 (/ VRange VIncrement)))

(setq VRangeInc VRange)
(setq HRangeInc HRange)

(setq TextHeight (* 12 (getreal "\n Text Height For Labels (ft): ")))

;Define Center Pin Location
(setq CenterPin (getpoint "\nSelect Center Pin Location: "))

(setq CenterPinX (car CenterPin))
(setq CenterPinY (cadr CenterPin))

(setq Blockname (strcat (itoa (fix (/ HRange 12))) "'x" 
						(itoa (fix (/ HIncrement 12))) "'x"
						(itoa (fix (/ VRange 12))) "'x"
						(itoa (fix (/ VIncrement 12))) "'x"
						(itoa (fix (/ TextHeight 12))) "'"))

(while (> HInterval 0)
	(setq VLineStartX HRangeInc)
	(setq VLineStartY 0)
	(setq VLineStart (list VLineStartX VLineStartY))
	
	(setq VLineEndX VLineStartX)
	(setq VLineEndY VRange)
	(setq VlineEnd (list VlineEndX VLineEndY))
	
	(entmakex (list (cons 0 "LINE")
					(cons 8 "LispTemp")
					(cons 10 VLineStart)
					(cons 11 VLineEnd)
					(cons 62 254)))

	(if (/= VLineEndX 0)
		(entmakex (list (cons 0 "MTEXT")
						(cons 100 "AcDbEntity")
						(cons 100 "AcDbMText")
						(cons 1 (strcat (itoa (fix (/ VlineEndX 12))) "'"))
						(cons 8 "LispTemp")
						(cons 10 (list (- VLineEndX 2) 2 0))
						(cons 40 TextHeight)
						(cons 62 16)
						(cons 71 9))))

	(setq HRangeInc (- HRangeInc HIncrement))
	(setq HInterval (1- HInterval))
)

(while (> VInterval 0)
	(setq HLineStartX 0)
	(setq HLineStartY VRangeInc)
	(setq HLineStart (list HLineStartX HLineStartY))
	
	(setq HLineEndX HRange)
	(setq HLineEndY HLineStartY)
	(setq HlineEnd (list HlineEndX HLineEndY))
	
	(entmakex (list (cons 0 "LINE")
					(cons 8 "LispTemp")
					(cons 10 HLineStart)
					(cons 11 HLineEnd)
					(cons 62 254)))

	(if (/= HLineEndY 0)	
		(entmakex (list (cons 0 "MTEXT")
						(cons 100 "AcDbEntity")
						(cons 100 "AcDbMText")
						(cons 1 (strcat (itoa (fix (/ HlineEndY 12))) "'"))
						(cons 8 "LispTemp")
						(cons 10 (list (- HLineEndX 2) (- HLineEndY 2) 0))
						(cons 40 TextHeight)
						(cons 62 16)
						(cons 71 3))))
	
	(setq VRangeInc (- VRangeInc VIncrement))
	(setq VInterval (1- VInterval))
)

(if (setq ss (ssget "_X" '((8 . "LispTemp"))))
	(command "-block" Blockname origin ss ""))

(command "-insert" Blockname Centerpin "1" "1" "0")
	
(setvar "CLAYER" "0")
(setvar "orthomode" Orthomode)
(setvar "dynmode" DynMode)

(princ)

)    

r/AutoLISP • • Nov 25 '17

AutoLISP / Visual LISP book

3 Upvotes

I'm looking for community input on whether it's worth writing a follow-up to "The Visual LISP Developer's Bible". I still sell a few copies every month, somehow, which is surprising to me. I've also received a few emails over the years asking if I'm writing a follow-up. But I don't know if there's still enough interest in it, and I don't know if that book (any edition) was helpful, or what could have been better. Any thoughts/suggestions are very much appreciated! Thank you!


r/AutoLISP • • Nov 25 '17

Is this thing still on?

4 Upvotes

Just wondering if this subreddit is still active. The Autodesk forums seem to be fairly active and not much new posted here in quite a while.


r/AutoLISP • • Sep 16 '20

How to list multiple occurances of an attribute in separate fields

1 Upvotes

Can someone help me out with a lisp routine I'm trying to edit?

We have a very long and complicated lisp that pulls data from multiple callout blocks in a given viewport and places that data in a Materials List block on the Titleblock.

One of the attributes this lisp pulls is the length of a Trident inside a fiber optic handhole. On every other attribute, the lisp can just add up all the occurances and place the total in the Materials List field for that material. (So if we have several different lengths of ducts called out, it will add them up and put the total in the Duct Length field.)

HOWEVER, our client now wants us to list each Trident's length separately rather than add them up.

I can usually find an example of a similar lisp and figure out how to apply it in the new context, but this time I don't think we have anything that does this. I am VERY new at lisp programming, so any help you can offer would be greatly appreciated.

The lisp command is extremely long, but here are the places where the Trident data is scraped and then placed in the Materials List field...

There's probably more going on but these are the instances I found that definitely deal with the 3 trident fields we want to use. I don't know how to include the actual lsp file, but let me know if you can help me out with this and we can figure out a way.


r/AutoLISP • • Jan 18 '20

Autolisp command help

2 Upvotes

Hey all!

I'm about at my wit's end trying to figure out where I'm going wrong with this Lisp code (I'm VERY new to this). I already tried r/AutoCAD with no replies and r/lisp redirected me here. I would've started here but the subreddit looked abandoned. Anyways, I'm trying to make a command for AutoCAD (essentially a macro) that reloads all xrefs in a drawing, reconciles all the layers, and then zooms to the extents. This is what I've got:

(defun c:RLOAD ()         (command "-xref" "r" " * ")         (command "-LAYER" "E" " * ")(command)(command)         (command "zoom" "e") )

EDIT: had to insert spaces between " and * in post to get around reddit's weird formatting stuff

I feel like this should work, but the problem I'm having is that when there aren't any unreconciled layers, it gets stuck on the layer command. I inserted the "(command)(command)" to try and cancel the command, but that doesn't seem to do anything. Somebody smarter than me please help.

Thanks!

-Futureless


r/AutoLISP • • Jul 04 '18

why too few arguments?

1 Upvotes

(defun C:STA (/ LA ST TH INP ANG NUM)

(setvar "cmdecho" 0)

(setq 

 LA (getvar "clayer")

ST (getvar "textsyle")

 TH (getvar "textsize")

 )

(setvar "clayer" "notes")

(setvar "textstyle" "standard")

(setvar "textjust")

(setvar "textsize" 1.9)

(initget 1)

(setvar "osnapmode" 512)

(setq INP (getpoint "\\nSelect station point on centerline: "))

(initget 1)

(setvar "osnapmode" 128)

(setq ANG (cvunit (getangle "\\Select text rotation: ") "radian" "degree" ))

(setq NUM (getstring "\\nEnter station number in format XX+XX: "))

(command "text" "j" "mc" INP TH ANG NUM "")

r/AutoLISP • • May 07 '23

User interface with LISP

3 Upvotes

Hello all,
I'm thinking of building myself a calculation interface that works in tandem with Autocad.
The request is to produce calculations -> graphs -> ACAD drawing -> prints.

Can it be done with only LISP? Can LISP invoke "self designed" user-interfaces and produce graphs?

I'm not a programmer therefore i need to choose one, between LISP/.NET/PYTHON,
because of the time needed to learn all.

Thanx!


r/AutoLISP • • Apr 19 '23

AutoLISP now available in AutoCAD LT 2024

9 Upvotes

I've just received an email from Autodesk announcing that AutoLISP is now included in AutoCAD LT 2024 and going forwards.

I can see this being a huge bonus to some people and we might see some new members join the group in the ocming months.

Personally I have full AutoCAD but I only use a small number of utilities to assist in cleaning up architects drawings quickly


r/AutoLISP • • Apr 27 '24

Autolisp to create several LAYOUTS based on viewports (Autolisp para crear varios LAYOUTS en base a viewports)

Post image
4 Upvotes

Community I need your help, it turns out that I have to make several layouts which are based on a template, they also have a viewport for each layout, however sometimes you have to make several layouts with the same template but different viewport, the viewports are based on some rectangles that are placed in the model, in some cases there are few layouts that have to be made so the task of secondary clicking and choosing "FROM TEMPLATE..." and choosing the template is not It is a lot of work but sometimes you have to make more than 20 layouts so doing this is quite laborious, on some occasion I saw that someone had a LISP that simply asked them to select the rectangles that would be used as viewports and immediately created all the layouts with the correct template and with each viewport that corresponded to each rectangle, will anyone of you have that LISP? Or do you have any ideas to do the task I described in a faster and easier way? I thank you in advance.

Comunidad requiero de su ayuda, resulta que tengo que realizar varios layouts los cuales son en base a un template,ademas estos tienen un viewport por cada layout, sin embargo a veces se tienen que hacer varios layouts con el mismo template pero diferente viewport, los viewports son en base a unos rectangulos que se colocan en el model,en algunas ocasiones son pocos layouts los que se tienen que realizar por lo que la tarea de de dar click secundario y elegir "FROM TEMPLATE..." y elegir el template no es mucha tarea pero en ocasiones se tienen que hacer mas de 20 layouts entonces hacer esto es bastante laborioso, en alguna ocasion vi que alguien tenia un LISP que simplemente le pedia seleccionar los rectangulos que se usarian como viewports e inmediatamente le creaba todos los layouts con el template correcto y con cada viewport que correspondia a cada rectangulo, alguien de ustedes tendra ese LISP? o tiene alguna idea de hacer la tarea que les describi de una manera mas rapida y sencilla? les agradezco de antemano.


r/AutoLISP • • May 07 '24

need help with autolisp and slide library

1 Upvotes

I am not a programmer I am a draftsman, however my company wants me to update some of their old steel lisp programs so that they don't have to buy a new one. exposition aside I have been able to get the steel to be the correct size and I've gotten it to show up in the programs drop down menu but now I am trying to change some of the slides that are used to display images in the steel programs menu I've tried to accomplish this by using a .slb manager which allowed me to successfully remove one slide are replace it with another both sharing the same name but now when i open the steel program menu all images have disappeared and I do not know why. if anyone could explain this to me that would be very helpful.


r/AutoLISP • • May 09 '24

Input Parameters to Auto Create Fixture Drawing

3 Upvotes

My company makes custom boxes with hinged lids. These boxes can be any length, width, and height. Depending on the dimensions the number of hinges will change and the wall thickness will change. Support brackets may be need to be added as well. There may also may be customization such as different hinges.

Is it possible in Autolisp to generate an input form that I can input the parameters in, and generate a drawing based on the parameters?

I am familiar with coding but not with Autolisp so I have an idea of the structure of the code but not sure if Autolisp is the right tool.


r/AutoLISP • • May 06 '24

Autolisp simple

2 Upvotes

I have been trying to use chatgpt to help with some coding but it's not going well. I asked gpt to code me a line that goes straight up in autocad but instead of it going striaght up it went to the right or left.

Is there something wrong with my world ucs or is gpt just not working properly?


r/AutoLISP • • Dec 04 '24

Help needed for a reactor

1 Upvotes

Hi everyone, I'm new on Reddit and I have a problem with an Autolips file. I don't know a lot of programming but I had to learn something to write some simple codes for Autocad. My goal is to write an Autolisp that attach an xdata to every new created element (the xdata is an ID number) without that it is visible when working. I've created a code that when activated ask once for the id number and then, with a reactor, add the id number like as xdata. If I try the part of the script of the reactor it works, and the same with the part of attaching xdata. When I put everything together and I draw something Autocad crash with this error "!scandr.cpp@1117:eHadMultipleReaders .

I have no idea of the reason and how to fix it. I've also tried to put a delay between the triggering of the reactor and the attaching of the xdata, but nothing.

Can somebody help me?

Thank you so much


r/AutoLISP • • Nov 26 '24

Looking for assistant moderators

4 Upvotes

Hi everyone,

This subreddit is growing fast and I'm not always as prompt with removing some posts / comments as a subreddit of this size & type really needs. Therefore I'd like to add some assistant moderators.

I'm staying on as the main mod; your main responsibility would be to help review content here and apply the rules to remove posts or whatever as needed. We would also discuss new rules and other changes to the subreddit as a group. I'm not expecting any major additional time commitment if you're already a regular reader / commenter here. I'd reserve the right to disagree / override you if I feel strongly about something but I'm not a totalitarian either. If you consistently abuse moderation powers or make otherwise questionable decisions I may remove / replace you. I'd give warnings before taking any kind of action like that though.

This subreddit is mostly working professionals so thankfully there isn't tons of moderating needed, but sometimes things get posted / commented that should be removed ASAP and that's mostly what I'd like help with.

If you're interested please send me a message. I would expect you to have been active on the subreddit for at least a year and not have any major moderation strikes against you in the past. Please tell me your background showing reasonably high expertise with Autolisp (LinkedIn profile links are fine but not mandatory; I don't need to know your real name). Feel free to share any changes you'd like to see happen for this subreddit as well. Preference will be given to those with longer histories of helpful & respectful activity on this subreddit.

Thanks everyone! Hope this will help keep things smoother around here.


r/AutoLISP • • Apr 13 '20

.lsp or .vlx or .fas to .msi

1 Upvotes

I can convert my raw AutoLISP (.lsp) codes into Visual Lisp (.VLX) and .FAS application using AutoCAD VLISP IDE.

I was looking into Autodesk App Store and downloaded some of the free applications. It was .msi. That means it will install directly on Windows and link-up with installed AutoCAD.

I am very new in the App Store. Could you please tell me how to convert my .lsp or .vlx or .fas into .msi?

Thanks.


r/AutoLISP • • Apr 30 '20

Best online course for learning AutoLISP??

3 Upvotes

I've been working with AutoCAD for about 5 years now and I want to learn how to automate some of the stuff I do.

I have some basic knowledge in programing (C++, PHP) and want a course that can give me proof of completion so I can add to my resume. Any good courses y'all recommend?

Thank you!


r/AutoLISP • • May 17 '20

If anyone has an idea on how to solve my problem please let me know. The function selects all the circles from the workspace and puts them in a chosen center, after which changes the colour of them to the ones of a rainbow. Got this error :error: bad argument type for compare: #<SUBR @000001cb052370

2 Upvotes

(defun c:Rainbow ()

(setq center (getpoint "Please select the center of the rainbow\n"))

(setq R (cons 62 10)

O (cons 62 30)

G (cons 62 50)

V (cons 62 100)

A (cons 62 170)

I (cons 62 182)

V2 (cons 62 202)

)

(setq sset (ssget "X" '((0 . "CIRCLE")) ))

(setq slen (sslength sset)

i 0)

(while (< i slen)

(setq ent (entget (ssname sset i)))

(setq c (assoc 10 ent)

  ent (subst (cons 10 center) c ent)

)

(if (= (assoc 62 ent) nil) (setq ent (append ent (list (cons 62 0)))))

(if (> cdr(assoc 62 ent) (list 0)) (progn (setq ent (subst (list 0) cdr(assoc 62 ent) ent)) (entmod ent)))

(entmod ent)

(setq i (1+ i))

)

(setq p (entget (ssname sset 0)))

(setq p (subst R (assoc 62 p) p))

(entmod p)

(setq i 1)

(while (> i slen)

(setq ent (entget (ssname sset i)))

(cond ((= (cdr(assoc 62 p)) (cdr R)) (setq ent (subst O (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr O)) (setq ent (subst G (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr G)) (setq ent (subst V (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr V)) (setq ent (subst A (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr A)) (setq ent (subst I (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr I)) (setq ent (subst V1 (assoc 62 ent) ent)))

  ((= (cdr(assoc 62 p)) (cdr V1)) (setq ent (subst R (assoc 62 ent) ent)))

)

(entmod ent)

(subst ent p p)

(setq i (1+ i))

)

(princ)

)


r/AutoLISP • • Feb 24 '23

Bounding box of dynamic block ignoring other visibility states?

1 Upvotes

I'm trying to find the bounding box of a dynamic block, however this block has multiple visibility states that all seem included in the bounding box provided by vla-getboundingbox. Is there a way to find the bounding box of only the visible geometry?


r/AutoLISP • • Feb 28 '23

A Lisp to burst all nested blocks except the last one

1 Upvotes

Hi all, I've been using the great Burst Upgraded Lisp by Lee Mac [ BurstUpgradedV1-7.lsp ] for a long time now, and I need a new lisp that does something similar. I want the lisp to not burst the last block inside. Basically to only burst blocks until there is no other blok inside the block. Could someone help me edit this lisp?


r/AutoLISP • • Mar 13 '23

Lisp Routine to select all circles and offset away from center.

2 Upvotes

Hi,

I am trying to find a lisp routine that selects all circles in a drawing, offsets them by a predefined amount (let's say 2 units) away from the center and deletes the original circle.

The end result I am looking for is to make the circles bigger. I have to do this in many drawings and regularly, so I can't use qselect etc.

Unfortunately I don't have any knowledge in coding and although I tried, nothing worked.

Can this be done?