Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Share Your Favorite usefull LISP files

28 REPLIES 28
Reply
Message 1 of 29
ganeshmag
21225 Views, 28 Replies

Share Your Favorite usefull LISP files

Share Your Favorite Lisp files and Customization to helpful others.

 

thanks,

28 REPLIES 28
Message 2 of 29
roland.r71
in reply to: ganeshmag

I understand your intentions, i think, but for lisp it's not as easy as with dynamic blocks.

Most of my (own) favorite lisps are "drawing/situation dependant" and not "general purpose".

 

Mostly because it takes at least 3x as much code & time to write to make it general purpose without adding anything for my personal (or companies) needs.

 

Usually it takes a few years of switching clients before anything i write has become general purpose (as i adjust what i have to the new situation/client, retaining the old situation, a point comes where it fits/handles all situations).

 

Anyway, as for my (& prety much any LISP programmer) favorite LISP files in general:

I'd say, anything Lee Mac ever wrote (& shared) Smiley Wink

Message 3 of 29
john.uhden
in reply to: ganeshmag

Many of us do that all the time, right here.  We even try not to delay the people at the drive-thru window.

I think @Kent1Cooper gives away more than anyone.

John F. Uhden

Message 4 of 29
Kent1Cooper
in reply to: ganeshmag

I agree with @roland.r71 that what will be most useful to anyone will be dependent on their circumstances.  And they're more likely to find what they need by Searching for terms related to the need, rather than in some kind of generic collection such as here.  But in case someone might find something they can use in this thread, here are some of mine that I personally use most often [thanks for the plug, @john.uhden!]:

 

MakeMore.lsp with its MM command is similar to AutoCAD's ADDSELECTED command, but it "knows more" about what you select in many situations [for example, if you pick on a Polyline that's rectangular, ADDSELECTED only sees that it's a Polyline, and starts a basic PLINE command, but MM recognizes it as a rectangle, and offers the RECTANG command as a default, while also offering options  for the various other commands that make Polylines].  And if any of the properties of what you pick are overrides, not ByLayer or other defaults [such as a linetype scale other than 1], it makes those properties current but warns you to reset them, and has a MMR command [= MakeMore Reset] to reset them for you.  [It doesn't reset them automatically, in case you want to draw more than one  of whatever new thing you're drawing.]

 

PolylineContinue.lsp with its PLC command lets you carry on from the nearer end of any Polyline/Line/Arc that you select, as though you were at that point in the middle of a PLINE command, and if what you picked was a Line or Arc, it converts it to a Polyline joined to the continuation that you draw, and if you go into arc mode, it knows the tangent-continuation direction off the end of what you selected, and if you Close, it closes back to the other end of what you selected, not to the point where you picked up.

 

DivideMeasurePlus.lsp with its DIV+ amd MEA+ commands has "super-charged" versions enhancing what ordinary DIVIDE and MEASURE can do.  They have options for User selection of objects or Line markers [not just Points or Blocks], and/or to put whatever it is at both ends of the path object in DIV+ or at the start in MEA+, various options about spacing [such as to put things at the mid-points of the divisions rather than at the division points, inset the ends in DIV+, and more], more choices about rotation, a Maximum-spacing option in DIV+ [it will figure out how many are needed], etc. [see the top of the file].

 

... and I can attach only 3 -- more later, perhaps....

Kent Cooper, AIA
Message 5 of 29
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... more later, perhaps....


Some more:

 

ConstLines.lsp with its RX command [= Rays/Xlines] puts you in a non-plotting layout Layer, and within one running of it, you can switch back and forth between Rays and Xlines, and among various typical pre-set directions and free direction, and place as many such things as you want, and when you're done it returns you to the Layer you were in before.

 

ReportSlope.lsp with its RS command tells you the absolute slope relative to horizontal of virtually any straight thing you pick on [including nested things], regardless of its drawn direction, reporting in multiple formats [degrees, radians, percentage, X-in-12, 1-in-X], so you can find out, for example:  is this slope in a site section shallow enough to be "sidewalk"-type, or is it steep enough that is has to be considered a "ramp" with handrails?  what's the pitch of the roof in this wall section or building elevation?  is this [whatever] truly orthogonal or is it off a little?  etc.

 

DimExtLineToggle.lsp with its DET command toggles the on/off [suppression] state of the extension line of a Dimension that's closer to where you pick on the Dimension.  [I use it, for example, to turn off extension lines that write over the gaps in grid centerlines.]  You can pick on the extension line itself if it's on, or on the dimension line or arrowhead nearer that end, or even on the text part.  You don't need to know whether the one in question is #1 or #2, as you would to make the same change in the Properties palette.

Kent Cooper, AIA
Message 6 of 29
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... more later, perhaps....


And a few more:

Bisector.lsp with its BI command draws an Xline between virtually any two straight things you select [including nested ones], bisecting either the angle  between them if they're not  parallel, or the spacing  between them if they are  parallel.

 

FilletZero.lsp with its FZ command goes into Filleting at zero radius and in multiple mode [as many as you want], for "cleaning up corners," and afterwards restores whatever the current Fillet radius was when you started.

 

