All Activity
- Today
-
I often have to go back to old drawings. I have over 300 lisp programs. I would like the drawing to have a list of programs used to continue working, but over time it is not always possible to remember the name of the desired program.
-
LISPLogV1-0.lsp is a very convenient program. Thanks @Lee Mac. Is it possible to get a list of lisp commands in the drawing? That is, when saving a drawing, a request appears: "Save a list of lisp commands?" and the text with the commands is inserted into the drawing?
-
Lee Mac started following switch to turn on or off a variable
-
switch to turn on or off a variable
Lee Mac replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Another - (defun c:sf ( ) (setvar 'ucsfollow (- 1 (getvar 'ucsfollow))) (princ) ) -
Steven P started following Selection set filter
-
Your looking at DXF code 42 - which is "Actual Measurement" If X is say 1.2345 your selection set will look for dimensions measuring 1.2345 units, not passing through X coordinate 1.2345. Modified from Glavcvs code above: (ssget "_X" (list (cons 0 "DIMENSION") ; Filter for dimension '(-4 . "=,=,*") ; List filter modifiers (list 10 X Y ) ; Dimensions: '= 10' '= X' 'Anything Y' ) ; end list ) ; end ssget List filter modifiers could also be < or > '(-4 . "=,>,*") ; List filter modifiers (list 10 10 Y ) ; Dimensions: '= 10' 'X coord > 10' 'Anything Y' Weekend, beers last night, CAD is definitely off today so no testing done to check if I am typing rubbish or not.
-
Lee Mac started following Get a list of used AutoLISP commands
-
Get a list of used AutoLISP commands
Lee Mac replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Perhaps this old program? https://lee-mac.com/lisplog.html -
Get a list of used AutoLISP commands
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
I assume you're referring to commands defined in Lisp code. One way to do this is to call ATOMS-FAMILY, save its contents in a variable, call ATOMS-FAMILY again when the drawing is about to be closed, compare the difference, and filter out symbols that don't begin with "c:" But why do you need to do this? -
Good day to everyone. Is it possible to display a list of AutoLISP commands before closing and saving the dwg file? For example, in notepad or text in dwg.
-
According to your original code, the dimension drawn when the command is executed isn't changed. Only the existing dimensions are. Therefore, the call to DIMORDINATE should be made at the end of the loop, like this: (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) (command "_dimordinate" w M) ) ;while (setvar "osmode" 511) )
-
I am using (command "_.BREAK" pause "_F" "0,0.3" "0,-0.3") On the pause I am selecting a vertical line that spans well past the first and second point. When I got run this command and I select the line, I get this error BREAK Select object: Specify second break point or [First point]: F Specify first break point: 0,.3 Specify second break point: 0,-.3 Command: nil It doesn't break how I expect it to. If I run this command manually as in I manually type in the first and second points, it works but as soon as I try to run that single command line, it doesn't break properly. This is eventually part of a bigger lisp routine but I am getting hung up on this. Any thoughts?
-
cadnub joined the community
- Yesterday
-
LISP To attach xref's and modify layers
BIGAL replied to adrath's topic in AutoLISP, Visual LISP & DCL
You are right about learning lisp the CAD suppliers give you example of how to use a lisp function but really no actual step by step tutorials. Look for Graden path tutorial if using Acad. A good tutorial. Ther are some good books out there I found some on kindle very cheap and can copy code from the electronic book. Also a good reference is 'The visual Lisp Developers Bible" Agree Afralisp has come good tutorials. A comment "6. Analyze the layers" we used to process output from other software brought into cad so had a text file with all the layer details, Oldname Newname etc. Eg for road surveys had a existing layer LIP it was renamed EX-LIP and color changed, when designing a layer called LIP was known then as a design layer. -
switch to turn on or off a variable
Tsuky replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Or this, for toggle (defun c:SF ( / ) (if (zerop (boole 1 (getvar "UCSFOLLOW") 1)) (progn (setvar "UCSFOLLOW" (1+ (getvar "UCSFOLLOW"))) (princ "\nUCS Follow Activado") ) (progn (setvar "UCSFOLLOW" (1- (getvar "UCSFOLLOW"))) (princ "\nUCS Follow Desactivado") ) ) (prin1) ) -
LISP To attach xref's and modify layers
rlx replied to adrath's topic in AutoLISP, Visual LISP & DCL
Haven't really looked at the rest of your code , simply changed the getfolder & split text part and pasted the rest. As far for learning , there are lots of posts here on this site asking the same thing so no use summing them up all again but Lee Mac's site and Afralisp are good places to start. Just kiss... (keep it simple stupid) , start easy and if you like it enough you'll find the motivation to take it next level. Lisp has some quirks & limitations but for many (repeating) tasks you can get great results with relatively little effort once you get the hang of it. But some lisp concepts will need a little time to sink in (if ever). 3d and matrixes for example are not really my thing but that's because I use them so little , when I need them I beg , steal , borrow , cut , copy & paste something together until it works and forget all about it until I need it again. -
switch to turn on or off a variable
GLAVCVS replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
'repeat 100...'? Changing the same variable 100 times...why? I guess that's a mistake. Something simple: every time the command sf is called, UCSFOLLOW changes state, without asking (defun c:sf (/ act) (setvar "UCSFOLLOW" (if (setq act (= (getvar "UCSFOLLOW") 0)) 1 0)) (princ (strcat "\n*** Variable UCSFOLLOW " (if act "activada" "desactivada"))) (princ) ) -
leonucadomi started following switch to turn on or off a variable
-
hello : I use this code to quickly change a variable on or off. I would like to know if someone can improve it in appearance or functionality.
-
LISP To attach xref's and modify layers
adrath replied to adrath's topic in AutoLISP, Visual LISP & DCL
Thanks for the reply, RLX! I would love to learn how to do this myself, but I've had a hard time finding any instructional resources. Seems you just have to work with somebody that knows and get taught. Autodesk has very little about writing LISP's. If you know of any resources, I'm all ears. I would rather be in charge of the coding than doing this iterative, dystopian machine-building-machine nonsense. But for now, CoPilot writes a code, I read the code and get a sense of what it does, then I change the code and read it again and I'm at least starting to lay the groundwork that way. As far as your code, it didn't throw any errors and it brought in all the xref's but it didn't change the layer colors. I do like the folder dialogue you used better though and not throwing errors is a huge step in the right direction. Thank you. I'll keep messing with it. -
LISP To attach xref's and modify layers
adrath replied to adrath's topic in AutoLISP, Visual LISP & DCL
Sorry. I'll do that next time. -
Try (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (command "_dimordinate" w M) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) ) ;while (setvar "osmode" 511) )
-
I only want to select the dimension that goes through the specific x-axis point and y-axis is veriable. example point (13,17) (15, 18) co-ordinate greater than 10, select dimension which goes through co-ordinate 13, 15.
-
tillawy joined the community
-
Your question seems a little confusing to me. What do you want to achieve?
-
(defun C:or (/ dst) (prompt "\set UCS at 0,0") (while (setq w (getpoint)) (setq m (getpoint)) (setq x (car w)) (setq y (cadr w)) (setvar "osmode" 0) (if (< X 10) (command "dimordinate" w M ) (progn (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) (command "dimordinate" w M ) (command "_.CHPROP" e "" "_color" 1 "") ;;;;code;;;; ) ;progn ) ;if ) ;while (setvar "osmode" 511) ) (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) It does not create any selection set, dimension passing through only x-cordinate
-
.DXF files not showing up
CyberAngel replied to BCDJOHN123's topic in AutoCAD Drawing Management & Output
My guess is they mean they set their DWGUNITS variable to 3, which changes units to mm. But it doesn't sound like that's the real problem. They mentioned a new template, may be something there. -
nguyenhoang joined the community
-
hmedia joined the community
- Last week
-
.DXF files not showing up
BIGAL replied to BCDJOHN123's topic in AutoCAD Drawing Management & Output
Does not sound right an inch is 25.4 mm. So need to scale accordingly using that factor. Zoom extents should find. Post a dwg as suggested. -
AutoCAD LISP: Bring Back Layout Arrows (Next/Previous Tab Navigation)
BIGAL replied to PhillM's topic in AutoCAD General
if you just want to go up and down use Ctrl+Pgdn, Ctrl+Pgup. This will let you jump to any layout. Goto-layout.lsp -
DMP joined the community
-
rlx started following LISP To attach xref's and modify layers
-
LISP To attach xref's and modify layers
rlx replied to adrath's topic in AutoLISP, Visual LISP & DCL
without the actual drawings unable to test this so this is untested : (defun c:BatchXref ( / skipList folder curPhase prevPhases phaseList ) (setq skipList '("X-TTLB.dwg" "X-DETL.dwg" "X-LGND.dwg")) (setq folder (GetShellFolder "Select target folder")) ;;; Prompt for current phase number (setq curPhase (getstring "\nEnter current phase number (e.g., 03): ")) ;;; Prompt for previous phase numbers (setq prevPhases (getstring "\nEnter previous phase numbers (comma-separated, e.g., 01,02): ")) ;;; split up previous phases (setq phaseList (SplitStr prevPhases ",")) ;; Display phase info (princ (strcat "\nCurrent Phase: X-BASE-UN" curPhase)) (princ (strcat "\nPrevious Phases: " (apply 'strcat (mapcar (function (lambda (p) (strcat " " p))) phaseList)))) ;;; Create X-REF layer if needed (if (not (tblsearch "LAYER" "X-REF")) (command "_.-LAYER" "_Make" "X-REF" "_Color" "7" "X-REF" "")) ;;; Get DWG files (if (vl-consp (setq files (vl-directory-files folder "*.dwg" 1))) (progn ;;; Insert XREFs (foreach file files (if (not (member (strcase file) (mapcar 'strcase skipList))) (progn (setq fullpath (strcat folder file)) (command "_.-XREF" "_Overlay" fullpath '(0 0 0) 1 1 0) (command "_.CHPROP" "L" "" "_LA" "X-REF" "") ) ) ) ;;; Lock the layer (command "_.-LAYER" "_Lock" "X-REF" "") ;;; Change color of layers with previous phase names in XREF or nested XREF (setq layerTable (tblnext "LAYER" T)) (while layerTable (setq layerName (cdr (assoc 2 layerTable))) (setq matched nil) ;;; *** vl-string-split *** made up by glorified paperclip ;;; Split layer name into parts (XREF nesting) (setq xrefParts (SplitStr layerName "|")) ;;; Check each part for a match with previous phase names (foreach part xrefParts (if (member (strcase part) phaseList) (setq matched T))) ;;; If matched, change layer color using entmod (if matched (progn (setq layerEnt (tblobjname "LAYER" layerName)) (if layerEnt (progn (setq layerData (entget layerEnt)) (if (assoc 62 layerData) (setq layerData (subst (cons 62 251) (assoc 62 layerData) layerData)) (setq layerData (append layerData (list (cons 62 251)))) ) (entmod layerData) (entupd layerEnt) ) ) ) ) (setq layerTable (tblnext "LAYER")) ) (princ "\nOverlay XREFs added. Layers in matching XREFs and nested XREFs set to color 251.") ) (princ "\nNo folder selected / files to proces") ) (princ) ) ;;; s = string d = delimiter p = position delimiter (setq r (SplitStr "01,02" ",")) -> '("01" "02") (defun SplitStr ( s d / p ) (if (setq p (vl-string-search d s))(cons (substr s 1 p) (SplitStr (substr s (+ p 1 (strlen d))) d)) (list s))) ;;; (setq f (GetShellFolder "Select a folder")) -> "C:\\Temp\\Lisp\\" (defun GetShellFolder ( m / f s) (if (and (setq s (vlax-create-object "Shell.Application")) (setq f (vlax-invoke s 'browseforfolder 0 m 65536 "")))(setq f (vlax-get-property (vlax-get-property f 'self) 'path)) (setq f nil))(vl-catch-all-apply 'vlax-release-object (list s)) (if f (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" f)) "\\"))) Just a couple remarks : getfolder (or GetShellFolder) is more generic than selecting a drawing and stripping out path. It's not wrong but soooo last century. ChatGPT or Copilot : stop using them and learn to do it yourself. As long as those glorified paperclips are not star-trek level you can't trust them. They make up commands like in your code : (setq xrefParts (vl-string-split layerName "|")) , maybe somebody at one time created this (vl-string-split) as a custom defun but in my visual lisp editor it didn't turn blue so its not a core command. I replaced it with SplitStr. Oh I also don't see a save command anywhere so I assume that's handled by you or Copilot? I hope code above works , if not... bite me -
LISP To attach xref's and modify layers
SLW210 replied to adrath's topic in AutoLISP, Visual LISP & DCL
In the future, please use Code Tags for your code. (<> in the editor toolbar)