All Activity
- Past hour
-
Just another example, nice, also it would work.
-
Steven P started following Minus value to set zero
-
If (- botLength 6000) is minus.... (if (= (minusp (- botlength 6000)) T) ;; verifies that a number is negative (setq botLength 0) ;; if it is, it will set to 0 (setq botLength (- botLength 6000)) ;; if it isn't, it will be substracted with "6000" ) ;;End If
- Today
-
Saxlle started following Minus value to set zero
-
(if (= (minusp botLength) T) ;; verifies that a number is negative (setq botLength 0) ;; if it is, it will set to 0 (setq botLength (- botLength 6000)) ;; if it isn't, it will be substracted with "6000" )
-
dexus started following Minus value to set zero
-
You mean like this? (if (minusp botLength) 0 (- botLength 6000))
-
(- botLength 6000) If this value is a minus value , I need to set it zero. Please help
-
bimcowboy joined the community
- Yesterday
-
devitg started following LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
-
LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
devitg replied to xenru's topic in AutoLISP, Visual LISP & DCL
@xenru Please upload your-sample-dwg -
CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
BIGAL replied to SCHNIPPLES's topic in AutoLISP, Visual LISP & DCL
Also -
CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
devitg replied to SCHNIPPLES's topic in AutoLISP, Visual LISP & DCL
@SCHNIPPLES please give it a try ;;----------------------------------------------------------------------;; ;; Design and modify by Gabo CALOS DE VIT from CORDOBA ARGENTINA ;;; Copyleft 1995-2026 by Gabriel Calos De Vit ; DEVITG@GMAIL.COM ;Hecho y modificado por Gabo CALOS DE VIT de CORDOBA ARGENTINA ;;; Copyleft 1995-2026 por Gabriel Calos De Vit ;; DEVITG@GMAIL.COM ;;; inicio-defun-20-ene-2026 ;; as per ;;https://www.cadtutor.net/forum/topic/98950-create-perpendicular-dimension-between-two-parallel-polylines/ ;;*------------------------------------------------------------------------------------------- (defun c:T5 (/ ACAD-OBJ acExtendNone ADOC AT&T-STYLE BASE-OBJ BASEENT CE CP1 DERIV DIM-STYLES DIM-TXT-PT DIMOBJ INTS-VAR@BASE INTS-VAR@TGT INTS@BASE INTS@TGT MODEL NRM OS P P1 P2 PARAM S SEARCHRAD SMPL-DIM SMPL-DIM-LAY SMPL-DIM-STYLE SMPL-OBJ TAN TGT-OBJ TGTENT TMP-OBJ TMPE X ) ;_ end of / (VL-LOAD-COM) (SETQ ACAD-OBJ (VLAX-GET-ACAD-OBJECT)) ;_ el programa ACAD (SETQ ADOC (VLA-GET-ACTIVEDOCUMENT ACAD-OBJ)) ;_ el DWG que esta abierto- (SETQ MODEL (VLA-GET-MODELSPACE ADOC)) (setq dim-styles (VLA-GET-DIMSTYLES adoc)) (setq searchRad 2000.0) ; increase if your gaps are big (drawing units) (defun v+ (a b) (mapcar '+ a b)) (defun v- (a b) (mapcar '- a b)) (defun v* (v s) (mapcar '(lambda (x) (* x s)) v)) (defun dot (a b) (+ (* (car a) (car b)) (* (cadr a) (cadr b)) (* (caddr a) (caddr b)) ) ;_ end of + ) ;_ end of defun (defun len (v) (sqrt (dot v v))) (defun unit (v / L) (setq L (len v)) (if (> L 1e-12) (v* v (/ 1.0 L)) v ) ;_ end of if ) ;_ end of defun (defun dist (a b) (len (v- a b))) (setq os (getvar "OSMODE")) (setq ce (getvar "CMDECHO")) (setvar "OSMODE" 0) (setvar "CMDECHO" 0) (alert "\n you have to select a dim you had done ") (princ "\n Select a sample dim") (setq smpl-dim (ssname (ssget "_:S+." '((0 . "dimension"))) 0)) (setq baseEnt (car (entsel "\nSelect BASE object (ROW): "))) (redraw baseEnt 3) (setq base-obj (vlax-ename->vla-object baseEnt)) (setq tgtEnt (car (entsel "\nSelect TARGET object (BOC/Fiber/etc.): "))) (redraw tgtEnt 3) (setq tgt-obj (vlax-ename->vla-object tgtEnt)) (setq p (getpoint "\nPick dimension location (also picks the side): " ) ;_ end of getpoint ) ;_ end of setq (if (and baseEnt tgtEnt p) (progn ;; Closest point on base (setq cp1 (vlax-curve-getClosestPointTo baseEnt p)) ;; Tangent derivative at cp1 (setq param (vlax-curve-getParamAtPoint baseEnt cp1)) (setq deriv (vlax-curve-getFirstDeriv baseEnt param)) (setq tan (unit deriv)) ;; Normal (perpendicular) in XY (setq nrm (unit (list (- (cadr tan)) (car tan) 0.0))) ;; Build long perpendicular segment through cp1 (setq p1 (v- cp1 (v* nrm searchRad))) ;(setq point@p1 (VLA-ADDPOINT model (VLAX-3D-POINT p1))) (setq p2 (v+ cp1 (v* nrm searchRad))) ;(setq point@p2 (VLA-ADDPOINT model (VLAX-3D-POINT p2))) ;; Create temp LINE entity (so we can intersect reliably) (setq tmpE (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2) ) ;_ end of list ) ;_ end of entmakex ) ;_ end of setq (setq tmp-obj (vlax-ename->vla-object (entlast))) ;; Get intersections between target and temp line ; You had an error here. it is not ;; (setq ints (vlax-curve-intersectwith tgtEnt tmpE acextendnone)) ;;it is so (setq ints-var@tgt (vla-intersectwith tgt-obj tmp-obj acextendnone)) (setq ints@tgt (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE ints-var@tgt))) ;(setq point@tgt (VLA-ADDPOINT model ints-var)) ;; Get intersections between base and templine (setq ints-var@base (vla-intersectwith base-obj tmp-obj acextendnone)) (setq ints@base (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE ints-var@base))) ;(setq point@base (VLA-ADDPOINT model ints-var@base)) (vla-delete tmp-obj) ;;(setq smpl-dim (ssname (ssget "_:S+." '((0 . "dimension"))) 0)) (setq smpl-dim-style (cdr (assoc 3 (entget smpl-dim)))) (setq smpl-obj (vlax-ename->vla-object smpl-dim)) (setq smpl-dim-lay (vla-get-layer smpl-obj)) (setvar 'clayer smpl-dim-lay) (setq at&t-style (vla-item dim-styles (VLA-GET-STYLENAME smpl-obj))) ;"AT&T" (vla-put-ActiveDimStyle adoc at&t-style) (setq dim-txt-pt (MAPCAR '* '(0.5 0.5 0.5) (MAPCAR '+ ints@base ints@tgt))) (setq dimObj (vla-AddDimAligned model ints-var@base ints-var@tgt (VLAX-3D-POINT dim-txt-pt) ) ;_ end of vla-AddDimAligned ) ;_ end of setq ) ;_ end of progn ) ;_ end of if (VL-CMDF "regen") (setvar "CMDECHO" ce) (setvar "OSMODE" os) (princ) ) ;_ end of defun ;|«Visual LISP© Format Options» (100 2 40 2 T "end of " 60 9 0 0 0 T T nil T) ;*** DO NOT add text below the comment! ***|; dim to lines SCHNIPPLES cadtutor.lsp -
Select all the lines that are vertical
Isaac26a replied to Isaac26a's topic in AutoLISP, Visual LISP & DCL
Hi ryanatkins49056, your solution is no solution, most of the time I use qselect for a lot of tasks and as this lines are not vertical (90º) there is no match, and if you use less than or greater than, also has a different selection, thanks for your attempt to solve the problem but, it is already solved by the solutions from Mhupp and Lee Mac. -
CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
BIGAL replied to SCHNIPPLES's topic in AutoLISP, Visual LISP & DCL
This has been asked before for that task of dimensioning services in roads. I know did something pick base line then pick other lines and all done. Will try to find may have been a few years ago. -
Batch DWG to PDF plot LISP File
BIGAL replied to Chicane_Apex's topic in AutoLISP, Visual LISP & DCL
"Modelspace, paperspace or both?" looks like @Chicane_Apex has left the building, just like Elvis. -
VS Code AutoCAD Lisp Snippets
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Another very useful is "Entmake functions.lsp", it has various entmake functions in it. Maybe make a word doc etc of your functions describing what they do. We had a "how to directory" with lots of help files. Was thinking about doing macros in Notepad++ run ents, run ss, ssl for layer, ssi for insert and so on. This is a common one. (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) ) Posted this before. Lisp files Apr 2024.docx -
Steven P started following VS Code AutoCAD Lisp Snippets
-
VS Code AutoCAD Lisp Snippets
Steven P replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
I have some snippets saved away in different files - open, copy and paste as I need them. Others I have some files with many functions, such as text where I'll save the common functions and refer to them. For example a simple text selection (entsel, check it is text, message if not and reselect, return the text) or an entmod to update a text string... all in the same file but referenced by many functions in it. However I keep meaning to save away little functions to answer questions on the forum that get asked time and time again such as PDF plotting and batch LISPs -
VS Code AutoCAD Lisp Snippets
CivilTechSource replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
@BIGAL this is exactly what I want to achieve! I want to make it more accessible to people to learn how to write lisps. My plan is to start with basic functions, like getpoint and getdistance, if statements, prompts and so on. If you have suggestions on what more I can add please feel free. -
ronjonp started following LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
-
LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
ronjonp replied to xenru's topic in AutoLISP, Visual LISP & DCL
(defun c:foo (/ :paddvertex e lwp pts s) ;; Lee Mac's function (defun :paddvertex (e p / tan lm:lwvertices a b e h l n r w x z) (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) (defun lm:lwvertices (e) (if (setq e (member (assoc 10 e) e)) (cons (list (assoc 10 e) (assoc 40 e) (assoc 41 e) (assoc 42 e)) (lm:lwvertices (cdr e))) ) ) (if (and p e (setq p (vlax-curve-getclosestpointto e (trans p 1 0)) n (vlax-curve-getparamatpoint e p) ) ) (if (not (equal n (fix n) 1e-8)) (progn (setq e (entget e) h (reverse (member (assoc 39 e) (reverse e))) l (lm:lwvertices e) z (assoc 210 e) ) (repeat (fix n) (setq a (cons (car l) a) l (cdr l) ) ) (setq x (car l) r (- n (fix n)) w (cdr (assoc 40 x)) w (+ w (* r (- (cdr (assoc 41 x)) w))) b (atan (cdr (assoc 42 x))) ) (entmod (append h (apply 'append (reverse a)) (list (assoc 10 x) (assoc 40 x) (cons 41 w) (cons 42 (tan (* r b)))) (list (cons 10 (trans p 0 (cdr z))) (cons 40 w) (assoc 41 x) (cons 42 (tan (* (- 1.0 r) b))) ) (apply 'append (cdr l)) (list z) ) ) ) ) ) ) ;; RJP » 2026-01-20 (cond ((setq s (ssget ":L" '((0 . "INSERT,LWPOLYLINE")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (if (= "LWPOLYLINE" (cdr (assoc 0 (entget e)))) (setq lwp (cons e lwp)) (setq pts (cons (cdr (assoc 10 (entget e))) pts)) ) ) (and lwp pts (foreach e lwp (foreach pt pts (and (equal pt (vlax-curve-getclosestpointto e pt) 1e-4) (:paddvertex e pt)) ) ) ) ) ) (princ) )(defun c:foo (/ :paddvertex e lwp pts s) ;; Lee Mac's function (defun :paddvertex (e p / tan lm:lwvertices a b e h l n r w x z) (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) (defun lm:lwvertices (e) (if (setq e (member (assoc 10 e) e)) (cons (list (assoc 10 e) (assoc 40 e) (assoc 41 e) (assoc 42 e)) (lm:lwvertices (cdr e))) ) ) (if (and p e (setq p (vlax-curve-getclosestpointto e (trans p 1 0)) n (vlax-curve-getparamatpoint e p) ) ) (if (not (equal n (fix n) 1e-8)) (progn (setq e (entget e) h (reverse (member (assoc 39 e) (reverse e))) l (lm:lwvertices e) z (assoc 210 e) ) (repeat (fix n) (setq a (cons (car l) a) l (cdr l) ) ) (setq x (car l) r (- n (fix n)) w (cdr (assoc 40 x)) w (+ w (* r (- (cdr (assoc 41 x)) w))) b (atan (cdr (assoc 42 x))) ) (entmod (append h (apply 'append (reverse a)) (list (assoc 10 x) (assoc 40 x) (cons 41 w) (cons 42 (tan (* r b)))) (list (cons 10 (trans p 0 (cdr z))) (cons 40 w) (assoc 41 x) (cons 42 (tan (* (- 1.0 r) b))) ) (apply 'append (cdr l)) (list z) ) ) ) ) ) ) ;; RJP » 2026-01-20 (cond ((setq s (ssget ":L" '((0 . "INSERT,LWPOLYLINE")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (if (= "LWPOLYLINE" (cdr (assoc 0 (entget e)))) (setq lwp (cons e lwp)) (setq pts (cons (cdr (assoc 10 (entget e))) pts)) ) ) (and lwp pts (foreach e lwp (foreach pt pts (and (equal 0. (distance pt (vlax-curve-getclosestpointto e pt)) 1e-4) (:paddvertex e pt) ) ) ) ) ) ) (princ) ) -
mhupp started following LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
-
LISP for breaking multiple polyline at 'insertion point' of multiple Blocks (AUTOCAD 2026)
mhupp replied to xenru's topic in AutoLISP, Visual LISP & DCL
I Think they want this more for measurements of some type of conduit than for visual display. tho why not use lee mac's and just add whatever half or 3/4 of [SPLT] is. maybe points? you could get that from the block. @xenru need a little more detail on why you want this. -
CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
SCHNIPPLES replied to SCHNIPPLES's topic in AutoLISP, Visual LISP & DCL
Here you go sample.dwg -
AutoCAD for Mac 2022 – Lineweights change thickness when zooming (display bug)
gkathan replied to gkathan's topic in AutoCAD Bugs, Error Messages & Quirks
Thank you for the suggestions and for taking the time to look into this. I appreciate your help and insights. -
furqanibrahim joined the community
-
devitg started following CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
-
CREATE PERPENDICULAR DIMENSION BETWEEN TWO PARALLEL POLYLINES
devitg replied to SCHNIPPLES's topic in AutoLISP, Visual LISP & DCL
@SCHNIPPLES please upload your-sample.dwg -
ryo83 joined the community
-
Reduce file size.
SLW210 replied to Bandido's topic in AutoCAD 2D Drafting, Object Properties & Interface
Best way to clean a difficult file is WBlock, not sure what had those bloated like that. -
AutoCAD for Mac 2022 – Lineweights change thickness when zooming (display bug)
SLW210 replied to gkathan's topic in AutoCAD Bugs, Error Messages & Quirks
What are the computer specifications? What OS? Lines, LWPolylines, 2DPolylines or 3D Polylines I doubt there is a permanent fix except to repair the drawings that have the issue, though it could still be an issue with your computer graphics. If it's polylines, try exploding them to lines, then PEDIT them back to LWPolylines, also try an Audit on the affected drawings. You could post an example drawing that has the issue, maybe it will show on other's computers if it's a .dwg issue. -
Henk594 joined the community
-
Batch DWG to PDF plot LISP File
SLW210 replied to Chicane_Apex's topic in AutoLISP, Visual LISP & DCL
The OP is using AutoCAD LT 2026 and cannot use a .NET AFAIK. You are new so I removed your link to YouTube. -
lehoang6198 joined the community
-
Batch DWG to PDF plot LISP File
lehoang6198 replied to Chicane_Apex's topic in AutoLISP, Visual LISP & DCL
Experience my plugin written with .NET API. -
COOKIE2000 joined the community
-
AD_743 joined the community
-
If you want to load lisp as it is, then you shouldn't localize that first (defun) along with other variables... Only if you push it (that first defun) in main body of command function (defun c:) you should localize it, wich is what I suggested... As you observed CAD won't recognize localized defun if it's out of main command function and bahave like global variable, though as if you had globals they should never be localized as they also won't be recognized...
-
VS Code AutoCAD Lisp Snippets
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
@CivilTechSource Like you, It is a good idea to have a library of functions that you use all the time, in my Excel lisp there are 41 defuns so just copy and paste the ones I want to use, same with my Multi lisps for dcl's. often set them to write a dcl and then convert that file to dcl lisp code, like 3 lines of code to make a dcl. I have a VLAX lsp open all the time in my Notepad++ so again copy paste a function. I have a lot of lisp's saved as a function name eg Sort.lsp has various sort methods in it. I use windows "Findstr" a lot in a bat file so can look through an entire lisp directory for a keyword, identifies lisp files with that key word and copy and paste what I want out of existing code. You can in a lisp load an entire other lisp program and continue and use functions in that new lisp, I mention it as you could have little tiny lisp's like your "make layer.lsp" and just load when required. eg (if (not ah:butts)(load "Multi radio Buttons.lsp")) so you could have a few load lisp's at start of code saving lots of copying and pasting. Interested what others do.