InsulBattPoly.lsp with its IB command draws S-curve-squiggle batt insulation as a Polyline.  You can either put it along a "path" object already drawn, or establish the path from inside the command, and you can either retain or delete the path.  The path can be anything with linearity [Line, Arc, Circle, Polyline of any type, Ellipse, Spline], and if it's not straight, the widths of the S-curves are adjusted to meet without overlaps or gaps such as you get with AutoCAD's Batting linetype [and the curvature is much nicer than with that].  The result can be Left-, Right- or Center-justified along the path.  It has some common US-Imperial insulation thicknesses built in as options, or you can specify whatever thickness you want.  It fits the curves to the overall length exactly, so there's no need to Trim overshoot, nor the continuous-centerline bits at the ends that Batting linetype gives you.  And it's a Polyline, so you can Trim it if you want, such as to things like angled baffles for attic-insulation ventilation at roof eaves.

Kent Cooper, AIA
Message 7 of 29
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

... more later, perhaps....


Some Layer-related ones:

LayerIsolateOnOff.lsp with its LIO and LUO commands is similar to AutoCAD's LAYISO and LAYUNISO, except:

A)  If you change something about a Layer [such as its color or linetype] between using LIO and LUO, it leaves that changed  rather than reverting [as LAYUNISO did at least at the time I wrote this -- that may be fixed in later versions] -- it deals only  in the On/Off condition of the Layers involved.

B)  It nests -- you can isolate some Layers, and then further isolate fewer of them with another LIO command, and even further down to even fewer, as many levels deep as you want to go, and then successive LUO commands will "step back" through each successive combination of turning Layers back On in reverse order [LAYUNISO can step back only once].

 

LayerIsolateThawFreeze.lsp with its LIT and LUT commands is just like LIO/LUO except that it does it by Freezing and Thawing rather than turning Off and On, an option not available with LAYISO [except that within a Viewport, it does VPfreeze rather than turning Off].

 

LayerQuellPick.lsp contains four commands to make invisible ["quell" seemed to cover both "off" and "freeze" choices] the Layers of picked objects.  LOP = Layer Off by Picking [top-level objects], LOPN = Layer Off by Picking [Nested objects], LFP = Layer Freeze by Picking [top-level objects], LFPN = Layer Freeze by Picking [Nested objects].  These pre-date AutoCAD's LAYOFF and LAYFRZ commands, and the nesting options more recently added to them, but even now that those are available, these get you there directly, rather than needing to call up one of those commands and choose the Settings option and then the Block selection option and then the level.  [But they don't have the Viewport choice.]

Kent Cooper, AIA
Message 8 of 29
Kevin.Spear
in reply to: Kent1Cooper

Being A Site/Civil Engineer, I'm late to this convo... But my favorite routine is something I found way back in the forums during the 90's. It's a routine [TW] that automates using DVIEW to orient your view to two picks. Or, you can press enter instead to type in a specific rotation value. The lisp has a secondary command [SNAG] to set the crosshairs orthogonal when recalling saved views that are rotated.
Thanks
Kevin

Kevin Spear, PE
Message 9 of 29
Kevin.Spear
in reply to: Kent1Cooper

Being A Site/Civil Engineer, I'm late to this convo... But my favorite routine is something I found way back in the forums during the 90's. It's a routine [TW] that automates using DVIEW to orient your view to two picks. Or, you can press enter instead to type in a specific rotation value. The lisp has a secondary command [SNAG] to set the crosshairs orthogonal when recalling saved views that are rotated.

Thanks
Kevin

Kevin Spear, PE
Message 10 of 29
john.uhden
in reply to: Kevin.Spear

Sounds like my VTWIST routine that originated in 1997 and includes
automatic change to SNAPANG. The best part is that there is an "Object"
option, meaning you need make only one pick of say text, or a polyline
segment, even if nested in a block or xref.

It's funny that it still contains an option to select a border block (from
the days before the use of paper space).

If any one wants it, just say so.

John F. Uhden

Message 11 of 29
iftikhargulmrd
in reply to: ganeshmag

my daily use 

Message 12 of 29

If I may make a few comments....

 

Many of the commands defined in CAD14.lsp may have been very useful in older versions -- AutoCAD Release 14  from about 20 years ago [not talking about AutoCAD 2014] perhaps? -- but for a long time now, can be accomplished through the Properties palette, without any command.

 

In the ANUMBER command, people should be aware that it requires that the current Text Style have a fixed height.  So you would need to ensure that you set that to the Style needed before using it.  But given that:

