Author Topic: Old lsp Code  (Read 2804 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Old lsp Code
« on: October 23, 2010, 09:27:13 AM »
The lsp files that came with Release 11 & 12, circa 1990 and before were my tutorials.  A couple in particular were real teaching tools for me
ssx and 3d.

R11 came with 34 routines, R12 - 29 but introduced DCL.

I remember finally grasping (cond) and meshes from 3d.lsp  and (ssget) filtering from ssx.  They were good learning tools.  Along with Customizing AutoCAD Release 10 by J. Smith and R. Gesner  -David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Old lsp Code
« Reply #1 on: October 23, 2010, 09:52:26 AM »
Thanks David, a good learning tool. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Old lsp Code
« Reply #2 on: October 23, 2010, 11:31:42 AM »
CAB,

Yes, they really are!  Sometimes you can see the evolution of certain aspects of a subroutine ( error, set modes, reset modes etc )

One that has come and gone more that once is  (GetVal) type of calls. I would have hopes that they would be gone by now but I still see it now and again.  -David
R12 Dos - A2K

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Old lsp Code
« Reply #3 on: October 23, 2010, 11:48:03 AM »
Those MODES and MODER subs are still my favorite. I employ a similar method i learned from Evgeniy.

Thank you David.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Old lsp Code
« Reply #4 on: October 23, 2010, 12:36:31 PM »
Those MODES and MODER subs are still my favorite. I employ a similar method i learned from Evgeniy.

I still use something similar my self.  It looks like ti was the mid to late '90s when I started using a doted pair for  the modes.  I really don't remember how it came about.  Other than I didn't like the 2 separate lists
Code: [Select]
(mapcar 'setvar
    '("cmdecho" "blipmode" "expert" "flatland" "gridmode"
      "osmode" "thickness")
    '(0 0 4 0 0 0 0)
  )

R12 Dos - A2K

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Old lsp Code
« Reply #5 on: October 23, 2010, 01:46:48 PM »
Hi,

One I like to deal with with sysvars is ai_sysvar from acad20XXdoc.lsp (in acad.mnl or ai_utils.lsp for older versions).

Quote
;;; --- ai_sysvar ------------------------------------------
;;; Change system variable settings and save current settings
;;; (Note: used by *merr* to restore system settings on error.)
;;;
;;; The <vars> argument is used to...
;;;   restore previous settings (ai_sysvar NIL)
;;;   set a single sys'var (ai_sysvar  '("cmdecho" . 0))
;;;   set multiple sys'vars (ai_sysvar '(("cmdecho" . 0)("gridmode" . 0)))
;;;
;;; defun-q is needed by Visual Lisp for functions which redefine themselves.
;;; it is aliased to defun for seamless use with AutoLISP.
Speaking English as a French Frog

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Old lsp Code
« Reply #6 on: October 23, 2010, 02:09:25 PM »
I had forgotten about them, thank goodness!  defun-q yuck!  -David
R12 Dos - A2K

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Old lsp Code
« Reply #7 on: October 23, 2010, 02:37:31 PM »
Using the same behaviour as ai_sysvar: gc:LayerUnLockAll.

Code: [Select]
;;; gc:LayerUnLockAll
;;; Unlocks all layers or re-locks the previous locked layers
;;;
;;; Argument: T or nil
;;;
;;; Using:
;;; (gc:LayerUnLockAll T) unlocks all locked layers
;;; (gc:LayerUnLockAll nil) re-locks previous locked layers


(defun-q
  gc:LayerUnLockAll
  (flag / lst lay)
  (setq lst nil)
  (if flag
    (vlax-for l (vla-get-Layers (vla-get-Activedocument (vlx-get-acad-object)))
      (and (= (vla-get-Lock l) :vlax-true)
   (setq lst (cons l lst))
   (vla-put-Lock l :vlax-false)
      )
    )
    (progn
      (foreach n lst
(vl-catch-all-apply 'vla-put-Lock (list n :vlax-true))
      )
      (setq lst nil)
    )
  )
  (setq layerunlockall
(cons (car layerunlockall)
       (cons (list 'setq 'lst (list 'quote lst))
     (cddr layerunlockall)
       )
)
  )
  lst
)
Speaking English as a French Frog