All Activity
- Today
-
Integrating Firing Range Software with AutoCAD for Shooting Range Design
oddssatisfy replied to oddssatisfy's topic in Autodesk Software General
thank you for your suggestion -
ronso1 joined the community
-
m.wolny joined the community
-
Saxlle started following Lisp for to get y value of police based on datum value and line.
-
Lisp for to get y value of police based on datum value and line.
Saxlle replied to Ish's topic in AutoLISP, Visual LISP & DCL
Long time I'm nothing written in Lisp. So, I hoppe it will serve you. Also, you can saw a short video how it works. The code: (prompt "\nTo run a LISP type: yval") (princ) (defun c:yval ( / old_osmode pline spt ept spt_pline ept_pline datum_line yval_datum_line yval_start_pline yval_end_pline txt_position ang_spt_pline ang_ept_pline datum_value intersecting_lines len i int_pt_pline int_pt_datum_line dist yval_position ang) (setq old_osmode (getvar 'osmode)) (setq pline (car (entsel "\nSelect Polyline to get an Elevation:"))) (while (or (equal pline nil) (not (equal "LWPOLYLINE" (cdr (assoc 0 (entget pline)))))) (prompt "\nSelected entity must be LWPOLYLINE. Try again...\n") (setq pline (car (entsel "\nSelect Polyline to get an Elevation:"))) ) (setq spt_pline (vlax-curve-getStartPoint pline) ept_pline (vlax-curve-getEndPoint pline) ) (if (> (car spt_pline) (car ept_pline)) (progn (command-s "_reverse" pline "") (setq spt_pline (vlax-curve-getStartPoint pline) ept_pline (vlax-curve-getEndPoint pline) ) ) ) (setq datum_line (car (entsel "\nSelect Datum Line:"))) (while (or (equal datum_line nil) (not (equal "LINE" (cdr (assoc 0 (entget datum_line)))))) (prompt "\nSelected entity must be LINE. Try again...\n") (setq datum_line (car (entsel "\nSelect Datum Line:\n"))) ) (setq yval_datum_line (cadr (vlax-curve-getStartPoint datum_line)) yval_start_pline (- (cadr spt_pline) yval_datum_line) yval_end_pline (- (cadr ept_pline) yval_datum_line) ) (setq txt_position (getpoint "\nPick the lower-left corner of the box for elevation value:\n")) (setvar 'osmode 0) (setq datum_value (car (entsel "\nSelect Datum value:"))) (if (equal "MTEXT" (cdr (assoc 0 (entget datum_value)))) (setq datum_value (LM:UnFormat (cdr (assoc 1 (entget datum_value))) T)) (setq datum_value (cdr (assoc 1 (entget datum_value)))) ) (setq ang_spt_pline (angle (setq yval_position_one (list (car spt_pline) (+ (cadr txt_position) 0.1) (caddr txt_position))) spt_pline) ang_ept_pline (angle (setq yval_position_two (list (car ept_pline) (+ (cadr txt_position) 0.1) (caddr txt_position))) ept_pline) ) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 1 (rtos (+ yval_start_pline (atof datum_value)) 2 3)) (cons 10 yval_position_one) (cons 11 yval_position_one) (cons 40 0.35) (cons 72 0) (cons 73 2) (cons 50 ang_spt_pline))) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 1 (rtos (+ yval_end_pline (atof datum_value)) 2 3)) (cons 10 yval_position_two) (cons 11 yval_position_two) (cons 40 0.35) (cons 72 0) (cons 73 2) (cons 50 ang_ept_pline))) (princ "\nSelect intersecting lines:") (setq intersecting_lines (ssget (list (cons 0 "LINE") (cons 8 "DATUM-GRID"))) len (sslength intersecting_lines) i 0 ) (while (< i len) (setq int_pt_pline (vlax-safearray->list (vlax-variant-value (vla-IntersectWith (vlax-ename->vla-object pline) (vlax-ename->vla-object (ssname intersecting_lines i)) acExtendNone))) int_pt_datum_line (vlax-safearray->list (vlax-variant-value (vla-IntersectWith (vlax-ename->vla-object datum_line) (vlax-ename->vla-object (ssname intersecting_lines i)) acExtendNone))) dist (distance int_pt_pline int_pt_datum_line) yval_position (list (car int_pt_pline) (+ (cadr txt_position) 0.1) (caddr txt_position)) ang (angle yval_position int_pt_pline) i (1+ i) ) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 1 (rtos dist 2 3)) (cons 10 yval_position) (cons 11 yval_position) (cons 40 0.35) (cons 72 0) (cons 73 2) (cons 50 ang_spt_pline))) ) (setvar 'osmode old_osmode) (prompt "\nAn elevation values were added!") (princ) ) ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; str - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( str mtx / _replace rx ) (vl-load-com) (defun _replace ( new old str ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace str new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq str (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq str (_replace (car pair) (cdr pair) str)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str)) (_replace "\\" "\032" str) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p str)) str ) ) ) ) The short video: YVAL.mp4 Best regards. -
Lisp for to get y value of police based on datum value and line.
Ish posted a topic in AutoLISP, Visual LISP & DCL
Dear Members, I have a ployline with dautm text value and datum line , I want text label of pline start vertex, intersection pont and end vertex, based on datum. If any have plz share need only y value, elevation, level of pline . Thanks See attached cad file Thanks POLYLINE Y VALUE.dwg -
vayacondios____ joined the community
-
I made mistake, this works only for text. As for mtext, should be: entmakex with plain content and then vla-put-Textstring with the field expression.
-
EliThorne joined the community
-
Give this a try, allows up to 4 values. Probably needs a bit of fine tuning. Only use it with a single line dim. Can add more lines and can change width of boxes look at 20 19. ; Add more lines to a normal Dimension ; By AlanH Oct 2025 (defun c:incdim ( / obj prec ans howmany x newstr ) (setq obj (vlax-ename->vla-object (car (entsel "\nPick Dimension object ")))) (setq prec (vlax-get obj 'PrimaryUnitsPrecision)) (setq tp (vlax-get obj 'TextPosition)) (if (= (setq len (vlax-get obj 'textoverride)) "") (setq newstr (rtos (vlax-get obj 'measurement) 2 prec)) ) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter values " "line 1 " 20 19 newstr "line 2 " 20 19 "" "Line 3" 20 19 "" "Line 4" 20 19 ""))) (setq howmany "Yes") (setq x 0) (while (= howmany "Yes") (setq str (nth (setq x (1+ x)) ans)) (setq newstr (strcat newstr "\n" str )) (if (or (= x 3)(= str ""))(setq howmany "No")) ) (vlax-put obj 'textoverride newstr) (vlax-put obj 'TextPosition tp) (princ) ) (c:incdim)
- Yesterday
-
Another By @Lee Mac Area.lsp look on his web site. https://www.lee-mac.com/arealabel.html
-
Lee Mac started following LISP Assistance
-
Have you defined the variables 'myfilepath' and 'myfilename' somewhere? If not, these symbols will evaluate to nil, yielding the error you have described.
-
Same Penn Foster Oleson Subdivision Nightmare... different day
ReMark replied to Ztrain's topic in Student Project Questions
The answers you seek can be found in the thread entitled... "Penn Foster Student Suffering with Oleson Village Map." I know this because I contributed instructions as well as images. Many P-F students have found the thread beneficial. -
Hi It's not certain that all the functions in this code will work in AutoCAD LT. Try it. (defun c:guardA (/ v nvoD f?) (setq v (member (vla-get-saveAsType (vla-get-openSave (vla-get-preferences (vlax-get-acad-object)))) (list acr14_dwg "v14" ac2000_dwg "v2000" ac2004_dwg "v2004" ac2007_dwg "v2007" ac2010_dwg "v2010" ac2013_dwg "v2013" ac2018_dwg "v2018"))) (setq f? (if (not (vl-directory-files (setq nvoD (strcat (getvar "DWGPREFIX") "EXPORTED\\")))) (VL-MKDIR nvoD) T)) (vla-saveas (vla-get-activedocument (vlax-get-acad-object)) (strcat (if f? nvoD (getvar "DWGPREFIX")) (VL-FILENAME-BASE (getvar "DWGNAME")) "-EXPORTED_" (cadr v) ".dwg") (car v)) (princ "\nDone!") (princ) )
-
Need help with attributes count table
3arizona replied to aridzv's topic in AutoLISP, Visual LISP & DCL
Thanks, I found this lisp that works for me. If anyone is interested here is the link. Visibility Selection -
Steven P started following Field and LISP Assistance
-
LT is not brilliant with VLA- or VL- commands so best really avoid them for now. Perhaps not the most efficient method but try the (command "_.saveas" ...... ) method
-
... have you tested that...
-
Randomnepomog joined the community
-
-
Hi all, I've been trying to accomplish what I thought would be an easy thing, but despite hours of searching I can't seem to get it to work! I'm trying to create a lisp that I can run in AutoCAD LT (2025) that does a "SAVE AS" and simply adds " - EXPORTED" as a suffix onto the original filename. I'd like this to happen without any dialogue boxes popping up, and If it could have the following features it would be absolutley perfect (but these arent crucial). 1. specify the file version from within the lisp 2. save the exported versions into a folder within the same directory called "exported" (and overwrite previous versions if they exist) The closest I've gotten is using the below code to do the saveas, but it throws an error (; error: bad argument type: stringp nil) (defun c:TEST () (vl-load-com) (vla-SaveAs (vla-get-ActiveDocument (vlax-get-acad-object)) (strcat myfilepath myfilename ".dwg") ac2018_dwg) ) If anyone is able to help me out I'd very much appreciate it
-
swanny89 joined the community
-
Migoo joined the community
-
Another simple way is to entmake the mtext with a plain content first, then apply entmod DXF1 with field expression for the mtext.
-
Precisely selecting with a window
SLW210 replied to Discus84's topic in AutoCAD 2D Drafting, Object Properties & Interface
Are you using AutoCAD 2010 as shown in your profile? I do not believe this is an issue in newer AutoCAD versions, I am not sure what version it was fixed though. UPDATE: From the posted thread, looks like AutoCAD 17.1 update or maybe AutoCAD 2018 had the fix. AutoCAD 2023 Help | SELECTIONOFFSCREEN (System Variable) | Autodesk You'll probably need to keep searching and see what workarounds people came up with before the fix. Losing selected objects when zooming/panning etc - AutoCAD 2D Drafting, Object Properties & Interface - AutoCAD Forums Solved: AutoCAD - Zoom after selection lost object selected - Autodesk Community -
dimension Change Qleader Setting via Command Line
SLW210 replied to reza's topic in AutoLISP, Visual LISP & DCL
That LISP the is not original AFAIK. It is a couple of functions, you need to call for it with a LISP to make the settings, etc. Several places to get the correct QlSet.lsp and example LISPs to use it. Qleader lisp routine - AutoLISP, Visual LISP & DCL - AutoCAD Forums Qleader System Variables - AutoLISP, Visual LISP & DCL - AutoCAD Forums qleader lisp - AutoLISP, Visual LISP & DCL - AutoCAD Forums assigning q-leader settings using lisp- 1 reply
-
- 1
-
-
;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq mtext (vla-AddMText mspace (vlax-3d-point pt) 0.0 ; width (0 for default) (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-ObjectID entity)) ">%).Area \\f \"%lu2%pr2%ps\">%") ) ) ;; Set properties (vla-put-Layer mtext "mtext") (vla-put-Height mtext 0.3) (vla-put-AttachmentPoint mtext 5) ; Middle-center (vla-put-InsertionPoint mtext (vlax-3d-point pt)) (vla-put-StyleName mtext "Standard") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; I am replacing entmakex with vla-addmtext and have completed the task. I want to apply various text properties, such as bold, underline, color, style, height, etc.............................thank...........................
-
Need help with attributes count table
BIGAL replied to aridzv's topic in AutoLISP, Visual LISP & DCL
Have a look at lee-mac dynamic block properties there is a get current visibility name in there, also get all visibility names into a list. -
Precisely selecting with a window
BIGAL replied to Discus84's topic in AutoCAD 2D Drafting, Object Properties & Interface
Look at (getvar 'extmax) & (getvar 'extmin) these are the size of your dwg wether your zoomed or not. -
Something I have done for attributes in a block is pop up a dcl with the current attribute values so there is no reason why could not do the same just set a maximum number of lines 1 2 3 4 etc. If you leave a line blank that would be considered end of multi line input. It uses my library Multi getvals.lsp to make the dcl. Some example code can be changed to work with a Dimension. Have a go. ; Change an attribute value in blocks ; Using creation order rather than by tag name ; BY Alan H Sept 2025 (defun AH:blchange( / ss1 blname x inc atts) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq obj (vlax-ename->vla-object (car (entsel "\nPick block object ")))) (setq atts (vlax-invoke obj 'Getattributes)) (setq lst '()) (setq lst '("Enter new values ")) (foreach att atts (setq lst (cons (vlax-get att 'tagstring) lst)) (setq lst (cons 19 lst)) (setq lst (cons 20 lst)) (setq lst (cons (vlax-get att 'Textstring) lst)) ) (setq lst (reverse lst)) (setq ans (AH:getvalsm lst)) (setq x -1) (foreach att atts (vlax-put att 'Textstring (nth (setq x (1+ x)) ans)) ) (princ) ) (aH:blchange) Multi GETVALS.lsp
-
Look for Notepad your Acad.pgp make code even shorter. This the bat file I use. d: cd\alan\lisp findstr %1 *.lsp
-
Tharwat started following Need help with attributes count table
-
Need help with attributes count table
Tharwat replied to aridzv's topic in AutoLISP, Visual LISP & DCL
You can private message me if you are after a custom program. -
drmemo345 joined the community
-
reza started following Change Qleader Setting via Command Line
-
dimension Change Qleader Setting via Command Line
reza posted a topic in AutoLISP, Visual LISP & DCL
Hi everyone When I open a dwg file and use the attached lisp to change the Qleader settings, no changes are made to the settings. Please fix the problem for me. qlset.lsp.lsp test.dwg