It has a non-existent function (PRINC1) at the end.  But since it uses

    (while T

to make it repeat, it requires the use of the ESCape key to end it, which cancels the whole thing before you ever reach that non-existent function to get an error message about it.

If you use the  (getpoint) function itself as the "test" part  of the (while) function, instead of using T, then you can still end it with ESCape if you like, but also with Enter or Space.  And since you're dealing with only integers, the

    (RTOS FNUM  2 0)

can be replaced with just

    (itoa FNUM)

and that can be put directly into the text command, rather than being saved to another otherwise-unnecessary variable.  My suggested alteration:

(defun C:ANUMBER (/ FNUM POINT1)
  (setq FNUM (getint "\nFIRST NUMBER : "))
  (while (setq POINT1 (getpoint "\nCHOOSE POINT or <exit>: "))
    (command "_.TEXT" POINT1 "0" (itoa FNUM))
    (setq FNUM (1+ FNUM))
  )
  (princ)
)
Kent Cooper, AIA
Message 13 of 29
ronjonp
in reply to: Kent1Cooper

I'd also add a simple IF statement .. (itoa nil) crashes.

(defun c:anumber (/ fnum point1)
  (if (setq fnum (getint "\nFIRST NUMBER : "))
    (while (setq point1 (getpoint "\nCHOOSE POINT or <exit>: "))
      (command "_.TEXT" point1 "0" (itoa fnum))
      (setq fnum (1+ fnum))
    )
  )
  (princ)
)
Message 14 of 29
Shneuph
in reply to: Kent1Cooper

I've always been pretty happy with how my acad and acaddoc.lsp files are used to manage loading lisp files and setting variables.  The acad.lsp is used to check and set environmental variables and the acaddoc.lsp for those saved in the dwg.

 

Lisp commands are demand loaded from a specific folder and lisp functions through a separate folder.  So, everything I piece together a lisp or need to edit one I only need to save it to the appropriate folder and it will begin loading the next time a dwg is opened.

 

There is also reporting so if you save a lisp that does have an error you can see in the commandline window where it got hung up.

 

I'm certainly not the greatest at writing lisp but have written quite a bit.  90% of what I know is probably through these forums so I have great appreciation for you guys who are always willing to help.  I also always try to give credit if I use what other people have written.

 

AcaddocPrintscr.png

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 15 of 29
Kent1Cooper
in reply to: ronjonp


@ronjonp wrote:

I'd also add a simple IF statement .. (itoa nil) crashes.

....
  (if (setq fnum (getint "\nFIRST NUMBER : "))
    (while (setq point1 (getpoint "\nCHOOSE POINT or <exit>: "))
....

I hit this thread again in connection with something else, and decided to offer a further enhancement.  Another way to ensure there's a value for the number, and also to offer a default value of 1 the first time, and of the next unused number on subsequent use:

(defun C:ANUMBER (/ POINT1)
  (initget 6); no zero, no negative
  (setq _ANumberInt_ ; global variable
    (cond
      ( (getint ; [returns nil on Enter]
          (strcat
            "\nFIRST NUMBER <"
            (if _ANumberInt_ (itoa _ANumberInt_) "1")
              ; prior value as default if present, otherwise 1
            ">: "
          ); strcat
        ); getint
      ); User-input condition
      (_ANumberInt_); on Enter with prior value [returns nil if none]
      (1); Enter on first use
    ); cond
  ); setq
  (while (setq POINT1 (getpoint "\nCHOOSE POINT or <exit>: "))
    (command "_.TEXT" POINT1 "0" (itoa _ANumberInt_))
    (setq _ANumberInt_ (1+ _ANumberInt_))
  ); while
  (princ)
); defun

I changed the variable name to something specific to the command name, so it's unlikely to be overwritten by any other routine in between uses of this one.  [The underscore prefix/suffix are just a convention some people use to distinguish global variable names from localized ones -- some use other characters for such indicators, like * or $, and/or sometimes use one only at the beginning, or none at all.]

Kent Cooper, AIA
Message 16 of 29
andkal
in reply to: ganeshmag

My daily use Lisp programs:

SUMAREA_SUMLEN_toCLIPBOARD - copies sum of area or length of objects and copies to clipboard so it can be easily pasted in another program. Program offers an option to define decimal symbol and devide factor.

RENAME_BLOCK_OR_LAYER(+DCL) - simple routine with one field popup window for changing name of a block or a layer of selected object.

XREFPATHUPDATE - for quick reloading not found xrefs or for replacing xrefs path with the path stored in clipboard.

QUICK_APPLOAD - for loading lisp files that I write in external editor (like Notepad++) and need to test it each time I change something


More general purpose lisp routines you can also find on my website.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
Message 17 of 29
_Tharwat
in reply to: ganeshmag

Some of my free applications listed in the following link to my website:

https://autolispprograms.wordpress.com/free-apps/ 

Message 18 of 29
Sea-Haven
in reply to: ganeshmag

A simple answer a work always in progress, just some of the 1100+ lisps in one directory, A*.lsp 71 lisps

 

 

Message 19 of 29
bfalconr2
in reply to: Kent1Cooper

Those lisp are very useful tools, thank you very much, do you have one to vpfreeze a selected object it's kind of the inverse of your LayerIsolateThawFreeze.

 

thank you in advance, 

Message 20 of 29
Jonathan3891
in reply to: bfalconr2

XYZ - similar to the ID command but displays the information in a dialog box. My favorite thing about this routine is if your units are set to 1/256, it will display correctly. 

 

 


Jonathan Norton
Blog | Linkedin

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost