TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: David Bethel 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
-
Thanks David, a good learning tool. 8-)
-
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
-
Those MODES and MODER subs are still my favorite. I employ a similar method i learned from Evgeniy.
Thank you David.
-
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
(mapcar 'setvar
'("cmdecho" "blipmode" "expert" "flatland" "gridmode"
"osmode" "thickness")
'(0 0 4 0 0 0 0)
)
-
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).
;;; --- 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.
-
I had forgotten about them, thank goodness! defun-q yuck! -David
-
Using the same behaviour as ai_sysvar: gc:LayerUnLockAll.
;;; 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
)